Changeset 225498 in webkit


Ignore:
Timestamp:
Dec 4, 2017 3:05:00 PM (6 years ago)
Author:
Ross Kirsling
Message:

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.

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r225496 r225498  
     12017-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
    1212017-12-04  Joseph Pecoraro  <pecoraro@apple.com>
    222
  • trunk/Tools/Scripts/download-latest-github-release.py

    r225361 r225498  
    4747    UP_TO_DATE = 1
    4848    COULD_NOT_FIND = 2
    49     USE_EXISTING_VERSION = 3
     49    USING_EXISTING = 3
    5050
    5151
     
    7070    try:
    7171        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
    7574        return None, None
    7675
     
    8382
    8483
    85 def existing_version_info(version_info_path):
     84def download_release(source_url, target_path):
     85    with open(target_path, 'wb') as file:
     86        file.write(urllib2.urlopen(source_url).read())
     87
     88
     89def load_version_info(version_info_path):
    8690    if not os.path.exists(version_info_path):
    8791        return None
     
    8993    with open(version_info_path) as file:
    9094        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_info
    95 
    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())
    10095
    10196
     
    111106    version_info_path = binary_path + '.version'
    112107
    113     print 'Seeking latest release of {} from {}...'.format(args.filename, args.repo)
     108    print 'Updating {}...'.format(args.filename)
    114109
    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.'
    117115
    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)
    121118
    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
    125123
    126     except urllib2.URLError, error:
    127         print error
     124        print 'No release found!'
     125        return Status.COULD_NOT_FIND
    128126
    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
    135132
    136133    if not os.path.exists(args.output_dir):
    137134        os.makedirs(args.output_dir)
    138135
    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))
    140137    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)
    142139    print 'Done!'
    143140
Note: See TracChangeset for help on using the changeset viewer.