OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Fetch prebuilt binaries to run PyAuto. | 6 """Fetch prebuilt binaries to run PyAuto. |
7 | 7 |
8 Sets up Chrome and PyAuto binaries using prebuilt binaries from the | 8 Sets up Chrome and PyAuto binaries using prebuilt binaries from the |
9 continuous build archives. Works on mac, win, linux (32 & 64 bit). | 9 continuous build archives. Works on mac, win, linux (32 & 64 bit). |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 pyauto_utils.GetCurrentPlatform()) | 47 pyauto_utils.GetCurrentPlatform()) |
48 self._options, self._args = parser.parse_args() | 48 self._options, self._args = parser.parse_args() |
49 if not self._options.outdir: | 49 if not self._options.outdir: |
50 print >>sys.stderr, 'Need output directory: -d/--outdir' | 50 print >>sys.stderr, 'Need output directory: -d/--outdir' |
51 sys.exit(1) | 51 sys.exit(1) |
52 if not self._args: | 52 if not self._args: |
53 print >>sys.stderr, 'Need download url' | 53 print >>sys.stderr, 'Need download url' |
54 sys.exit(2) | 54 sys.exit(2) |
55 self._outdir = self._options.outdir | 55 self._outdir = self._options.outdir |
56 self._url = self._args[0] | 56 self._url = self._args[0] |
| 57 # Chromium continuous build archive has a non-standard format. |
| 58 if 'index.html?path=' in self._url: |
| 59 self._url = self._url.replace('index.html?path=', '') |
| 60 self._url = self._url.rstrip('/') |
57 | 61 |
58 # Determine name of zip. | 62 # Determine name of zip. |
59 if not self._options.platform.startswith('linux'): | 63 if not self._options.platform.startswith('linux'): |
60 self._chrome_zip_name = 'chrome-%s' % { 'mac': 'mac', | 64 self._chrome_zip_name = 'chrome-%s' % { 'mac': 'mac', |
61 'win': 'win32' | 65 'win': 'win32' |
62 }[self._options.platform] | 66 }[self._options.platform] |
63 else: | 67 else: |
64 linux_32_names = ['linux', 'lucid32bit'] | 68 linux_32_names = ['linux', 'lucid32bit'] |
65 linux_64_names = ['linux64', 'lucid64bit'] | 69 linux_64_names = ['linux64', 'lucid64bit'] |
66 linux_names = { 'linux': linux_32_names + linux_64_names, | 70 linux_names = { 'linux': linux_32_names + linux_64_names, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 """Remove old binaries, if any.""" | 107 """Remove old binaries, if any.""" |
104 pass | 108 pass |
105 | 109 |
106 def Run(self): | 110 def Run(self): |
107 self._ParseArgs() | 111 self._ParseArgs() |
108 if not os.path.isdir(self._outdir): | 112 if not os.path.isdir(self._outdir): |
109 os.makedirs(self._outdir) | 113 os.makedirs(self._outdir) |
110 get_it2me = self._DoesURLExist(self._it2me_zip_url) | 114 get_it2me = self._DoesURLExist(self._it2me_zip_url) |
111 | 115 |
112 # Fetch chrome & pyauto binaries | 116 # Fetch chrome & pyauto binaries |
113 print 'Fetching' | 117 print 'Fetching', self._chrome_zip_url |
114 print self._chrome_zip_url | 118 chrome_zip = urllib.urlretrieve(self._chrome_zip_url)[0] |
| 119 |
115 if get_it2me: | 120 if get_it2me: |
116 print self._it2me_zip_url | 121 print 'Fetching', self._it2me_zip_url |
| 122 it2me_zip = urllib.urlretrieve(self._it2me_zip_url)[0] |
117 else: | 123 else: |
118 print 'Warning: %s does not exist.' % self._it2me_zip_url | 124 print 'Warning: %s does not exist.' % self._it2me_zip_url |
119 print self._pyautolib_py_url | 125 |
120 print self._pyautolib_so_url | 126 print 'Fetching', self._pyautolib_py_url |
121 print self._chromedriver_url | |
122 chrome_zip = urllib.urlretrieve(self._chrome_zip_url)[0] | |
123 if get_it2me: | |
124 it2me_zip = urllib.urlretrieve(self._it2me_zip_url)[0] | |
125 pyautolib_py = urllib.urlretrieve(self._pyautolib_py_url)[0] | 127 pyautolib_py = urllib.urlretrieve(self._pyautolib_py_url)[0] |
| 128 |
| 129 print 'Fetching', self._pyautolib_so_url |
126 pyautolib_so = urllib.urlretrieve(self._pyautolib_so_url)[0] | 130 pyautolib_so = urllib.urlretrieve(self._pyautolib_so_url)[0] |
| 131 |
| 132 print 'Fetching', self._chromedriver_url |
127 chromedriver = urllib.urlretrieve(self._chromedriver_url)[0] | 133 chromedriver = urllib.urlretrieve(self._chromedriver_url)[0] |
| 134 |
128 chrome_unzip_dir = os.path.join(self._outdir, self._chrome_zip_name) | 135 chrome_unzip_dir = os.path.join(self._outdir, self._chrome_zip_name) |
129 if os.path.exists(chrome_unzip_dir): | 136 if os.path.exists(chrome_unzip_dir): |
130 print 'Cleaning', chrome_unzip_dir | 137 print 'Cleaning', chrome_unzip_dir |
131 pyauto_utils.RemovePath(chrome_unzip_dir) | 138 pyauto_utils.RemovePath(chrome_unzip_dir) |
| 139 print 'Unzipping' |
132 pyauto_utils.UnzipFilenameToDir(chrome_zip, self._outdir) | 140 pyauto_utils.UnzipFilenameToDir(chrome_zip, self._outdir) |
133 if get_it2me: | 141 if get_it2me: |
134 pyauto_utils.UnzipFilenameToDir(it2me_zip, self._outdir) | 142 pyauto_utils.UnzipFilenameToDir(it2me_zip, self._outdir) |
135 shutil.move(self._outdir + '/remoting-it2me', | 143 shutil.move(self._outdir + '/remoting-it2me', |
136 self._outdir + '/remoting/it2me.webapp') | 144 self._outdir + '/remoting/it2me.webapp') |
137 | 145 |
138 # Copy over the binaries to outdir | 146 # Copy over the binaries to outdir |
139 items_to_copy = { | 147 items_to_copy = { |
140 pyautolib_py: os.path.join(self._outdir, 'pyautolib.py'), | 148 pyautolib_py: os.path.join(self._outdir, 'pyautolib.py'), |
141 pyautolib_so: os.path.join(self._outdir, self._pyautolib_so_name), | 149 pyautolib_so: os.path.join(self._outdir, self._pyautolib_so_name), |
(...skipping 27 matching lines...) Expand all Loading... |
169 os.path.lexists(dest) and os.remove(dest) | 177 os.path.lexists(dest) and os.remove(dest) |
170 print 'Creating symlink "%s"' % dest | 178 print 'Creating symlink "%s"' % dest |
171 os.symlink(framework, dest) | 179 os.symlink(framework, dest) |
172 | 180 |
173 print 'Prepared binaries in "%s"' % self._outdir | 181 print 'Prepared binaries in "%s"' % self._outdir |
174 return 0 | 182 return 0 |
175 | 183 |
176 | 184 |
177 if __name__ == '__main__': | 185 if __name__ == '__main__': |
178 sys.exit(FetchPrebuilt().Run()) | 186 sys.exit(FetchPrebuilt().Run()) |
OLD | NEW |