OLD | NEW |
| (Empty) |
1 # Copyright (c) 2012 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. | |
4 | |
5 """Downloads items from the Chromium continuous archive.""" | |
6 | |
7 import os | |
8 import stat | |
9 import urllib | |
10 | |
11 import util | |
12 | |
13 | |
14 _SITE = 'http://commondatastorage.googleapis.com/chromium-browser-continuous' | |
15 | |
16 | |
17 def GetLatestRevision(): | |
18 """Returns the latest revision (as a string) available for this platform.""" | |
19 url = _SITE + '/%s/LAST_CHANGE' | |
20 return urllib.urlopen(url % _GetDownloadPlatform()).read() | |
21 | |
22 | |
23 def DownloadChromeDriver(revision, dest_dir): | |
24 """Downloads ChromeDriver from the archive to the given directory. | |
25 | |
26 Args: | |
27 revision: the revision of ChromeDriver to download. | |
28 dest_dir: the directory to download ChromeDriver to. | |
29 | |
30 Returns: | |
31 The path to the downloaded ChromeDriver binary. | |
32 """ | |
33 def GetChromedriverPath(): | |
34 if util.IsWin(): | |
35 return 'chrome-win32.test/chromedriver.exe' | |
36 elif util.IsMac(): | |
37 return 'chrome-mac.test/chromedriver' | |
38 elif util.IsLinux(): | |
39 return 'chrome-linux.test/chromedriver' | |
40 url = _SITE + '/%s/%s/%s' % (_GetDownloadPlatform(), revision, | |
41 GetChromedriverPath()) | |
42 print 'Downloading', url, '...' | |
43 path = os.path.join(dest_dir, 'chromedriver') | |
44 if util.IsWin(): | |
45 path = path + '.exe' | |
46 urllib.urlretrieve(url, path) | |
47 # Make executable by owner. | |
48 os.chmod(path, stat.S_IEXEC) | |
49 return path | |
50 | |
51 | |
52 def DownloadChrome(revision, dest_dir): | |
53 """Downloads the packaged Chrome from the archive to the given directory. | |
54 | |
55 Args: | |
56 revision: the revision of Chrome to download. | |
57 dest_dir: the directory to download Chrome to. | |
58 | |
59 Returns: | |
60 The path to the unzipped Chrome binary. | |
61 """ | |
62 def GetZipName(): | |
63 if util.IsWin(): | |
64 return 'chrome-win32' | |
65 elif util.IsMac(): | |
66 return 'chrome-mac' | |
67 elif util.IsLinux(): | |
68 return 'chrome-linux' | |
69 def GetChromePathFromPackage(): | |
70 if util.IsWin(): | |
71 return 'chrome.exe' | |
72 elif util.IsMac(): | |
73 return 'Chromium.app/Contents/MacOS/Chromium' | |
74 elif util.IsLinux(): | |
75 return 'chrome' | |
76 zip_path = os.path.join(dest_dir, 'chrome-%s.zip' % revision) | |
77 if not os.path.exists(zip_path): | |
78 url = _SITE + '/%s/%s/%s.zip' % (_GetDownloadPlatform(), revision, | |
79 GetZipName()) | |
80 print 'Downloading', url, '...' | |
81 urllib.urlretrieve(url, zip_path) | |
82 util.Unzip(zip_path, dest_dir) | |
83 return os.path.join(dest_dir, GetZipName(), GetChromePathFromPackage()) | |
84 | |
85 | |
86 def _GetDownloadPlatform(): | |
87 """Returns the name for this platform on the archive site.""" | |
88 if util.IsWin(): | |
89 return 'Win' | |
90 elif util.IsMac(): | |
91 return 'Mac' | |
92 elif util.IsLinux(): | |
93 return 'Linux_x64' | |
OLD | NEW |