Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-2013 Eyeo GmbH | 4 # Copyright (C) 2006-2013 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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
410 | 410 |
411 # upload a new version with the Chrome Web Store API | 411 # upload a new version with the Chrome Web Store API |
412 # https://developer.chrome.com/webstore/using_webstore_api#uploadexisitng | 412 # https://developer.chrome.com/webstore/using_webstore_api#uploadexisitng |
413 | 413 |
414 request = urllib2.Request('https://www.googleapis.com/upload/chromewebstore/ v1.1/items/' + self.config.galleryID) | 414 request = urllib2.Request('https://www.googleapis.com/upload/chromewebstore/ v1.1/items/' + self.config.galleryID) |
415 request.get_method = lambda: 'PUT' | 415 request.get_method = lambda: 'PUT' |
416 request.add_header('Authorization', '%s %s' % (response['token_type'], respo nse['access_token'])) | 416 request.add_header('Authorization', '%s %s' % (response['token_type'], respo nse['access_token'])) |
417 request.add_header('x-goog-api-version', '2') | 417 request.add_header('x-goog-api-version', '2') |
418 | 418 |
419 with open(self.path, 'rb') as file: | 419 with open(self.path, 'rb') as file: |
420 # skip CRX magic and version | 420 if file.read(8) != 'Cr24\x02\x00\x00\x00': |
421 offset = 8 | 421 raise Exception('not a chrome extension or unknown CRX version') |
422 file.seek(offset) | |
423 | 422 |
424 # skip public key and signature | 423 # skip public key and signature |
425 offset += 8 + sum(struct.unpack('<II', file.read(8))) | 424 file.seek(sum(struct.unpack('<II', file.read(8))), os.SEEK_CUR) |
Wladimir Palant
2014/04/21 20:22:56
Please don't skip magic number and version - read
Sebastian Noack
2014/04/21 20:46:36
Done.
| |
426 file.seek(offset) | 425 |
Wladimir Palant
2014/04/21 20:22:56
Please use os.SEEK_CUR as second parameter to file
Sebastian Noack
2014/04/21 20:46:36
Done.
| |
427 | 426 request.add_header('Content-Length', os.fstat(file.fileno()).st_size - fil e.tell()) |
428 request.add_header('Content-Length', os.fstat(file.fileno()).st_size - off set) | |
429 request.add_data(file) | 427 request.add_data(file) |
430 | 428 |
431 response = json.load(urllib2.urlopen(request)) | 429 response = json.load(urllib2.urlopen(request)) |
432 | 430 |
433 if response['uploadState'] == 'FAILURE': | 431 if response['uploadState'] == 'FAILURE': |
434 raise Exception(response['itemError']) | 432 raise Exception(response['itemError']) |
435 | 433 |
436 def run(self): | 434 def run(self): |
437 """ | 435 """ |
438 Run the nightly build process for one extension | 436 Run the nightly build process for one extension |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
473 | 471 |
474 if self.config.type == 'ie': | 472 if self.config.type == 'ie': |
475 self.writeIEUpdateManifest(versions) | 473 self.writeIEUpdateManifest(versions) |
476 | 474 |
477 # update index page | 475 # update index page |
478 self.updateIndex(versions) | 476 self.updateIndex(versions) |
479 | 477 |
480 # update nightlies config | 478 # update nightlies config |
481 self.config.latestRevision = self.revision | 479 self.config.latestRevision = self.revision |
482 | 480 |
483 if self.config.clientID and self.config.clientSecret and self.config.refre shToken: | 481 if self.type == 'chrome' and self.config.clientID and self.config.clientSe cret and self.config.refreshToken: |
Wladimir Palant
2014/04/21 20:22:56
I think it makes sense to keep the type == 'chrome
Sebastian Noack
2014/04/21 20:46:36
Done.
| |
484 self.uploadToChromeWebStore() | 482 self.uploadToChromeWebStore() |
485 finally: | 483 finally: |
486 # clean up | 484 # clean up |
487 if self.tempdir: | 485 if self.tempdir: |
488 shutil.rmtree(self.tempdir, ignore_errors=True) | 486 shutil.rmtree(self.tempdir, ignore_errors=True) |
489 | 487 |
490 | 488 |
491 def main(): | 489 def main(): |
492 """ | 490 """ |
493 main function for createNightlies.py | 491 main function for createNightlies.py |
(...skipping 17 matching lines...) Expand all Loading... | |
511 except Exception, ex: | 509 except Exception, ex: |
512 print >>sys.stderr, "The build for %s failed:" % repo | 510 print >>sys.stderr, "The build for %s failed:" % repo |
513 traceback.print_exc() | 511 traceback.print_exc() |
514 | 512 |
515 file = open(nightlyConfigFile, 'wb') | 513 file = open(nightlyConfigFile, 'wb') |
516 nightlyConfig.write(file) | 514 nightlyConfig.write(file) |
517 | 515 |
518 | 516 |
519 if __name__ == '__main__': | 517 if __name__ == '__main__': |
520 main() | 518 main() |
LEFT | RIGHT |