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

Delta Between Two Patch Sets: sitescripts/extensions/bin/createNightlies.py

Issue 29733599: Issue 6523 - Update softlink for downloaded builds (Closed) Base URL: https://hg.adblockplus.org/abpssembly/file/f92468d41835
Left Patch Set: Created March 26, 2018, 9:36 a.m.
Right Patch Set: Created March 27, 2018, 10:27 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 828
829 if self.config.type in downloads: 829 if self.config.type in downloads:
830 try: 830 try:
831 self.copyRepository() 831 self.copyRepository()
832 self.readGeckoMetadata() 832 self.readGeckoMetadata()
833 833
834 for data in download_info[self.config.type]: 834 for data in download_info[self.config.type]:
835 self.version = data['version'] 835 self.version = data['version']
836 836
837 self.download_from_mozilla_addons(**data) 837 self.download_from_mozilla_addons(**data)
838 838 if os.path.exists(self.path):
839 # write out changelog 839 # write out changelog
840 self.writeChangelog(self.getChanges()) 840 self.writeChangelog(self.getChanges())
841 841
842 # write update manifest 842 # write update manifest
843 self.writeUpdateManifest() 843 self.writeUpdateManifest()
844 844
845 # retire old builds 845 # retire old builds
846 versions = self.retireBuilds() 846 versions = self.retireBuilds()
847 # update index page 847 # update index page
848 self.updateIndex(versions) 848 self.updateIndex(versions)
849 849
850 # Update soft link to latest build 850 # Update soft link to latest build
851 baseDir = os.path.join( 851 baseDir = os.path.join(
852 self.config.nightliesDirectory, self.basename 852 self.config.nightliesDirectory, self.basename
853 ) 853 )
854 linkPath = os.path.join( 854 linkPath = os.path.join(
855 baseDir, '00latest' + self.config.packageSuffix 855 baseDir, '00latest' + self.config.packageSuffix
856 ) 856 )
857 857
858 self.symlink_or_copy(self.path, linkPath) 858 self.symlink_or_copy(self.path, linkPath)
Vasily Kuznetsov 2018/03/26 19:12:11 What if we don't have `self.path` because in `down
859
860 finally: 859 finally:
861 # clean up 860 # clean up
862 if self.tempdir: 861 if self.tempdir:
863 shutil.rmtree(self.tempdir, ignore_errors=True) 862 shutil.rmtree(self.tempdir, ignore_errors=True)
864 863
865 864
866 def main(download=False): 865 def main(download=False):
867 """ 866 """
868 main function for createNightlies.py 867 main function for createNightlies.py
869 """ 868 """
(...skipping 20 matching lines...) Expand all
890 889
891 file = open(nightlyConfigFile, 'wb') 890 file = open(nightlyConfigFile, 'wb')
892 nightlyConfig.write(file) 891 nightlyConfig.write(file)
893 892
894 893
895 if __name__ == '__main__': 894 if __name__ == '__main__':
896 parser = argparse.ArgumentParser() 895 parser = argparse.ArgumentParser()
897 parser.add_argument('--download', action='store_true', default=False) 896 parser.add_argument('--download', action='store_true', default=False)
898 args = parser.parse_args() 897 args = parser.parse_args()
899 main(args.download) 898 main(args.download)
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld