forked from CNSRE/Plog
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplog.py
38 lines (30 loc) · 1.28 KB
/
plog.py
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
from plog import run
from optparse import OptionParser
import os,sys
import signal
def signal_handler(sig, frame):
pid=os.getpid()
os.kill(pid, signal.SIGQUIT)
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
parser = OptionParser()
parser.add_option("-c", "--config", dest="config_filename",
help="config file for parse log")
parser.add_option("-s", "--source", dest="source_file",
help="source file from log")
(options, args) = parser.parse_args()
if options.config_filename is None :
print "config file is none"
sys.exit(1)
else :
try:
if not os.path.exists(sys.path[0]+'/conf/'+options.config_filename):
print "there is not config file:%s,you should creat_cfg first,refer to https://github.com/CNSRE/Plog" %config_filename
sys.exit(1)
else:
config_file = sys.path[0]+'/conf/'+options.config_filename
except:
print "read config error,check it exists or not,refer to https://github.com/CNSRE/Plog"
sys.exit(1)
run(config_file = config_file, options=options ,args=args,debug=False)