add stop and restart key to cl-consoled

develop
Спиридонов Денис 12 years ago
parent 5ea7e10b6e
commit e078d723b4

@ -16,8 +16,11 @@
# limitations under the License.
import socket
import sys, pwd, os, argparse
import sys, pwd, os
import random, string, datetime
import subprocess
from calculate.console.application.cert_func import owner, getRunProc
reload(sys)
sys.setdefaultencoding("utf-8")
@ -25,6 +28,7 @@ from calculate.lib.cl_lang import setLocalTranslate
setLocalTranslate('calculate_console',sys.modules[__name__])
def parse():
import argparse
parser = argparse.ArgumentParser(add_help=False)
parser.add_argument('-h', '--help', action='store_true', default=False,
dest='help',help=_("show this help message and exit"))
@ -166,15 +170,23 @@ def start():
return 0
def stop():
pass
username = pwd.getpwuid(os.getuid()).pw_name
for run_commands in filter(lambda x:'cl-consoled' in \
x[0],getRunProc()):
if 'python' in run_commands[0]:
if username == owner(run_commands[1]) and \
str(os.getpid()) != run_commands[1]:
os.system('kill %s' %run_commands[1])
if __name__=='__main__':
parser = parse()
args = parser.parse_args()
if args.stop or args.restart:
stop()
while True:
res = start()
if res != 408:
sys.exit(res)
if not args.stop:
while True:
print 'start'
res = start()
if res != 408:
sys.exit(res)
Loading…
Cancel
Save