Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / chrome / test / chromedriver / archive.py
blob387a3964e362fab7bee5eecac0790a1dc29ca065
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Downloads items from the Chromium continuous archive."""
7 import os
8 import platform
9 import urllib
11 import util
13 CHROME_43_REVISION = '323865'
14 CHROME_44_REVISION = '330231'
15 CHROME_45_REVISION = '338390'
17 _SITE = 'http://commondatastorage.googleapis.com'
20 class Site(object):
21 CONTINUOUS = _SITE + '/chromium-browser-continuous'
22 CHROMIUM_SNAPSHOT = _SITE + '/chromium-browser-snapshots'
23 BLINK_SNAPSHOT = _SITE + '/chromium-webkit-snapshots'
26 def GetLatestRevision(site=Site.CONTINUOUS):
27 """Returns the latest revision (as a string) available for this platform.
29 Args:
30 site: the archive site to check against, default to the continuous one.
31 """
32 url = site + '/%s/LAST_CHANGE'
33 return urllib.urlopen(url % _GetDownloadPlatform()).read()
36 def DownloadChrome(revision, dest_dir, site=Site.CONTINUOUS):
37 """Downloads the packaged Chrome from the archive to the given directory.
39 Args:
40 revision: the revision of Chrome to download.
41 dest_dir: the directory to download Chrome to.
42 site: the archive site to download from, default to the continuous one.
44 Returns:
45 The path to the unzipped Chrome binary.
46 """
47 def GetZipName():
48 if util.IsWindows():
49 return 'chrome-win32'
50 elif util.IsMac():
51 return 'chrome-mac'
52 elif util.IsLinux():
53 return 'chrome-linux'
55 def GetChromePathFromPackage():
56 if util.IsWindows():
57 return 'chrome.exe'
58 elif util.IsMac():
59 return 'Chromium.app/Contents/MacOS/Chromium'
60 elif util.IsLinux():
61 return 'chrome-wrapper'
62 zip_path = os.path.join(dest_dir, 'chrome-%s.zip' % revision)
63 if not os.path.exists(zip_path):
64 url = site + '/%s/%s/%s.zip' % (_GetDownloadPlatform(), revision,
65 GetZipName())
66 print 'Downloading', url, '...'
67 urllib.urlretrieve(url, zip_path)
68 util.Unzip(zip_path, dest_dir)
69 return os.path.join(dest_dir, GetZipName(), GetChromePathFromPackage())
72 def _GetDownloadPlatform():
73 """Returns the name for this platform on the archive site."""
74 if util.IsWindows():
75 return 'Win'
76 elif util.IsMac():
77 return 'Mac'
78 elif util.IsLinux():
79 if platform.architecture()[0] == '64bit':
80 return 'Linux_x64'
81 else:
82 return 'Linux'
85 def GetLatestSnapshotVersion():
86 """Returns the latest revision of snapshot build."""
87 return GetLatestRevision(GetSnapshotDownloadSite())
90 def GetSnapshotDownloadSite():
91 """Returns the site to download snapshot build according to the platform."""
92 return Site.CHROMIUM_SNAPSHOT