Last active
August 29, 2015 14:05
-
-
Save harlo/def27e720cb88c346757 to your computer and use it in GitHub Desktop.
force quits some of my packages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from sys import argv, exit | |
from fabric.api import settings, local | |
if __name__ == '__main__': | |
try: | |
target = argv[1] | |
except Exception as e: | |
print e | |
print "usage: skillet.py [module name (i.e. compass_frontend)]" | |
exit(1) | |
if target not in ['compass_frontend', 'informa_frontend', 'unveillance_annex']: | |
print "usage: skillet.py [module name (i.e. compass_frontend)]" | |
exit(1) | |
with settings(warn_only=True): | |
whoami = local("whoami", capture=True) | |
kill_list = local("ps -ef | grep %s.py" % target, capture=True) | |
for k in kill_list.splitlines(): | |
if re.match(".*\d{2}:\d{2}:\d{2}\s/bin/sh", k) is not None: continue | |
if re.match(".*\d{2}:\d{2}:\d{2}\sgrep", k) is not None: continue | |
pid = re.findall(re.compile("\d{4}|%s\s+(\d{3,6})\s+.*" % whoami), k) | |
if len(pid) == 1: | |
try: | |
pid = int(pid[0]) | |
except Exception as e: | |
print "ERROR: %s" % e | |
continue | |
with settings(warn_only=True): local("kill -9 %d" % pid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment