| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2008 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 """Functions specific to build slaves, shared by several buildbot scripts. | 6 """Functions specific to build slaves, shared by several buildbot scripts. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import re | 10 import re |
| 11 import signal | 11 import signal |
| 12 import subprocess | 12 import subprocess |
| 13 import sys | 13 import sys |
| 14 import tempfile | 14 import tempfile |
| 15 import time | 15 import time |
| 16 | 16 |
| 17 | 17 |
| 18 import chromium_utils | 18 import chromium_utils |
| 19 | 19 |
| 20 | 20 |
| 21 # Local errors. | 21 # Local errors. |
| 22 class PageHeapError(Exception): pass | 22 class PageHeapError(Exception): pass |
| 23 | 23 |
| 24 | 24 |
| 25 # Cache the path to gflags.exe. | 25 # Cache the path to gflags.exe. |
| 26 _gflags_exe = None | 26 _gflags_exe = None |
| 27 | 27 |
| 28 def SubversionExe(): | 28 def SubversionExe(): |
| 29 # TODO(pamg): move this into platform_utils to support Mac and Linux. | 29 # TODO(pamg): move this into platform_utils to support Mac and Linux. |
| 30 return 'svn.bat' # Find it in the user's path. | 30 if sys.platform in ['cygwin', 'win32']: |
| 31 return 'svn.bat' # Find it in the user's path. |
| 32 elif sys.platform in ['linux', 'linux2', 'darwin']: |
| 33 return 'svn' # Find it in the user's path. |
| 31 | 34 |
| 32 | 35 |
| 33 def SubversionRevision(wc_dir): | 36 def SubversionRevision(wc_dir): |
| 34 """Finds the last svn revision of a working copy dir by running 'svn info', | 37 """Finds the last svn revision of a working copy dir by running 'svn info', |
| 35 and returns it as an integer. | 38 and returns it as an integer. |
| 36 """ | 39 """ |
| 37 svn_regexp = re.compile(r'.*Revision: (\d+).*', re.DOTALL) | 40 svn_regexp = re.compile(r'.*Revision: (\d+).*', re.DOTALL) |
| 38 svn_info = chromium_utils.GetCommandOutput([SubversionExe(), 'info', wc_dir]) | 41 svn_info = chromium_utils.GetCommandOutput([SubversionExe(), 'info', wc_dir]) |
| 39 return int(re.sub(svn_regexp, r'\1', svn_info)) | 42 return int(re.sub(svn_regexp, r'\1', svn_info)) |
| 40 | 43 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 """Try and stop the virtual X server if one was started with StartVirtualX. | 163 """Try and stop the virtual X server if one was started with StartVirtualX. |
| 161 If a virtual x server is not running, this method does nothing.""" | 164 If a virtual x server is not running, this method does nothing.""" |
| 162 xvfb_pid_filename = _XvfbPidFilename(slave_build_name) | 165 xvfb_pid_filename = _XvfbPidFilename(slave_build_name) |
| 163 if os.path.exists(xvfb_pid_filename): | 166 if os.path.exists(xvfb_pid_filename): |
| 164 try: | 167 try: |
| 165 # If the process doesn't exist, we raise an exception that we can ignore. | 168 # If the process doesn't exist, we raise an exception that we can ignore. |
| 166 os.kill(open(xvfb_pid_filename).read(), signal.SIGKILL) | 169 os.kill(open(xvfb_pid_filename).read(), signal.SIGKILL) |
| 167 except: | 170 except: |
| 168 pass | 171 pass |
| 169 os.remove(xvfb_pid_filename) | 172 os.remove(xvfb_pid_filename) |
| OLD | NEW |