def runCheck(initType, scrn):
if initType == "systemd":
try:
getStatus = subprocess.Popen(['systemctl', 'status', 'cgroup_py'], stdout=subprocess.PIPE)
except subprocess.CalledProcessError as e:
eMsg = "Unable to get status of cgroup_py daemon. Exiting!"
scrn.addstr(1,1,eMsg)
time.sleep(2)
sys.exit(2)
statlines = getStatus.communicate()[0].splitlines()
for l in statlines:
if "Active:" in l:
status = l.split(':')[1]
if 'active' in status and not 'inactive' in status:
pass
else:
eMsg = "Cgroup_py daemon does not appear to be active. Exiting."
scrn.erase()
scrn.addstr(1,1,eMsg)
scrn.refresh()
time.sleep(2)
sys.exit(2)
elif initType == "sysV":
try:
getStatus = subprocess.Popen(['/etc/init.d/cgroup_py', 'status'], stdout=subprocess.PIPE)
except subprocess.CalledProcessError as e:
eMsg = "Unable to get status of cgroup_py daemon. Exiting!"
scrn.addstr(1,1, eMsg)
time.sleep(2)
sys.exit(2)
if not "running" in getStatus.communicate()[0]:
eMsg = "Cgroup_py daemon doesn't appear to be running. Exiting."
scrn.addstr(1,1, eMsg, curses.A_NORMAL)
scrn.refresh()
time.sleep(2)
sys.exit(2)
else:
print "Cgroup_py daemon found."
评论列表
文章目录