| LEFT | RIGHT |
| 1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
| 2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
| 3 # | 3 # |
| 4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
| 5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
| 6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
| 7 # | 7 # |
| 8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 config = get_config() | 538 config = get_config() |
| 539 iss = config.get('extensions', 'amo_key') | 539 iss = config.get('extensions', 'amo_key') |
| 540 secret = config.get('extensions', 'amo_secret') | 540 secret = config.get('extensions', 'amo_secret') |
| 541 | 541 |
| 542 url = ('https://addons.mozilla.org/api/v3/addons/{}/' | 542 url = ('https://addons.mozilla.org/api/v3/addons/{}/' |
| 543 'versions/{}/').format(app_id, version) | 543 'versions/{}/').format(app_id, version) |
| 544 | 544 |
| 545 request = self.generate_jwt_request(iss, secret, url, 'GET') | 545 request = self.generate_jwt_request(iss, secret, url, 'GET') |
| 546 response = json.load(urllib2.urlopen(request)) | 546 response = json.load(urllib2.urlopen(request)) |
| 547 | 547 |
| 548 filename = '{}-{}.xpi'.format(self.basename, version) |
| 549 self.path = os.path.join( |
| 550 config.get('extensions', 'nightliesDirectory'), |
| 551 self.basename, |
| 552 filename |
| 553 ) |
| 554 |
| 548 necessary = ['passed_review', 'reviewed', 'processed', 'valid'] | 555 necessary = ['passed_review', 'reviewed', 'processed', 'valid'] |
| 549 if all(response[x] for x in necessary): | 556 if all(response[x] for x in necessary): |
| 550 download_url = response['files'][0]['download_url'] | 557 download_url = response['files'][0]['download_url'] |
| 551 checksum = response['files'][0]['hash'] | 558 checksum = response['files'][0]['hash'] |
| 552 | |
| 553 filename = '{}-{}.xpi'.format(self.basename, version) | |
| 554 self.path = os.path.join( | |
| 555 config.get('extensions', 'nightliesDirectory'), | |
| 556 self.basename, | |
| 557 filename | |
| 558 ) | |
| 559 | 559 |
| 560 request = self.generate_jwt_request(iss, secret, download_url, | 560 request = self.generate_jwt_request(iss, secret, download_url, |
| 561 'GET') | 561 'GET') |
| 562 try: | 562 try: |
| 563 response = urllib2.urlopen(request) | 563 response = urllib2.urlopen(request) |
| 564 except urllib2.HTTPError as e: | 564 except urllib2.HTTPError as e: |
| 565 logging.error(e.read()) | 565 logging.error(e.read()) |
| 566 | 566 |
| 567 # Verify the extension's integrity | 567 # Verify the extension's integrity |
| 568 file_content = response.read() | 568 file_content = response.read() |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 | 889 |
| 890 file = open(nightlyConfigFile, 'wb') | 890 file = open(nightlyConfigFile, 'wb') |
| 891 nightlyConfig.write(file) | 891 nightlyConfig.write(file) |
| 892 | 892 |
| 893 | 893 |
| 894 if __name__ == '__main__': | 894 if __name__ == '__main__': |
| 895 parser = argparse.ArgumentParser() | 895 parser = argparse.ArgumentParser() |
| 896 parser.add_argument('--download', action='store_true', default=False) | 896 parser.add_argument('--download', action='store_true', default=False) |
| 897 args = parser.parse_args() | 897 args = parser.parse_args() |
| 898 main(args.download) | 898 main(args.download) |
| LEFT | RIGHT |