| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 # | 6 # |
| 7 | 7 |
| 8 # A script to kill hanging processs. The tool will return non-zero if any | 8 # A script to kill hanging processs. The tool will return non-zero if any |
| 9 # process was actually found. | 9 # process was actually found. |
| 10 # | 10 # |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 os_name = utils.GuessOS() | 21 os_name = utils.GuessOS() |
| 22 | 22 |
| 23 POSIX_INFO = 'ps -p %s -o args' | 23 POSIX_INFO = 'ps -p %s -o args' |
| 24 | 24 |
| 25 EXECUTABLE_NAMES = { | 25 EXECUTABLE_NAMES = { |
| 26 'win32': { | 26 'win32': { |
| 27 'chrome': 'chrome.exe', | 27 'chrome': 'chrome.exe', |
| 28 'content_shell': 'content_shell.exe', | 28 'content_shell': 'content_shell.exe', |
| 29 'dart': 'dart.exe', | 29 'dart': 'dart.exe', |
| 30 'iexplore': 'iexplore.exe', | 30 'iexplore': 'iexplore.exe', |
| 31 'firefox': 'firefox.exe' | 31 'firefox': 'firefox.exe', |
| 32 'git': 'git.exe', |
| 33 'svn': 'svn.exe' |
| 32 }, | 34 }, |
| 33 'linux': { | 35 'linux': { |
| 34 'chrome': 'chrome', | 36 'chrome': 'chrome', |
| 35 'content_shell': 'content_shell', | 37 'content_shell': 'content_shell', |
| 36 'dart': 'dart', | 38 'dart': 'dart', |
| 37 'firefox': 'firefox.exe' | 39 'firefox': 'firefox.exe', |
| 40 'git': 'git', |
| 41 'svn': 'svn' |
| 38 }, | 42 }, |
| 39 'macos': { | 43 'macos': { |
| 40 'chrome': 'Chrome', | 44 'chrome': 'Chrome', |
| 41 'content_shell': 'Content Shell', | 45 'content_shell': 'Content Shell', |
| 42 'dart': 'dart', | 46 'dart': 'dart', |
| 43 'firefox': 'firefox', | 47 'firefox': 'firefox', |
| 44 'safari': 'Safari' | 48 'safari': 'Safari', |
| 49 'git': 'git', |
| 50 'svn': 'svn' |
| 45 } | 51 } |
| 46 } | 52 } |
| 47 | 53 |
| 48 INFO_COMMAND = { | 54 INFO_COMMAND = { |
| 49 'win32': 'wmic process where Processid=%s get CommandLine', | 55 'win32': 'wmic process where Processid=%s get CommandLine', |
| 50 'macos': POSIX_INFO, | 56 'macos': POSIX_INFO, |
| 51 'linux': POSIX_INFO, | 57 'linux': POSIX_INFO, |
| 52 } | 58 } |
| 53 | 59 |
| 54 def GetOptions(): | 60 def GetOptions(): |
| 55 parser = optparse.OptionParser("usage: %prog [options]") | 61 parser = optparse.OptionParser("usage: %prog [options]") |
| 56 parser.add_option("--kill_dart", default=True, | 62 parser.add_option("--kill_dart", default=True, |
| 57 help="Kill all dart processes") | 63 help="Kill all dart processes") |
| 64 parser.add_option("--kill_vc", default=True, |
| 65 help="Kill all git and svn processes") |
| 58 parser.add_option("--kill_browsers", default=False, | 66 parser.add_option("--kill_browsers", default=False, |
| 59 help="Kill all browser processes") | 67 help="Kill all browser processes") |
| 60 (options, args) = parser.parse_args() | 68 (options, args) = parser.parse_args() |
| 61 return options | 69 return options |
| 62 | 70 |
| 63 | 71 |
| 64 def GetPidsPosix(process_name): | 72 def GetPidsPosix(process_name): |
| 65 # This is to have only one posix command, on linux we could just do: | 73 # This is to have only one posix command, on linux we could just do: |
| 66 # pidof process_name | 74 # pidof process_name |
| 67 cmd = 'ps -e -o pid= -o comm=' | 75 cmd = 'ps -e -o pid= -o comm=' |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 return len(pids) | 171 return len(pids) |
| 164 | 172 |
| 165 def KillBrowsers(): | 173 def KillBrowsers(): |
| 166 status = Kill('firefox') | 174 status = Kill('firefox') |
| 167 status += Kill('chrome') | 175 status += Kill('chrome') |
| 168 status += Kill('iexplore') | 176 status += Kill('iexplore') |
| 169 status += Kill('safari') | 177 status += Kill('safari') |
| 170 status += Kill('content_shell') | 178 status += Kill('content_shell') |
| 171 return status | 179 return status |
| 172 | 180 |
| 181 def KillVCSystems(): |
| 182 status = Kill('git') |
| 183 status += Kill('svn') |
| 184 return status |
| 185 |
| 173 def KillDart(): | 186 def KillDart(): |
| 174 status = Kill("dart") | 187 status = Kill("dart") |
| 175 return status | 188 return status |
| 176 | 189 |
| 177 def Main(): | 190 def Main(): |
| 178 options = GetOptions() | 191 options = GetOptions() |
| 179 status = 0 | 192 status = 0 |
| 180 if (options.kill_dart): | 193 if (options.kill_dart): |
| 181 status += KillDart(); | 194 status += KillDart(); |
| 195 if (options.kill_vc): |
| 196 status += KillVCSystems(); |
| 182 if (options.kill_browsers): | 197 if (options.kill_browsers): |
| 183 status += KillBrowsers() | 198 status += KillBrowsers() |
| 184 return status | 199 return status |
| 185 | 200 |
| 186 if __name__ == '__main__': | 201 if __name__ == '__main__': |
| 187 sys.exit(Main()) | 202 sys.exit(Main()) |
| OLD | NEW |