def apiToDB(self, apiMesuer): mesureDB = dict() if ("_id" in apiMesuer): mesureDB["_id"] = apiMesuer["_id"] misc.toDateTime(apiMesuer, "date") mesureDB["date"] = apiMesuer["date"] mesureDB["adm"] = apiMesuer["adm"] mesureDB["source"] = source.getSource({"url": apiMesuer["source"]}) mesureDB["actions"] = list() if (apiMesuer["border_control"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append( action.getAction({"name": "border_control"})) if (apiMesuer["home_office"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append( action.getAction({"name": "home_office"})) if (apiMesuer["closure_leisureandbars"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append( action.getAction({"name": "closure_leisureandbars"})) if (apiMesuer["lockdown"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append(action.getAction({"name": "lockdown"})) if (apiMesuer["schools_closed"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append( action.getAction({"name": "schools_closed"})) if (apiMesuer["traveller_quarantine"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append( action.getAction({"name": "traveller_quarantine"})) if (apiMesuer["primary_residence"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append( action.getAction({"name": "primary_residence"})) if (apiMesuer["test_limitations"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append( action.getAction({"name": "test_limitations"})) return mesureDB
def apiToDB(self, apiMesuer): mesureDB = dict() dbId = apiMesuer.get("_id", None) if (not (dbId is None)): mesureDB["_id"] = dbId if ("date" in apiMesuer): if not isinstance(apiMesuer["date"], datetime.datetime): try: apiMesuer["date"] = datetime.datetime.fromtimestamp( int(apiMesuer["date"])) except: try: apiMesuer["date"] = datetime.datetime.strptime( apiMesuer["date"], '%Y-%m-%d') except: pass #was not a timestamp pass mesureDB["date"] = apiMesuer["date"] mesureDB["adm"] = apiMesuer["adm"] mesureDB["source"] = source.getSource({"url": apiMesuer["source"]}) mesureDB["actions"] = list() if (apiMesuer["border_control"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append( action.getAction({"name": "border_control"})) if (apiMesuer["home_office"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append( action.getAction({"name": "home_office"})) if (apiMesuer["closure_leisureandbars"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append( action.getAction({"name": "closure_leisureandbars"})) if (apiMesuer["lockdown"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append(action.getAction({"name": "lockdown"})) if (apiMesuer["schools_closed"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append( action.getAction({"name": "schools_closed"})) if (apiMesuer["traveller_quarantine"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append( action.getAction({"name": "traveller_quarantine"})) if (apiMesuer["primary_residence"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append( action.getAction({"name": "primary_residence"})) if (apiMesuer["test_limitations"] in ["TRUE", "true", "True", True]): mesureDB["actions"].append( action.getAction({"name": "test_limitations"})) return mesureDB
while True: sleep(1) except KeyboardInterrupt: print("Abort...") finally: Network.stopMonitorMode() exit(1) def gui(): """Creats the gui's main-window""" app = QtWidgets.QApplication(sys.argv) MainWindow = QtWidgets.QMainWindow() ui = Ui_MainWindow() ui.init(MainWindow) MainWindow.show() sys.exit(app.exec_()) if __name__ == '__main__': Config.parse_config() action = getAction() if action == ACTION.SCAN: scan() elif action == ACTION.INTERFACE: interfaceToMonitorMode() elif action == ACTION.EVALUATE: Pie_Chart.plotAllInOne() elif action == ACTION.GUI: gui()