Changeset 225498 in webkit
- Timestamp:
- Dec 4, 2017 3:05:00 PM (6 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r225496 r225498 1 2017-12-04 Ross Kirsling <ross.kirsling@sony.com> 2 3 download-latest-github-release.py should use existing release ANY time latest is not found 4 https://bugs.webkit.org/show_bug.cgi?id=180293 5 6 Reviewed by Per Arne Vollan. 7 8 * Scripts/download-latest-github-release.py: 9 (find_latest_release): 10 Handle all URLErrors, not just HTTPErrors. Stop special-casing 404s. 11 12 (main): 13 Rearrange logic so any failure to detect a latest release falls back to an existing release. Improve logging. 14 15 (Status): 16 (download_release): 17 (load_version_info): Renamed from existing_version info. 18 (has_latest_release): Deleted. 19 Cleanup. 20 1 21 2017-12-04 Joseph Pecoraro <pecoraro@apple.com> 2 22 -
trunk/Tools/Scripts/download-latest-github-release.py
r225361 r225498 47 47 UP_TO_DATE = 1 48 48 COULD_NOT_FIND = 2 49 US E_EXISTING_VERSION= 349 USING_EXISTING = 3 50 50 51 51 … … 70 70 try: 71 71 response = urllib2.urlopen(request) 72 except urllib2.HTTPError, error: 73 if error.code != 404: 74 print error.code, error.reason 72 except urllib2.URLError as error: 73 print error 75 74 return None, None 76 75 … … 83 82 84 83 85 def existing_version_info(version_info_path): 84 def download_release(source_url, target_path): 85 with open(target_path, 'wb') as file: 86 file.write(urllib2.urlopen(source_url).read()) 87 88 89 def load_version_info(version_info_path): 86 90 if not os.path.exists(version_info_path): 87 91 return None … … 89 93 with open(version_info_path) as file: 90 94 return json.load(file) 91 92 93 def has_latest_release(version_info_path, version_info):94 return existing_version_info(version_info_path) == version_info95 96 97 def download_release(source_url, target_path):98 with open(target_path, 'wb') as file:99 file.write(urllib2.urlopen(source_url).read())100 95 101 96 … … 111 106 version_info_path = binary_path + '.version' 112 107 113 print ' Seeking latest release of {} from {}...'.format(args.filename, args.repo)108 print 'Updating {}...'.format(args.filename) 114 109 115 try: 116 release_url, version_info = find_latest_release(args) 110 existing_version_info = load_version_info(version_info_path) 111 if existing_version_info: 112 print 'Found existing release:', existing_version_info['tag_name'] 113 else: 114 print 'No existing release found.' 117 115 118 if not release_url: 119 print 'No release found!' 120 return Status.COULD_NOT_FIND 116 print 'Seeking latest release from {}...'.format(args.repo) 117 release_url, latest_version_info = find_latest_release(args) 121 118 122 if has_latest_release(version_info_path, version_info): 123 print 'Already up-to-date:', existing_version_info(version_info_path) 124 return Status.UP_TO_DATE 119 if not latest_version_info: 120 if existing_version_info: 121 print 'Falling back to existing release!' 122 return Status.USING_EXISTING 125 123 126 except urllib2.URLError, error:127 print error124 print 'No release found!' 125 return Status.COULD_NOT_FIND 128 126 129 version_info = existing_version_info(version_info_path) 130 if version_info: 131 print 'Use existing version:', version_info 132 return Status.USE_EXISTING_VERSION 133 else: 134 return Status.COULD_NOT_FIND 127 print 'Found latest release:', latest_version_info['tag_name'] 128 129 if latest_version_info == existing_version_info: 130 print 'Already up-to-date!' 131 return Status.UP_TO_DATE 135 132 136 133 if not os.path.exists(args.output_dir): 137 134 os.makedirs(args.output_dir) 138 135 139 print 'Downloading {} to {}...'.format(version_info['tag_name'],os.path.abspath(args.output_dir))136 print 'Downloading to {}...'.format(os.path.abspath(args.output_dir)) 140 137 download_release(release_url, binary_path) 141 save_version_info(version_info_path, version_info)138 save_version_info(version_info_path, latest_version_info) 142 139 print 'Done!' 143 140
Note: See TracChangeset
for help on using the changeset viewer.