Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: pyautolib/fetch_prebuilt_pyauto.py

Issue 10384104: Chrome updater test framework (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « install_test/sample_updater.py ('k') | pyautolib/pyauto_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 }[self._options.platform] 73 }[self._options.platform]
74 else: 74 else:
75 linux_32_names = ['linux', 'lucid32bit'] 75 linux_32_names = ['linux', 'lucid32bit']
76 linux_64_names = ['linux64', 'lucid64bit'] 76 linux_64_names = ['linux64', 'lucid64bit']
77 linux_names = {'linux': linux_32_names + linux_64_names, 77 linux_names = {'linux': linux_32_names + linux_64_names,
78 'linux32': linux_32_names, 78 'linux32': linux_32_names,
79 'linux64': linux_64_names 79 'linux64': linux_64_names
80 }[self._options.platform] 80 }[self._options.platform]
81 for name in linux_names: 81 for name in linux_names:
82 zip_name = 'chrome-' + name 82 zip_name = 'chrome-' + name
83 if self._DoesURLExist('%s/%s.zip' % (self._url, zip_name)): 83 if pyauto_utils.DoesUrlExist('%s/%s.zip' % (self._url, zip_name)):
84 self._chrome_zip_name = zip_name 84 self._chrome_zip_name = zip_name
85 break 85 break
86 else: 86 else:
87 raise RuntimeError('Could not find chrome zip at ' + self._url) 87 raise RuntimeError('Could not find chrome zip at ' + self._url)
88 88
89 # Setup urls to download. 89 # Setup urls to download.
90 self._chrome_zip_url = '%s/%s.zip' % (self._url, self._chrome_zip_name) 90 self._chrome_zip_url = '%s/%s.zip' % (self._url, self._chrome_zip_name)
91 self._remoting_zip_url = self._url + '/' + 'remoting-webapp.zip' 91 self._remoting_zip_url = self._url + '/' + 'remoting-webapp.zip'
92 chrome_test_url = '%s/%s.test' % (self._url, self._chrome_zip_name) 92 chrome_test_url = '%s/%s.test' % (self._url, self._chrome_zip_name)
93 self._pyautolib_py_url = '%s/pyautolib.py' % chrome_test_url 93 self._pyautolib_py_url = '%s/pyautolib.py' % chrome_test_url
(...skipping 22 matching lines...) Expand all
116 response = urllib2.urlopen(last_change_url) 116 response = urllib2.urlopen(last_change_url)
117 last_change = response.read() 117 last_change = response.read()
118 if not last_change: 118 if not last_change:
119 print >>sys.stderr, ('Unable to get latest from %s' % last_change_url) 119 print >>sys.stderr, ('Unable to get latest from %s' % last_change_url)
120 sys.exit(2) 120 sys.exit(2)
121 last_change_url = ('http://commondatastorage.googleapis.com/' 121 last_change_url = ('http://commondatastorage.googleapis.com/'
122 'chromium-browser-continuous/%s/%s' % (os_type, 122 'chromium-browser-continuous/%s/%s' % (os_type,
123 last_change)) 123 last_change))
124 return last_change_url 124 return last_change_url
125 125
126 def _DoesURLExist(self, url):
127 """Determines whether a resource exists at the given URL."""
128 parsed = urlparse.urlparse(url)
129 conn = httplib.HTTPConnection(parsed.netloc)
130 conn.request('HEAD', parsed.path)
131 response = conn.getresponse()
132 if response.status == 302: # Redirect; follow it.
133 return self._DoesURLExist(response.getheader('location'))
134 return response.status == 200
135
136 def Cleanup(self): 126 def Cleanup(self):
137 """Remove old binaries, if any.""" 127 """Remove old binaries, if any."""
138 pass 128 pass
139 129
140 def Run(self): 130 def Run(self):
141 self._ParseArgs() 131 self._ParseArgs()
142 if not os.path.isdir(self._outdir): 132 if not os.path.isdir(self._outdir):
143 os.makedirs(self._outdir) 133 os.makedirs(self._outdir)
144 get_remoting = self._DoesURLExist(self._remoting_zip_url) 134 get_remoting = pyauto_utils.DoesUrlExist(self._remoting_zip_url)
145 135
146 # Fetch chrome & pyauto binaries 136 # Fetch chrome & pyauto binaries
147 print 'Fetching', self._chrome_zip_url 137 print 'Fetching', self._chrome_zip_url
148 chrome_zip = urllib.urlretrieve(self._chrome_zip_url)[0] 138 chrome_zip = urllib.urlretrieve(self._chrome_zip_url)[0]
149 139
150 if get_remoting: 140 if get_remoting:
151 print 'Fetching', self._remoting_zip_url 141 print 'Fetching', self._remoting_zip_url
152 remoting_zip = urllib.urlretrieve(self._remoting_zip_url)[0] 142 remoting_zip = urllib.urlretrieve(self._remoting_zip_url)[0]
153 else: 143 else:
154 print 'Warning: %s does not exist.' % self._remoting_zip_url 144 print 'Warning: %s does not exist.' % self._remoting_zip_url
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 os.path.lexists(dest) and os.remove(dest) 205 os.path.lexists(dest) and os.remove(dest)
216 print 'Creating symlink "%s"' % dest 206 print 'Creating symlink "%s"' % dest
217 os.symlink(framework, dest) 207 os.symlink(framework, dest)
218 208
219 print 'Prepared binaries in "%s"' % self._outdir 209 print 'Prepared binaries in "%s"' % self._outdir
220 return 0 210 return 0
221 211
222 212
223 if __name__ == '__main__': 213 if __name__ == '__main__':
224 sys.exit(FetchPrebuilt().Run()) 214 sys.exit(FetchPrebuilt().Run())
OLDNEW
« no previous file with comments | « install_test/sample_updater.py ('k') | pyautolib/pyauto_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698