Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/extensions/bin/createNightlies.py

Issue 5673709830406144: Issue 356 - Publish uploaded devbuild on the Chrome Web Store (Closed)
Patch Set: Created May 5, 2014, 2:13 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « .sitescripts.example ('k') | sitescripts/extensions/utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2014 Eyeo GmbH 4 # Copyright (C) 2006-2014 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 ('refresh_token', self.config.refreshToken), 386 ('refresh_token', self.config.refreshToken),
387 ('client_id', self.config.clientID), 387 ('client_id', self.config.clientID),
388 ('client_secret', self.config.clientSecret), 388 ('client_secret', self.config.clientSecret),
389 ('grant_type', 'refresh_token'), 389 ('grant_type', 'refresh_token'),
390 ]) 390 ])
391 )) 391 ))
392 392
393 # upload a new version with the Chrome Web Store API 393 # upload a new version with the Chrome Web Store API
394 # https://developer.chrome.com/webstore/using_webstore_api#uploadexisitng 394 # https://developer.chrome.com/webstore/using_webstore_api#uploadexisitng
395 395
396 request = urllib2.Request('https://www.googleapis.com/upload/chromewebstore/ v1.1/items/' + self.config.galleryID) 396 request = urllib2.Request('https://www.googleapis.com/upload/chromewebstore/ v1.1/items/' + self.config.devbuildGalleryID)
397 request.get_method = lambda: 'PUT' 397 request.get_method = lambda: 'PUT'
398 request.add_header('Authorization', '%s %s' % (response['token_type'], respo nse['access_token'])) 398 request.add_header('Authorization', '%s %s' % (response['token_type'], respo nse['access_token']))
399 request.add_header('x-goog-api-version', '2') 399 request.add_header('x-goog-api-version', '2')
400 400
401 with open(self.path, 'rb') as file: 401 with open(self.path, 'rb') as file:
402 if file.read(8) != 'Cr24\x02\x00\x00\x00': 402 if file.read(8) != 'Cr24\x02\x00\x00\x00':
403 raise Exception('not a chrome extension or unknown CRX version') 403 raise Exception('not a chrome extension or unknown CRX version')
404 404
405 # skip public key and signature 405 # skip public key and signature
406 file.seek(sum(struct.unpack('<II', file.read(8))), os.SEEK_CUR) 406 file.seek(sum(struct.unpack('<II', file.read(8))), os.SEEK_CUR)
407 407
408 request.add_header('Content-Length', os.fstat(file.fileno()).st_size - fil e.tell()) 408 request.add_header('Content-Length', os.fstat(file.fileno()).st_size - fil e.tell())
409 request.add_data(file) 409 request.add_data(file)
410 410
411 response = json.load(urllib2.urlopen(request)) 411 response = json.load(urllib2.urlopen(request))
412 412
413 if response['uploadState'] == 'FAILURE': 413 if response['uploadState'] == 'FAILURE':
414 raise Exception(response['itemError']) 414 raise Exception(response['itemError'])
415 415
416 # publish the new version on the Chrome Web Store
417 # https://developer.chrome.com/webstore/using_webstore_api#publishpublic
418
419 request = urllib2.Request('https://www.googleapis.com/upload/chromewebstore/ v1.1/items/%s/publish' % self.config.devbuildGalleryID)
420 request.get_method = lambda: 'POST'
421 request.add_header('Authorization', '%s %s' % (response['token_type'], respo nse['access_token']))
422 request.add_header('x-goog-api-version', '2')
423 request.add_header('Content-Length', '0')
424
425 response = json.load(urllib2.urlopen(request))
426
427 if any(status != 'ITEM_PENDING_REVIEW' for status in response['status']):
428 raise Exception(response['statusDetail'])
429
416 def run(self): 430 def run(self):
417 """ 431 """
418 Run the nightly build process for one extension 432 Run the nightly build process for one extension
419 """ 433 """
420 try: 434 try:
421 if self.config.type == 'ie': 435 if self.config.type == 'ie':
422 # We cannot build IE builds, simply list the builds already in 436 # We cannot build IE builds, simply list the builds already in
423 # the directory. Basename has to be deduced from the repository name. 437 # the directory. Basename has to be deduced from the repository name.
424 self.basename = os.path.basename(self.config.repository) 438 self.basename = os.path.basename(self.config.repository)
425 else: 439 else:
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 except Exception, ex: 505 except Exception, ex:
492 print >>sys.stderr, "The build for %s failed:" % repo 506 print >>sys.stderr, "The build for %s failed:" % repo
493 traceback.print_exc() 507 traceback.print_exc()
494 508
495 file = open(nightlyConfigFile, 'wb') 509 file = open(nightlyConfigFile, 'wb')
496 nightlyConfig.write(file) 510 nightlyConfig.write(file)
497 511
498 512
499 if __name__ == '__main__': 513 if __name__ == '__main__':
500 main() 514 main()
OLDNEW
« no previous file with comments | « .sitescripts.example ('k') | sitescripts/extensions/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld