Exemplo n.º 1
0
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.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)
Exemplo n.º 2
0
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.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)
Exemplo n.º 3
0
 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()
Exemplo n.º 4
0
 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 init ():
	global lbControl, camera, calibrator, config, lbVersion

	# read config
	config = ConfigReader(CONFIG_FILE)
	lbVersion = int(config.get("MAIN","version"))

	try:
		#init vars
		if lbVersion == 0:
			from hardware.letterboxControlTest import LetterboxControlTest
			lbControl = LetterboxControlTest()
		elif lbVersion == 1:
			from hardware.letterboxControlV1 import LetterboxControlV1
			lbControl = LetterboxControlV1()
		else:
			from hardware.letterboxControlV2 import LetterboxControlV2
			lbControl = LetterboxControlV2()

		# start camera
		if lbVersion == 0:
			from camera.cameraControlTest import CameraControlTest
			camera = CameraControlTest()
		else:
			from camera.cameraControl import CameraControl
			camera = CameraControl()

		calibrator = CameraCalibrator(CAMERA_MATRIX_FILE)

		# init hardware
		lbControl.calibrate()
		logger.info(" # initializing...")

	except Exception as err:
		logger.error(err)
		lbControl.flashFeedbackLed(10)
		stop()
		return False
	
	lbControl.flashFeedbackLed(2);
	logger.info("# finished initializing. starting loop...")
	return True
Exemplo n.º 6
0
def init (initCamera=True, cleanup=True):
	global lbControl, camera, config, lbVersion

	# read config
	config = ConfigReader(CONFIG_FILE)
	lbVersion = int(config.get("MAIN","version"))

	try:
		#init vars
		if lbVersion == 0:
			from hardware.letterboxControlTest import LetterboxControlTest
			lbControl = LetterboxControlTest(cleanup=cleanup)
		elif lbVersion == 1:
			from hardware.letterboxControlV1 import LetterboxControlV1
			lbControl = LetterboxControlV1(cleanup=cleanup)
		else:
			from hardware.letterboxControlV2 import LetterboxControlV2
			lbControl = LetterboxControlV2(cleanup=cleanup)

		# start camera
		if initCamera:
			if lbVersion == 0:
				from camera.cameraControlTest import CameraControlTest
				camera = CameraControlTest()
			else:
				from camera.cameraControl import CameraControl
				camera = CameraControl()

	except Exception as err:
		print(err)
		lbControl.flashFeedbackLed(10)
		stop()
		return False
	
	lbControl.flashFeedbackLed(2);
	print("# finished initializing")
	return True