Chromium Code Reviews| Index: scripts/slave/recipe_modules/chromedriver/archive.py |
| diff --git a/scripts/slave/recipe_modules/chromedriver/archive.py b/scripts/slave/recipe_modules/chromedriver/archive.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ba82f514452a9b3a9a9526b7022e48cf4eeca0dd |
| --- /dev/null |
| +++ b/scripts/slave/recipe_modules/chromedriver/archive.py |
| @@ -0,0 +1,98 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
|
mikecase (-- gone --)
2016/06/16 17:55:08
Making this CL Android only which means this file
|
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +class Url(object): |
|
jbudorick
2016/05/04 18:10:43
Not sure I see a strong argument for namespacing t
|
| + GS_CHROMIUM_CONTINUOUS_URL = 'gs://chromium-browser-continuous' |
| + GS_CHROMIUM_SNAPSHOT_URL = 'gs://chromium-browser-snapshots' |
| + GS_CHROMIUM_BLINK_SNAPSHOT_URL = 'gs://chromium-webkit-snapshots' |
| + |
| + |
| +class Archive(object): |
| + """Downloads items from the Chromium continuous archive.""" |
| + |
| + CHROME_45_REVISION = '338390' |
|
jbudorick
2016/05/04 18:10:43
Why are we hard-coding these? Can we do this anoth
|
| + CHROME_46_REVISION = '344997' |
| + CHROME_47_REVISION = '352825' |
| + |
| + def __init__(self, m): |
|
jbudorick
2016/05/04 18:10:43
Passing the modules object here seems weird but re
|
| + self.m = m |
| + |
| + def get_download_platform(self): |
| + """Returns the name for this platform on the archive site.""" |
| + if self.m.platform.is_win: |
| + return 'Win' |
| + elif self.m.platform.is_mac: |
| + return 'Mac' |
| + elif self.m.platform.is_linux: |
| + if self.m.platform.bits == 64: |
| + return 'Linux_x64' |
| + else: |
| + return 'Linux' |
| + |
| + def get_latest_revision(self, site=Url.GS_CHROMIUM_CONTINUOUS_URL): |
| + """Returns the latest revision (as a string) available for this platform. |
| + |
| + Args: |
| + site: the archive site to check against, default to the continuous one. |
| + """ |
| + url = site + '/%s/LAST_CHANGE' |
|
jbudorick
2016/05/04 18:10:43
Are you leaving the %s in here intentionally? Does
|
| + step_result = self.m.gsutil.cat( |
| + name='get latest revision', |
| + url=url, |
| + stdout=self.m.raw_io.output(), |
| + step_test_data=lambda: self.m.raw_io.test_api.stream_output( |
| + '123_LATEST_CHROME_REV_456', stream='stdout')) |
| + return step_result.stdout |
| + |
| + def download_chrome(self, revision, dest_dir, |
| + site=Url.GS_CHROMIUM_CONTINUOUS_URL): |
| + """Downloads the packaged Chrome from the archive to the given directory. |
| + |
| + Args: |
| + revision: the revision of Chrome to download. |
| + dest_dir: the directory to download Chrome to. |
| + site: the archive site to download from, default to the continuous one. |
| + |
| + Returns: |
| + The path to the unzipped Chrome binary. |
| + """ |
| + def get_zip_name(): |
| + if self.m.platform.is_win: |
| + return 'chrome-win32' |
| + elif self.m.platform.is_mac: |
| + return 'chrome-mac' |
| + elif self.m.platform.is_linux: |
| + return 'chrome-linux' |
| + |
| + def get_chrome_path_from_package(): |
| + if self.m.platform.is_win: |
| + return 'chrome.exe' |
| + elif self.m.platform.is_mac: |
| + return 'Chromium.app/Contents/MacOS/Chromium' |
| + elif self.m.platform.is_linux: |
| + return 'chrome-wrapper' |
| + |
| + zip_path = self.m.path.join(dest_dir, 'chrome-%s.zip' % revision) |
| + if not self.m.path.exists(zip_path): |
| + url = site + '/%s/%s/%s.zip' % (self.get_download_platform(), revision, |
|
jbudorick
2016/05/04 18:10:43
Why isn't this just
'%s/%s/%s/%s.zip' % (site,
|
| + get_zip_name()) |
| + temp_zip_path = self.m.path.mkdtemp('chrome_zip').join( |
| + 'chrome-%s.zip' % revision) |
| + self.m.gsutil.download_url( |
| + name='download chrome', |
| + url=url, |
| + dest=temp_zip_path) |
| + self.m.zip.unzip(step_name='unzip chrome', |
|
jbudorick
2016/05/04 18:10:43
nit: line break before this
|
| + zip_file=zip_path, |
| + output=dest_dir) |
| + return self.m.path.join( |
| + dest_dir, get_zip_name(), get_chrome_path_from_package()) |
| + |
| + def get_latest_snapshot_version(self): |
| + """Returns the latest revision of snapshot build.""" |
| + return self.get_latest_revision(self.get_snapshot_download_site()) |
| + |
| + def get_snapshot_download_site(self): |
| + """Returns site to download snapshot build according to the platform.""" |
| + return Url.GS_CHROMIUM_SNAPSHOT_URL |