-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMySys.py
More file actions
40 lines (31 loc) · 844 Bytes
/
Copy pathMySys.py
File metadata and controls
40 lines (31 loc) · 844 Bytes
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
import glob
import logging
import logging.handlers
from twisted.internet import reactor
import signal
import sys
reactor_active=False
def signal_handler(signal, frame):
print('You pressed Ctrl+C!')
#if reactor_active:
reactor.stop()
logging.shutdown()
sys.exit(0)
def initLog(fileName,standalone):
# import logging.config
if fileName == None: fileName = './app.log'
#if standalone:
signal.signal(signal.SIGINT, signal_handler)
logging.basicConfig(level=logging.DEBUG, filename=fileName,format='%(asctime)s %(levelname)s [%(threadName)s] %(message)s')
isactive=True
class MySys:
logfile = './mylog.log'
@staticmethod
def isActive():
return isactive
@staticmethod
def setActive(v):
isactive=v
@staticmethod
def setReactor():
reactor_active=True