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

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

Issue 29733599: Issue 6523 - Update softlink for downloaded builds (Closed) Base URL: https://hg.adblockplus.org/abpssembly/file/f92468d41835
Patch Set: Created March 26, 2018, 9:36 a.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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 necessary = ['passed_review', 'reviewed', 'processed', 'valid'] 548 necessary = ['passed_review', 'reviewed', 'processed', 'valid']
549 if all(response[x] for x in necessary): 549 if all(response[x] for x in necessary):
550 download_url = response['files'][0]['download_url'] 550 download_url = response['files'][0]['download_url']
551 checksum = response['files'][0]['hash'] 551 checksum = response['files'][0]['hash']
552 552
553 filename = '{}-{}.xpi'.format(self.basename, version) 553 filename = '{}-{}.xpi'.format(self.basename, version)
554 file_path = os.path.join( 554 self.path = os.path.join(
555 config.get('extensions', 'nightliesDirectory'), 555 config.get('extensions', 'nightliesDirectory'),
556 self.basename, 556 self.basename,
557 filename 557 filename
558 ) 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()
569 sha256 = hashlib.sha256(file_content) 569 sha256 = hashlib.sha256(file_content)
570 returned_checksum = '{}:{}'.format(sha256.name, sha256.hexdigest()) 570 returned_checksum = '{}:{}'.format(sha256.name, sha256.hexdigest())
571 571
572 if returned_checksum != checksum: 572 if returned_checksum != checksum:
573 logging.error('Checksum could not be verified: {} vs {}' 573 logging.error('Checksum could not be verified: {} vs {}'
574 ''.format(checksum, returned_checksum)) 574 ''.format(checksum, returned_checksum))
575 575
576 with open(file_path, 'w') as fp: 576 with open(self.path, 'w') as fp:
577 fp.write(file_content) 577 fp.write(file_content)
578 578
579 self.update_link = os.path.join( 579 self.update_link = os.path.join(
580 config.get('extensions', 'nightliesURL'), 580 config.get('extensions', 'nightliesURL'),
581 self.basename, 581 self.basename,
582 filename 582 filename
583 ) 583 )
584 584
585 self.remove_from_downloads_lockfile(self.config.type, 585 self.remove_from_downloads_lockfile(self.config.type,
586 'version', 586 'version',
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
850 # Update soft link to latest build
851 baseDir = os.path.join(
852 self.config.nightliesDirectory, self.basename
853 )
854 linkPath = os.path.join(
855 baseDir, '00latest' + self.config.packageSuffix
856 )
857
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
849 finally: 860 finally:
850 # clean up 861 # clean up
851 if self.tempdir: 862 if self.tempdir:
852 shutil.rmtree(self.tempdir, ignore_errors=True) 863 shutil.rmtree(self.tempdir, ignore_errors=True)
853 864
854 865
855 def main(download=False): 866 def main(download=False):
856 """ 867 """
857 main function for createNightlies.py 868 main function for createNightlies.py
858 """ 869 """
(...skipping 20 matching lines...) Expand all
879 890
880 file = open(nightlyConfigFile, 'wb') 891 file = open(nightlyConfigFile, 'wb')
881 nightlyConfig.write(file) 892 nightlyConfig.write(file)
882 893
883 894
884 if __name__ == '__main__': 895 if __name__ == '__main__':
885 parser = argparse.ArgumentParser() 896 parser = argparse.ArgumentParser()
886 parser.add_argument('--download', action='store_true', default=False) 897 parser.add_argument('--download', action='store_true', default=False)
887 args = parser.parse_args() 898 args = parser.parse_args()
888 main(args.download) 899 main(args.download)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld