def prepareThreads(): global threads dbproxy.DBCommand.comList = dbCommands threads[Processes.BasicIO] = basicio.BasicIO( currInfo["port"],int(currInfo["baudrate"]), queues[Queues.XBeeInput],queues[Queues.XBeeOutput],flags[Processes.BasicIO]) threads[Processes.Processing] = processing.DataHandler(queues[Queues.XBeeInput],queues[Queues.ProcessingOutput],flags[Processes.Processing]) threads[Processes.Distribution] = distributor.Distributor(queues[Queues.ProcessingOutput], queues[Queues.DatabaseInput],queues[Queues.FirstFileInput],queues[Queues.SecondFileInput], flags[Processes.Distribution],curSession) threads[Processes.DatabaseIO] = dbproxy.DataBaseWorker(currInfo["host"],currInfo["user"],currInfo["password"],currInfo["schema"], queues[Queues.DatabaseInput],queue.Queue(),flags[Processes.DatabaseIO]) threads[Processes.FileIO] = (fileio.FileIO("out(1).csv",queues[Queues.FirstFileInput],flags[Processes.FileIO]), fileio.FileIO("out(2).csv",queues[Queues.SecondFileInput],flags[Processes.FileIO]))
def createExceptionhandler(): global excHandler,excFile,queues errorQueueFileIO = queue.Queue(20) excFile = fileio.FileIO("error_log.txt",errorQueueFileIO,Flag(True)) queues["error"] = queue.Queue(40) excHandler = exceptionhandler.ExceptionHandler(queues["error"],errorQueueFileIO) basicio.BasicIO.setErrorLog(queues["error"]) processing.DataHandler.setErrorLog(queues["error"]) distributor.Distributor.setErrorLog(queues["error"]) dbproxy.DataBaseWorker.setErrorLog(queues["error"]) fileio.FileIO.setErrorLog(queues["error"]) excHandler.start() excFile.start()
def hello_world(): return json.dumps(fileio.FileIO().get_roms())
exceptionOutput = queue.Queue(20) fileOutput = queue.Queue(20) flags = {p[0] : flag.Flag(False) for p in Processes.getAll() } queues = {q[0] : queue.Queue(50) for q in Queues.getAll()} #sID = "" #while not sID.isnumeric(): # sID = input("Input session id: ") sID = 8 sName = "" #sName = input("Input session name: ") ses = session.Session(sID,sName) expOut = fileio.FileIO("log.txt",fileOutput,flag.Flag()) expHandler = exceptionhandler.ExceptionHandler(exceptionOutput,fileOutput) processing.DataHandler.setErrorLog(exceptionOutput) distributor.Distributor.setErrorLog(exceptionOutput) dbproxy.DataBaseWorker.setErrorLog(exceptionOutput) fileio.FileIO.setErrorLog(exceptionOutput) xbeeWorker = basicio.BasicIO("COM6",9600,queues[Queues.XBeeInput],queues[Queues.XBeeOutput],flags[Processes.BasicIO]) process = processing.DataHandler(queues[Queues.XBeeOutput],queues[Queues.ProcessingOutput],flags[Processes.Processing]) distrib = distributor.Distributor(queues[Queues.ProcessingOutput],queues[Queues.DatabaseInput],queues[Queues.FirstFileInput],queues[Queues.SecondFileInput],flags[Processes.Distribution],ses) dbWorker = dbproxy.DataBaseWorker(host,uid,passw,schema,queues[Queues.DatabaseInput],queue.Queue(100),flags[Processes.DatabaseIO]) fWorkerf = fileio.FileIO("output(1).csv",queues[Queues.FirstFileInput],flags[Processes.FileIO]) fWorkers = fileio.FileIO("output(2).csv",queues[Queues.SecondFileInput],flags[Processes.FileIO]) interface = CUI(ses,flags,queues)