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..238736ee87bfb462da8bcb96356ed63b3d18e8cc |
| --- /dev/null |
| +++ b/scripts/slave/recipe_modules/chromedriver/archive.py |
| @@ -0,0 +1,104 @@ |
| +# Copyright 2015 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +class Url(object): |
| + 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_42_REVISION = '317499' |
| + CHROME_43_REVISION = '323865' |
| + CHROME_44_REVISION = '330231' |
| + |
| + def __init__(self, api): |
| + self.api = api |
|
luqui
2015/08/06 00:57:37
Glancing through this, it appears that you only ev
mikecase (-- gone --)
2016/04/04 21:46:42
Done
|
| + |
| + 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' |
| + step_result = self.api.m.gsutil.cat( |
| + name='get latest revision', |
| + url=url, |
| + stdout=self.api.m.raw_io.output(), |
| + step_test_data=lambda: self.api.m.raw_io.test_api.stream_output( |
| + '444444', 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.api.m.platform.is_win: |
| + return 'chrome-win32' |
| + elif self.api.m.platform.is_mac: |
| + return 'chrome-mac' |
| + elif self.api.m.platform.is_linux: |
| + return 'chrome-linux' |
| + def get_chrome_path_from_package(): |
| + if self.api.m.platform.is_win: |
| + return 'chrome.exe' |
| + elif self.api.m.platform.is_mac: |
| + return 'Chromium.app/Contents/MacOS/Chromium' |
| + elif self.api.m.platform.is_linux: |
| + return 'chrome' |
| + zip_path = self.api.m.path.join(dest_dir, 'chrome-%s.zip' % revision) |
| + if not self.api.m.path.exists(zip_path): |
| + url = site + '/%s/%s/%s.zip' % (self.get_download_platform(), revision, |
| + get_zip_name()) |
| + temp_zip_path = self.api.m.path.mkdtemp('chrome_zip').join( |
| + 'chrome-%s.zip' % revision) |
| + self.api.m.gsutil.download_url( |
| + name='download chrome', |
| + url=url, |
| + dest=temp_zip_path) |
| + self.api.m.zip.unzip(step_name='unzip chrome', |
| + zip_file=zip_path, |
| + output=dest_dir) |
| + return self.api.m.path.join( |
| + dest_dir, get_zip_name(), get_chrome_path_from_package()) |
| + |
| + def get_download_platform(self): |
| + """Returns the name for this platform on the archive site.""" |
| + if self.api.m.platform.is_win: |
| + return 'Win' |
| + elif self.api.m.platform.is_mac: |
| + return 'Mac' |
| + elif self.api.m.platform.is_linux: |
| + if self.api.m.platform.bits == 64: |
| + return 'Linux_x64' |
| + else: |
| + return 'Linux' |
| + |
| + 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 the site to download snapshot build according to the platform. |
| + |
| + For Linux 32-bit, it is chromium snapshot build. |
| + For other platform, it is blink snapshot build. |
| + Because there is no linux32 blink snapshot build. |
| + """ |
| + if self.get_download_platform() in ('Linux', 'Linux_x64', 'Mac'): |
| + return Url.GS_CHROMIUM_SNAPSHOT_URL |
| + else: |
| + return Url.GS_CHROMIUM_BLINK_SNAPSHOT_URL |