Modified: trunk/Tools/ChangeLog (225497 => 225498)
--- trunk/Tools/ChangeLog 2017-12-04 22:52:26 UTC (rev 225497)
+++ trunk/Tools/ChangeLog 2017-12-04 23:05:00 UTC (rev 225498)
@@ -1,3 +1,23 @@
+2017-12-04 Ross Kirsling <[email protected]>
+
+ download-latest-github-release.py should use existing release ANY time latest is not found
+ https://bugs.webkit.org/show_bug.cgi?id=180293
+
+ Reviewed by Per Arne Vollan.
+
+ * Scripts/download-latest-github-release.py:
+ (find_latest_release):
+ Handle all URLErrors, not just HTTPErrors. Stop special-casing 404s.
+
+ (main):
+ Rearrange logic so any failure to detect a latest release falls back to an existing release. Improve logging.
+
+ (Status):
+ (download_release):
+ (load_version_info): Renamed from existing_version info.
+ (has_latest_release): Deleted.
+ Cleanup.
+
2017-12-04 Joseph Pecoraro <[email protected]>
Exclude some more leak callstacks
Modified: trunk/Tools/Scripts/download-latest-github-release.py (225497 => 225498)
--- trunk/Tools/Scripts/download-latest-github-release.py 2017-12-04 22:52:26 UTC (rev 225497)
+++ trunk/Tools/Scripts/download-latest-github-release.py 2017-12-04 23:05:00 UTC (rev 225498)
@@ -46,7 +46,7 @@
DOWNLOADED = 0
UP_TO_DATE = 1
COULD_NOT_FIND = 2
- USE_EXISTING_VERSION = 3
+ USING_EXISTING = 3
def parse_args(argv):
@@ -69,9 +69,8 @@
try:
response = urllib2.urlopen(request)
- except urllib2.HTTPError, error:
- if error.code != 404:
- print error.code, error.reason
+ except urllib2.URLError as error:
+ print error
return None, None
data = ""
@@ -82,7 +81,12 @@
return None, None
-def existing_version_info(version_info_path):
+def download_release(source_url, target_path):
+ with open(target_path, 'wb') as file:
+ file.write(urllib2.urlopen(source_url).read())
+
+
+def load_version_info(version_info_path):
if not os.path.exists(version_info_path):
return None
@@ -90,15 +94,6 @@
return json.load(file)
-def has_latest_release(version_info_path, version_info):
- return existing_version_info(version_info_path) == version_info
-
-
-def download_release(source_url, target_path):
- with open(target_path, 'wb') as file:
- file.write(urllib2.urlopen(source_url).read())
-
-
def save_version_info(version_info_path, version_info):
with open(version_info_path, 'w') as file:
json.dump(version_info, file)
@@ -110,35 +105,37 @@
binary_path = os.path.join(args.output_dir, args.filename)
version_info_path = binary_path + '.version'
- print 'Seeking latest release of {} from {}...'.format(args.filename, args.repo)
+ print 'Updating {}...'.format(args.filename)
- try:
- release_url, version_info = find_latest_release(args)
+ existing_version_info = load_version_info(version_info_path)
+ if existing_version_info:
+ print 'Found existing release:', existing_version_info['tag_name']
+ else:
+ print 'No existing release found.'
- if not release_url:
- print 'No release found!'
- return Status.COULD_NOT_FIND
+ print 'Seeking latest release from {}...'.format(args.repo)
+ release_url, latest_version_info = find_latest_release(args)
- if has_latest_release(version_info_path, version_info):
- print 'Already up-to-date:', existing_version_info(version_info_path)
- return Status.UP_TO_DATE
+ if not latest_version_info:
+ if existing_version_info:
+ print 'Falling back to existing release!'
+ return Status.USING_EXISTING
- except urllib2.URLError, error:
- print error
+ print 'No release found!'
+ return Status.COULD_NOT_FIND
- version_info = existing_version_info(version_info_path)
- if version_info:
- print 'Use existing version:', version_info
- return Status.USE_EXISTING_VERSION
- else:
- return Status.COULD_NOT_FIND
+ print 'Found latest release:', latest_version_info['tag_name']
+ if latest_version_info == existing_version_info:
+ print 'Already up-to-date!'
+ return Status.UP_TO_DATE
+
if not os.path.exists(args.output_dir):
os.makedirs(args.output_dir)
- print 'Downloading {} to {}...'.format(version_info['tag_name'], os.path.abspath(args.output_dir))
+ print 'Downloading to {}...'.format(os.path.abspath(args.output_dir))
download_release(release_url, binary_path)
- save_version_info(version_info_path, version_info)
+ save_version_info(version_info_path, latest_version_info)
print 'Done!'
return Status.DOWNLOADED