-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcc.py
More file actions
45 lines (37 loc) · 1.21 KB
/
mcc.py
File metadata and controls
45 lines (37 loc) · 1.21 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
#-*-coding:utf-8 -*-
import time
import sys
from utils.mailHelper import mailHelper
from utils.excutor import executor
from utils.configReader import configReader
__Author__ = 'kingname'
__Verson__ = 0.5
reload(sys)
sys.setdefaultencoding('utf-8')
class MCC(object):
CONFIGPATH = '_config.ini'
KEY_COMMAND = 'Command'
KEY_OPEN = 'Open'
KEY_BOSS = 'Boss'
KEY_TIMELIMIT = 'timelimit'
def __init__(self):
self.mailHelper = mailHelper()
self.configReader = configReader(self.CONFIGPATH)
commandDict = self.configReader.getDict(self.KEY_COMMAND)
openDict = self.configReader.getDict(self.KEY_OPEN)
self.timeLimit = int(self.configReader.readConfig(self.KEY_BOSS, self.KEY_TIMELIMIT))
self.excutor = executor(commandDict, openDict)
self.toRun()
def toRun(self):
while True:
self.mailHelper = mailHelper()
self.run()
time.sleep(self.timeLimit)
def run(self):
mailBody = self.mailHelper.acceptMail()
if mailBody:
exe = self.mailHelper.analysisMail(mailBody)
if exe:
self.excutor.execute(exe, self.mailHelper)
if __name__=='__main__':
mcc = MCC()