Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 """Generate fake repositories for testing.""" | 6 """Generate fake repositories for testing.""" |
| 7 | 7 |
| 8 import atexit | 8 import atexit |
| 9 import datetime | 9 import datetime |
| 10 import errno | 10 import errno |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 | 260 |
| 261 def tear_down_git(self): | 261 def tear_down_git(self): |
| 262 if self.gitdaemon: | 262 if self.gitdaemon: |
| 263 logging.debug('Killing git-daemon pid %s' % self.gitdaemon.pid) | 263 logging.debug('Killing git-daemon pid %s' % self.gitdaemon.pid) |
| 264 self.gitdaemon.kill() | 264 self.gitdaemon.kill() |
| 265 self.gitdaemon = None | 265 self.gitdaemon = None |
| 266 if self.git_pid_file: | 266 if self.git_pid_file: |
| 267 pid = int(self.git_pid_file.read()) | 267 pid = int(self.git_pid_file.read()) |
| 268 self.git_pid_file.close() | 268 self.git_pid_file.close() |
| 269 logging.debug('Killing git daemon pid %s' % pid) | 269 logging.debug('Killing git daemon pid %s' % pid) |
| 270 subprocess2.kill_pid(pid) | 270 try: |
| 271 subprocess2.kill_pid(pid) | |
| 272 except OSError, e: | |
|
M-A Ruel
2013/09/12 12:55:58
except OSError as e:
rmistry
2013/09/12 13:56:43
Done here and above.
| |
| 273 if e.errno != errno.ESRCH: # no such process | |
| 274 raise | |
| 271 self.git_pid_file = None | 275 self.git_pid_file = None |
| 272 wait_for_port_to_free(self.host, self.git_port) | 276 wait_for_port_to_free(self.host, self.git_port) |
| 273 self.git_port = None | 277 self.git_port = None |
| 274 self.git_base = None | 278 self.git_base = None |
| 275 if not self.trial.SHOULD_LEAK: | 279 if not self.trial.SHOULD_LEAK: |
| 276 logging.debug('Removing %s' % self.git_root) | 280 logging.debug('Removing %s' % self.git_root) |
| 277 gclient_utils.rmtree(self.git_root) | 281 gclient_utils.rmtree(self.git_root) |
| 278 else: | 282 else: |
| 279 return False | 283 return False |
| 280 return True | 284 return True |
| (...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 800 fake.set_up_git() | 804 fake.set_up_git() |
| 801 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.') | 805 print('Fake setup, press enter to quit or Ctrl-C to keep the checkouts.') |
| 802 sys.stdin.readline() | 806 sys.stdin.readline() |
| 803 except KeyboardInterrupt: | 807 except KeyboardInterrupt: |
| 804 trial_dir.TrialDir.SHOULD_LEAK.leak = True | 808 trial_dir.TrialDir.SHOULD_LEAK.leak = True |
| 805 return 0 | 809 return 0 |
| 806 | 810 |
| 807 | 811 |
| 808 if __name__ == '__main__': | 812 if __name__ == '__main__': |
| 809 sys.exit(main(sys.argv)) | 813 sys.exit(main(sys.argv)) |
| OLD | NEW |