OLD | NEW |
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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 'https://accounts.google.com/o/oauth2/token', | 383 'https://accounts.google.com/o/oauth2/token', |
384 | 384 |
385 urlencode([ | 385 urlencode([ |
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 auth_token = '%s %s' % (response['token_type'], response['access_token']) |
| 394 |
393 # upload a new version with the Chrome Web Store API | 395 # upload a new version with the Chrome Web Store API |
394 # https://developer.chrome.com/webstore/using_webstore_api#uploadexisitng | 396 # https://developer.chrome.com/webstore/using_webstore_api#uploadexisitng |
395 | 397 |
396 request = urllib2.Request('https://www.googleapis.com/upload/chromewebstore/
v1.1/items/' + self.config.devbuildGalleryID) | 398 request = urllib2.Request('https://www.googleapis.com/upload/chromewebstore/
v1.1/items/' + self.config.devbuildGalleryID) |
397 request.get_method = lambda: 'PUT' | 399 request.get_method = lambda: 'PUT' |
398 request.add_header('Authorization', '%s %s' % (response['token_type'], respo
nse['access_token'])) | 400 request.add_header('Authorization', auth_token) |
399 request.add_header('x-goog-api-version', '2') | 401 request.add_header('x-goog-api-version', '2') |
400 | 402 |
401 with open(self.path, 'rb') as file: | 403 with open(self.path, 'rb') as file: |
402 if file.read(8) != 'Cr24\x02\x00\x00\x00': | 404 if file.read(8) != 'Cr24\x02\x00\x00\x00': |
403 raise Exception('not a chrome extension or unknown CRX version') | 405 raise Exception('not a chrome extension or unknown CRX version') |
404 | 406 |
405 # skip public key and signature | 407 # skip public key and signature |
406 file.seek(sum(struct.unpack('<II', file.read(8))), os.SEEK_CUR) | 408 file.seek(sum(struct.unpack('<II', file.read(8))), os.SEEK_CUR) |
407 | 409 |
408 request.add_header('Content-Length', os.fstat(file.fileno()).st_size - fil
e.tell()) | 410 request.add_header('Content-Length', os.fstat(file.fileno()).st_size - fil
e.tell()) |
409 request.add_data(file) | 411 request.add_data(file) |
410 | 412 |
411 response = json.load(urllib2.urlopen(request)) | 413 response = json.load(urllib2.urlopen(request)) |
412 | 414 |
413 if response['uploadState'] == 'FAILURE': | 415 if response['uploadState'] == 'FAILURE': |
414 raise Exception(response['itemError']) | 416 raise Exception(response['itemError']) |
415 | 417 |
416 # publish the new version on the Chrome Web Store | 418 # publish the new version on the Chrome Web Store |
417 # https://developer.chrome.com/webstore/using_webstore_api#publishpublic | 419 # https://developer.chrome.com/webstore/using_webstore_api#publishpublic |
418 | 420 |
419 request = urllib2.Request('https://www.googleapis.com/upload/chromewebstore/
v1.1/items/%s/publish' % self.config.devbuildGalleryID) | 421 request = urllib2.Request('https://www.googleapis.com/upload/chromewebstore/
v1.1/items/%s/publish' % self.config.devbuildGalleryID) |
420 request.get_method = lambda: 'POST' | 422 request.get_method = lambda: 'POST' |
421 request.add_header('Authorization', '%s %s' % (response['token_type'], respo
nse['access_token'])) | 423 request.add_header('Authorization', auth_token) |
422 request.add_header('x-goog-api-version', '2') | 424 request.add_header('x-goog-api-version', '2') |
423 request.add_header('Content-Length', '0') | 425 request.add_header('Content-Length', '0') |
424 | 426 |
425 response = json.load(urllib2.urlopen(request)) | 427 response = json.load(urllib2.urlopen(request)) |
426 | 428 |
427 if any(status != 'ITEM_PENDING_REVIEW' for status in response['status']): | 429 if any(status != 'ITEM_PENDING_REVIEW' for status in response['status']): |
428 raise Exception(response['statusDetail']) | 430 raise Exception(response['statusDetail']) |
429 | 431 |
430 def run(self): | 432 def run(self): |
431 """ | 433 """ |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 except Exception, ex: | 507 except Exception, ex: |
506 print >>sys.stderr, "The build for %s failed:" % repo | 508 print >>sys.stderr, "The build for %s failed:" % repo |
507 traceback.print_exc() | 509 traceback.print_exc() |
508 | 510 |
509 file = open(nightlyConfigFile, 'wb') | 511 file = open(nightlyConfigFile, 'wb') |
510 nightlyConfig.write(file) | 512 nightlyConfig.write(file) |
511 | 513 |
512 | 514 |
513 if __name__ == '__main__': | 515 if __name__ == '__main__': |
514 main() | 516 main() |
OLD | NEW |