class Controller(object): def __init__(self): self.forms = {} self.log = initLog("controller", debug=True) self.inputQ = Queue() self.outputQ = Queue() self.gs = GlobalSession() self.timeout = 60 def start(self): # open the port and wait gui connection self.ui = UiProxy(self.inputQ, self.outputQ) self.ui.initServer() self.ui.start() self.log.debug("ui proxy started.") def stop(self, status=0): self.log.info("exiting ui") self.ui.stop() sys.exit(status) def mainloop(self): self.log.debug("main loop in controller.") #self.stop() #return while True: try: message = self.inputQ.get(timeout=self.timeout) if message.type == "SOCKERROR": self.log.error("SOCKERROR") self.stop() else: self.log.debug(str(message)) except Empty: self.onTimeout() def onTimeout(self): pass
def start(self): # open the port and wait gui connection self.ui = UiProxy(self.inputQ, self.outputQ) self.ui.initServer() self.ui.start() self.log.debug("ui proxy started.")