| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Common utilities for all buildbot scripts that specifically don't rely | 5 """Common utilities for all buildbot scripts that specifically don't rely |
| 6 on having a full chromium checkout. | 6 on having a full chromium checkout. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import subprocess | 10 import subprocess |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 def BuildStep(name): | 43 def BuildStep(name): |
| 44 """Annotate a buildbot build step.""" | 44 """Annotate a buildbot build step.""" |
| 45 sys.stdout.flush() | 45 sys.stdout.flush() |
| 46 print '\n@@@BUILD_STEP %s@@@' % name | 46 print '\n@@@BUILD_STEP %s@@@' % name |
| 47 sys.stdout.flush() | 47 sys.stdout.flush() |
| 48 | 48 |
| 49 | 49 |
| 50 def Run(args, cwd=None, env=None, shell=False): | 50 def Run(args, cwd=None, env=None, shell=False): |
| 51 """Start a process with the provided arguments. | 51 """Start a process with the provided arguments. |
| 52 | 52 |
| 53 Starts a process in the provided directory given the provided arguments. If | 53 Starts a process in the provided directory given the provided arguments. If |
| 54 shell is not False, the process is launched via the shell to provide shell | 54 shell is not False, the process is launched via the shell to provide shell |
| 55 interpretation of the arguments. Shell behavior can differ between platforms | 55 interpretation of the arguments. Shell behavior can differ between platforms |
| 56 so this should be avoided when not using platform dependent shell scripts.""" | 56 so this should be avoided when not using platform dependent shell scripts.""" |
| 57 print 'Running: ' + ' '.join(args) | 57 print 'Running: ' + ' '.join(args) |
| 58 sys.stdout.flush() | 58 sys.stdout.flush() |
| 59 sys.stderr.flush() | 59 sys.stderr.flush() |
| 60 subprocess.check_call(args, cwd=cwd, env=env, shell=shell) | 60 subprocess.check_call(args, cwd=cwd, env=env, shell=shell) |
| 61 sys.stdout.flush() | 61 sys.stdout.flush() |
| 62 sys.stderr.flush() | 62 sys.stderr.flush() |
| 63 | 63 |
| 64 | 64 |
| 65 def CopyDir(src, dst, excludes=('.svn', '*/.svn')): | 65 def CopyDir(src, dst, excludes=('.svn', '*/.svn')): |
| 66 """Recursively copy a directory using.""" | 66 """Recursively copy a directory using.""" |
| 67 args = ['-r', src, dst] | 67 args = ['-r', src, dst] |
| 68 for exc in excludes: | 68 for exc in excludes: |
| 69 args.append('--exclude=' + exc) | 69 args.append('--exclude=' + exc) |
| 70 print 'cp -r %s %s' % (src, dst) | 70 print 'cp -r %s %s' % (src, dst) |
| 71 if os.path.abspath(src) == os.path.abspath(dst): | 71 if os.path.abspath(src) == os.path.abspath(dst): |
| 72 ErrorExit('ERROR: Copying directory onto itself: ' + src) | 72 ErrorExit('ERROR: Copying directory onto itself: ' + src) |
| 73 oshelpers.Copy(args) | 73 oshelpers.Copy(args) |
| 74 | 74 |
| 75 | 75 |
| 76 def CopyFile(src, dst): | 76 def CopyFile(src, dst): |
| 77 print 'cp -r %s %s' % (src, dst) | 77 print 'cp %s %s' % (src, dst) |
| 78 if os.path.abspath(src) == os.path.abspath(dst): | 78 if os.path.abspath(src) == os.path.abspath(dst): |
| 79 ErrorExit('ERROR: Copying file onto itself: ' + src) | 79 ErrorExit('ERROR: Copying file onto itself: ' + src) |
| 80 args = [src, dst] | 80 args = [src, dst] |
| 81 oshelpers.Copy(args) | 81 oshelpers.Copy(args) |
| 82 | 82 |
| 83 | 83 |
| 84 def RemoveDir(dst): | 84 def RemoveDir(dst): |
| 85 """Remove the provided path.""" | 85 """Remove the provided path.""" |
| 86 print 'rm -fr ' + dst | 86 print 'rm -fr ' + dst |
| 87 oshelpers.Remove(['-fr', dst]) | 87 oshelpers.Remove(['-fr', dst]) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 subprocess.check_call( | 123 subprocess.check_call( |
| 124 '%s cp -a public-read %s %s' % (GetGsutil(), filename, full_dst), | 124 '%s cp -a public-read %s %s' % (GetGsutil(), filename, full_dst), |
| 125 shell=True, | 125 shell=True, |
| 126 cwd=cwd) | 126 cwd=cwd) |
| 127 url = 'https://commondatastorage.googleapis.com/'\ | 127 url = 'https://commondatastorage.googleapis.com/'\ |
| 128 '%s/%s' % (bucket_path, filename) | 128 '%s/%s' % (bucket_path, filename) |
| 129 if step_link: | 129 if step_link: |
| 130 print '@@@STEP_LINK@download@%s@@@' % url | 130 print '@@@STEP_LINK@download@%s@@@' % url |
| 131 sys.stdout.flush() | 131 sys.stdout.flush() |
| OLD | NEW |