Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: tools/task_kill.py

Issue 306383002: Always kill the editor and eggplant if on linux (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #
11 11
12 import optparse 12 import optparse
13 import os 13 import os
14 import signal 14 import signal
15 import shutil 15 import shutil
16 import string 16 import string
17 import subprocess 17 import subprocess
18 import sys 18 import sys
19 import utils 19 import utils
20 20
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 'editor': 'DartEditor.exe',
30 'iexplore': 'iexplore.exe', 31 'iexplore': 'iexplore.exe',
31 'firefox': 'firefox.exe', 32 'firefox': 'firefox.exe',
32 'git': 'git.exe', 33 'git': 'git.exe',
33 'svn': 'svn.exe' 34 'svn': 'svn.exe'
34 }, 35 },
35 'linux': { 36 'linux': {
36 'chrome': 'chrome', 37 'chrome': 'chrome',
37 'content_shell': 'content_shell', 38 'content_shell': 'content_shell',
38 'dart': 'dart', 39 'dart': 'dart',
40 'editor': 'DartEditor',
41 'eggplant': 'Eggplant',
39 'firefox': 'firefox.exe', 42 'firefox': 'firefox.exe',
40 'git': 'git', 43 'git': 'git',
41 'svn': 'svn' 44 'svn': 'svn'
42 }, 45 },
43 'macos': { 46 'macos': {
44 'chrome': 'Chrome', 47 'chrome': 'Chrome',
45 'content_shell': 'Content Shell', 48 'content_shell': 'Content Shell',
46 'dart': 'dart', 49 'dart': 'dart',
50 'editor': 'DartEditor',
47 'firefox': 'firefox', 51 'firefox': 'firefox',
48 'safari': 'Safari', 52 'safari': 'Safari',
49 'git': 'git', 53 'git': 'git',
50 'svn': 'svn' 54 'svn': 'svn'
51 } 55 }
52 } 56 }
53 57
54 INFO_COMMAND = { 58 INFO_COMMAND = {
55 'win32': 'wmic process where Processid=%s get CommandLine', 59 'win32': 'wmic process where Processid=%s get CommandLine',
56 'macos': POSIX_INFO, 60 'macos': POSIX_INFO,
57 'linux': POSIX_INFO, 61 'linux': POSIX_INFO,
58 } 62 }
59 63
60 def GetOptions(): 64 def GetOptions():
61 parser = optparse.OptionParser("usage: %prog [options]") 65 parser = optparse.OptionParser("usage: %prog [options]")
62 parser.add_option("--kill_dart", default=True, 66 parser.add_option("--kill_dart", default=True,
63 help="Kill all dart processes") 67 help="Kill all dart processes")
64 parser.add_option("--kill_vc", default=True, 68 parser.add_option("--kill_vc", default=True,
65 help="Kill all git and svn processes") 69 help="Kill all git and svn processes")
66 parser.add_option("--kill_browsers", default=False, 70 parser.add_option("--kill_browsers", default=False,
67 help="Kill all browser processes") 71 help="Kill all browser processes")
72 parser.add_option("--kill_editor", default=True,
73 help="Kill all editor processes")
68 (options, args) = parser.parse_args() 74 (options, args) = parser.parse_args()
69 return options 75 return options
70 76
71 77
72 def GetPidsPosix(process_name): 78 def GetPidsPosix(process_name):
73 # This is to have only one posix command, on linux we could just do: 79 # This is to have only one posix command, on linux we could just do:
74 # pidof process_name 80 # pidof process_name
75 cmd = 'ps -e -o pid= -o comm=' 81 cmd = 'ps -e -o pid= -o comm='
76 # Sample output: 82 # Sample output:
77 # 1 /sbin/launchd 83 # 1 /sbin/launchd
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 186
181 def KillVCSystems(): 187 def KillVCSystems():
182 status = Kill('git') 188 status = Kill('git')
183 status += Kill('svn') 189 status += Kill('svn')
184 return status 190 return status
185 191
186 def KillDart(): 192 def KillDart():
187 status = Kill("dart") 193 status = Kill("dart")
188 return status 194 return status
189 195
196 def KillEditor():
197 status = Kill("editor")
198 if os_name == "linux":
199 status += Kill("eggplant")
200 return status
201
190 def Main(): 202 def Main():
191 options = GetOptions() 203 options = GetOptions()
192 status = 0 204 status = 0
193 if (options.kill_dart): 205 if (options.kill_dart):
194 status += KillDart(); 206 status += KillDart();
195 if (options.kill_vc): 207 if (options.kill_vc):
196 status += KillVCSystems(); 208 status += KillVCSystems();
197 if (options.kill_browsers): 209 if (options.kill_browsers):
198 status += KillBrowsers() 210 status += KillBrowsers()
211 if (options.kill_editor):
212 status += KillEditor()
199 return status 213 return status
200 214
201 if __name__ == '__main__': 215 if __name__ == '__main__':
202 sys.exit(Main()) 216 sys.exit(Main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698