Chromium Code Reviews| 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 """Functions to setup xvfb, which is used by the linux machines. | 5 """Functions to setup xvfb, which is used by the linux machines. |
| 6 """ | 6 """ |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import platform | 9 import platform |
| 10 import signal | 10 import signal |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 checkstarttime = time.time() | 53 checkstarttime = time.time() |
| 54 xdisplayproc = subprocess.Popen([xdisplaycheck_path, '--noserver'], | 54 xdisplayproc = subprocess.Popen([xdisplaycheck_path, '--noserver'], |
| 55 stdout=subprocess.PIPE, | 55 stdout=subprocess.PIPE, |
| 56 stderr=subprocess.STDOUT) | 56 stderr=subprocess.STDOUT) |
| 57 # Wait for xdisplaycheck to exit. | 57 # Wait for xdisplaycheck to exit. |
| 58 logs = xdisplayproc.communicate()[0] | 58 logs = xdisplayproc.communicate()[0] |
| 59 if xdisplayproc.returncode == 0: | 59 if xdisplayproc.returncode == 0: |
| 60 print 'xdisplaycheck says there is a display still running, exiting...' | 60 print 'xdisplaycheck says there is a display still running, exiting...' |
| 61 raise Exception('Display already present.') | 61 raise Exception('Display already present.') |
| 62 | 62 |
| 63 xvfb_lock_filename = '/tmp/.X%s-lock' % _XvfbDisplayIndex(slave_build_name) | |
| 64 if os.path.exists(xvfb_lock_filename): | |
| 65 print 'Removing stale xvfb lock file %r' % xvfb_lock_filename | |
| 66 try: | |
| 67 os.unlink(xvfb_lock_filename) | |
| 68 except OSError as e: | |
| 69 print 'Trying to remove xvfb lock file failed: %s' % e | |
|
Sergiy Byelozyorov
2016/07/15 09:38:13
nit: Removing xvfb lock file failed
IMHO "Trying t
Paweł Hajdan Jr.
2016/07/15 09:40:40
Done
| |
| 70 | |
| 63 # Figure out which X server to try. | 71 # Figure out which X server to try. |
| 64 cmd = 'Xvfb' | 72 cmd = 'Xvfb' |
| 65 if server_dir and os.path.exists(server_dir): | 73 if server_dir and os.path.exists(server_dir): |
| 66 cmd = os.path.join(server_dir, 'Xvfb.' + platform.architecture()[0]) | 74 cmd = os.path.join(server_dir, 'Xvfb.' + platform.architecture()[0]) |
| 67 if not os.path.exists(cmd): | 75 if not os.path.exists(cmd): |
| 68 cmd = os.path.join(server_dir, 'Xvfb') | 76 cmd = os.path.join(server_dir, 'Xvfb') |
| 69 if not os.path.exists(cmd): | 77 if not os.path.exists(cmd): |
| 70 print 'No Xvfb found in designated server path:', server_dir | 78 print 'No Xvfb found in designated server path:', server_dir |
| 71 raise Exception('No virtual server') | 79 raise Exception('No virtual server') |
| 72 | 80 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 if os.path.exists(xvfb_pid_filename): | 137 if os.path.exists(xvfb_pid_filename): |
| 130 xvfb_pid = int(open(xvfb_pid_filename).read()) | 138 xvfb_pid = int(open(xvfb_pid_filename).read()) |
| 131 print 'Stopping Xvfb with pid %d ...' % xvfb_pid | 139 print 'Stopping Xvfb with pid %d ...' % xvfb_pid |
| 132 # If the process doesn't exist, we raise an exception that we can ignore. | 140 # If the process doesn't exist, we raise an exception that we can ignore. |
| 133 try: | 141 try: |
| 134 os.kill(xvfb_pid, signal.SIGKILL) | 142 os.kill(xvfb_pid, signal.SIGKILL) |
| 135 except OSError: | 143 except OSError: |
| 136 print '... killing failed, presuming unnecessary.' | 144 print '... killing failed, presuming unnecessary.' |
| 137 os.remove(xvfb_pid_filename) | 145 os.remove(xvfb_pid_filename) |
| 138 print 'Xvfb pid file removed' | 146 print 'Xvfb pid file removed' |
| OLD | NEW |