OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """Runs all the buildbot steps for ChromeDriver except for update/compile.""" |
| 7 |
| 8 import optparse |
| 9 import os |
| 10 import sys |
| 11 import urllib2 |
| 12 import zipfile |
| 13 |
| 14 _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) |
| 15 sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, 'pylib')) |
| 16 |
| 17 from common import chrome_paths |
| 18 from common import util |
| 19 |
| 20 |
| 21 def MaybeRelease(revision): |
| 22 # Version is embedded as: const char kChromeDriverVersion[] = "0.1"; |
| 23 with open(os.path.join(_THIS_DIR, 'version.cc'), 'r') as f: |
| 24 version_line = filter(lambda x: 'kChromeDriverVersion' in x, f.readlines()) |
| 25 version = version_line[0].split('"')[1] |
| 26 |
| 27 # This assumes the bitness of python is the same as the built ChromeDriver. |
| 28 bitness = '32' |
| 29 if sys.maxint > 2**32: |
| 30 bitness = '64' |
| 31 zip_name = 'experimental_chromedriver2_%s%s_%s.zip' % ( |
| 32 util.GetPlatformName(), bitness, version) |
| 33 |
| 34 site = 'https://code.google.com/p/chromedriver/downloads/list' |
| 35 s = urllib2.urlopen(site) |
| 36 downloads = s.read() |
| 37 s.close() |
| 38 |
| 39 if zip_name in downloads: |
| 40 return 0 |
| 41 |
| 42 print '@@@BUILD_STEP releasing %s@@@' % zip_name |
| 43 if util.IsWindows(): |
| 44 server_orig_name = 'chromedriver2_server.exe' |
| 45 server_name = 'chromedriver.exe' |
| 46 else: |
| 47 server_orig_name = 'chromedriver2_server' |
| 48 server_name = 'chromedriver' |
| 49 server = os.path.join(chrome_paths.GetBuildDir([server_orig_name]), |
| 50 server_orig_name) |
| 51 |
| 52 print 'Zipping ChromeDriver server', server |
| 53 temp_dir = util.MakeTempDir() |
| 54 zip_path = os.path.join(temp_dir, zip_name) |
| 55 f = zipfile.ZipFile(zip_path, 'w') |
| 56 f.write(server, server_name) |
| 57 f.close() |
| 58 |
| 59 cmd = [ |
| 60 sys.executable, |
| 61 os.path.join(_THIS_DIR, 'third_party', 'googlecode', |
| 62 'googlecode_upload.py'), |
| 63 '--summary', 'alpha version of ChromeDriver2 r%s' % revision, |
| 64 '--project', 'chromedriver', |
| 65 '--user', 'chromedriver.bot@gmail.com', |
| 66 '--label', 'Release-Alpha', |
| 67 zip_path |
| 68 ] |
| 69 code = util.RunCommand(cmd) |
| 70 if code != 0: |
| 71 print '@@@STEP_FAILURE@@@' |
| 72 return code |
| 73 |
| 74 |
| 75 def main(): |
| 76 parser = optparse.OptionParser() |
| 77 parser.add_option( |
| 78 '-r', '--revision', type='string', default=None, |
| 79 help='Chromium revision') |
| 80 options, _ = parser.parse_args() |
| 81 if options.revision is None: |
| 82 parser.error('Must supply a --revision') |
| 83 |
| 84 cmd = [ |
| 85 sys.executable, |
| 86 os.path.join(_THIS_DIR, 'run_all_tests.py'), |
| 87 ] |
| 88 code = 0 #util.RunCommand(cmd) |
| 89 if code != 0: |
| 90 return code |
| 91 |
| 92 return MaybeRelease(options.revision) |
| 93 |
| 94 |
| 95 if __name__ == '__main__': |
| 96 sys.exit(main()) |
OLD | NEW |