-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__main__.py
More file actions
88 lines (71 loc) · 2.5 KB
/
__main__.py
File metadata and controls
88 lines (71 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# **************************************************************************** #
# #
# ::: :::::::: #
# __main__.py :+: :+: :+: #
# +:+ +:+ +:+ #
# By: skhatir <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2016/06/30 10:04:15 by skhatir #+# #+# #
# Updated: 2016/06/30 10:04:20 by skhatir ### ########.fr #
# #
# **************************************************************************** #
import signal
import cmd
import os
import subprocess
from task_lib import task
from task_lib import close_fd
from task_lib import log
def opening():
try:
fd = open("opening.master", "r")
print fd.read()
fd.close()
except:
print ("opening failed___\n\n")
log.info("TASK_MASTER LAUNCH:")
class keyboard(cmd.Cmd):
prompt = '\033[31m' + '\033[1m' + '(Deamon_Master): ' + '\033[39m' + '\033[0m'
def emptyline(self):
pass
def do_info(self, line):
task.info(line)
def do_status(self, line):
task.status(line)
def do_start(self, line):
task.start(line)
def do_stop(self, line):
if (line != ""):
task.stop(line)
else:
print("task: need name to stop")
def do_shell(self, line):
proc = subprocess.Popen(
line,
shell = True,
env = os.environ
)
proc.wait()
def do_restart(self, line):
task.restart(line)
def do_reload(self, line):
task.reload()
def do_only(self, line):
task.only(line)
def do_help(self, line):
print ("cmd: <info/status/start/stop/restart> [all/name] || <reload/quit> ")
def do_quit(self, line):
signal.alarm(0)
close_fd(task.cmd)
task.stop("all")
print ("see you soon on 'Deamon_Master' .\nclosing ...")
log.info("TASK_MASTER CLOSED!")
return True
def do_EOF(self, line):
self.do_quit(line)
return True
if __name__ == "__main__":
opening()
task.autostart()
task.status("")
keyboard().cmdloop()