def POST(self,name): webData = json.loads(web.data()) action = webData["action"] if "token" in webData: token = webData["token"] if common.func.checkSession(token) == False: return packOutput({}, "401", "Tocken authority failed") if action == "edit": account = {} stationID = webData["stationID"] account["user"] = webData["user"] account["password"] = webData["password"] account["descText"] = webData["descText"] stationAccount = DB.StationAccount() stationAccount.edit(stationID,account) return packOutput({}) elif action == "getList": stationAccount = DB.StationAccount() resultJson = {"accountList":[]} list = stationAccount.getList() for item in list: resultJson["accountList"].append(item) return packOutput(resultJson) elif action == "getInfo": stationID = webData["stationID"] stationAccount = DB.StationAccount() info = stationAccount.getInfo(stationID) return packOutput(info)
def POST(self,name): # webData = json.loads(web.data()) # # user = webData["user"] # passwd = webData["passwd"] # # if user == "root" and passwd == "clear!@#": # ret = {"token": common.func.getToken(user,passwd), # "userType": "Manager" # } # return packOutput(ret) # # #判断是否为分诊台帐号 # ret = DB.DBLocal.where("account", user=user,password = passwd) # if len(ret) != 0: # account = ret[0] # ret = { "userType": "station","stationID":account["stationID"]} # ret["token"] = common.func.getToken(user,passwd) # else: # #判断是否为医生账号 # ret = DB.DBLocal.where("workers", user=user, password=passwd) # # if len(ret) != 0: # for account in ret: # # 判断是否在允许的叫号器上登录 # if "localIP" in webData: # account["localIP"] = webData["localIP"] # caller = mainWorker.WorkerMainController().getCallerInfo(account) # if caller != {}: #不合法的医生账户登录 # ret = {"userType": "worker","stationID": account["stationID"]} # ret["callerID"] = caller["id"] # onlineMsg = {"stationID":account["stationID"],"callerID":caller["id"],\ # "workerID":account["id"],"status":"online"} # CallerInterface().setWorkerStatus(onlineMsg) # ret["token"] = common.func.getToken(user,passwd) # return packOutput(ret) # if "localIP" in webData: # return packOutput({}, "500", "not allowed caller,ip: " + webData["localIP"]) # else: # return packOutput({}, "500", "not allowed caller,ip: " + web.ctx.ip) # else: # return packOutput({},"500","uncorrect user and password") # # return packOutput(ret) data = json.loads(web.data()) action = data.pop("action", None) if action is None: return packOutput({}, code='400', errorInfo='action required') if action not in self.support_action: return packOutput({}, code='400', errorInfo="unsupport action") try: result = getattr(self, self.support_action[action])(data) return packOutput(result) except Exception as e: # exc_traceback = sys.exc_info()[2] # errorInfo = traceback.format_exc(exc_traceback) return packOutput({}, code='500', errorInfo=str(e))
def checkPostAction(object, data, suppostAction): token = data.pop("token", None) if token: if not checkSession(token): return packOutput({}, "401", "Token authority failed") action = data.pop("action", None) if action is None: return packOutput({}, code="400", errorInfo='action required') if action not in suppostAction: return packOutput({}, code="400", errorInfo='unsupported action') # result = getattr(object, suppostAction[action])(data) # return packOutput(result) try: result = getattr(object, suppostAction[action])(data) return packOutput(result) except Exception as e: exc_traceback = sys.exc_info()[2] error_trace = traceback.format_exc(exc_traceback) error_args = e.args if len(error_args) == 2: code = error_args[0] error_info = str(error_args[1]) else: code = "500" error_info = str(e) return packOutput({ "errorInfo": str(error_info), "rescode": code }, code=code, errorInfo=error_trace)
def POST(self, name): webData = json.loads(web.data()) action = webData["action"] if "token" in webData: token = webData["token"] if checkSession(token) == False: return packOutput({}, "401", "Tocken authority failed") if action == "getListWaiting": ret = self.getQueueVisitor(webData) jsonData = {"num": len(ret), "list": []} for item in ret: visitor = {} visitor["id"] = item["id"] visitor["name"] = item["name"] visitor["status"] = item["status"] visitor["originScore"] = item["originScore"] visitor["finalScore"] = item["finalScore"] visitor["originLevel"] = item["originLevel"] jsonData["list"].append(visitor) return packOutput(jsonData) elif action == "getListUnactive": pass elif action == "getListOver": pass else: return packOutput({}, "500", "unsupport action")
def POST(self, name): webData = json.loads(web.data()) action = webData["action"] key = "_getPublishList_" + str(json.dumps(webData)) value = common.func.CachedGetValue(key) if value != False: print "Cached Get get Cached ok" return value print "Cached Get not ok ,", key if action == "getCallerList": try: ret = self.getCallerList(webData) except Exception as e: return packOutput({}, code="400", errorInfo=str(e)) elif action == "getStationList": try: ret = self.getStationList(webData) except Exception as e: return packOutput({}, code="400", errorInfo=str(e)) elif action == "getWinList": try: ret = self.getWinList(webData) except Exception as e: return packOutput({}, code="400", errorInfo=str(e)) print "Cached Set key ,", key common.func.CachedSetValue(key, ret, 3) return packOutput(ret)
def POST(self, inputData): data = json.loads(web.data()) token = data.pop("token", None) if token: if checkSession(token) == False: return packOutput({}, "401", "Token authority failed") action = data.pop("action", None) if action is None: return packOutput({}, code='400', errorInfo='action required') if action not in self.support_action: return packOutput({}, code='400', errorInfo='unsupported action') try: result = getattr(self, self.support_action[action])(data) return packOutput(result) except Exception as e: exc_traceback = sys.exc_info()[2] errorInfo = traceback.format_exc(exc_traceback) return packOutput({ "errorInfo": str(e), "rescode": "500" }, code='500', errorInfo=errorInfo)
class StationInterface: def __init__(self): pass def POST(self,name): webData = json.loads(web.data()) action = webData["action"] if "token" in webData: token = webData["token"] if checkSession(token) == False: return packOutput({}, "401", "Tocken authority failed") if action == "getList": print(" Controller get stationList func in") num = stationMagager.LoadStation() if num == -1: return packOutput({},"500", "getStationList Error") else: resultJson = {"stationNum": num, "stationList": []} for item in stationMagager.stationList: station = {} station['id'] = item.getData()["id"] station['name'] = item.getData()["name"] resultJson['stationList'].append(station) print " get stationList func ok ,station num " + str(num) return packOutput(resultJson) elif action == "getInfo": print (" Controller get stationInfo ") req = json.loads(web.data()) stationID = req["stationID"] ret = stationMagager.getStation(stationID) if ret == {}: return packOutput({},"500", "getStationInfo Error") else: return packOutput(ret) elif action == "add": print(" Controller Add station ") addObj = json.loads(web.data()) try: id = stationMagager.addStation(addObj) resultJson = {"stationID": id} return packOutput(resultJson) except Exception, e: print Exception, ":", e return packOutput({},"500","Add station error : " + str(e)) elif action == "delete": print(" Controller del station ") req = json.loads(web.data()) id = req["stationID"] ret = stationMagager.delStation(id) if ret == -1: return packOutput({}, "500", "del station error" ) else: return packOutput({})
def POST(self, data): data = json.loads(web.data()) try: result = self.heartBeat(data) return packOutput(result) except Exception as errorInfo: print errorInfo return packOutput({}, code='400', errorInfo=str(errorInfo))
def POST(self, name): webData = json.loads(web.data()) action = webData["action"] if "token" in webData: token = webData["token"] if checkSession(token) == False: return packOutput({}, "401", "Token authority failed") if action == "getList": list = self.getList(webData) num = len(list) resultJson = {"num": num, "list": []} for item in list: caller = item.copy() resultJson["list"].append(caller) return packOutput(resultJson) elif action == "getInfo": caller = self.getInfo(webData) return packOutput(caller) elif action == "add": ret = self.add(webData) return packOutput({}) elif action == "edit": id = self.edit(webData) return packOutput({}) elif action == "delete": ret = self.delete(webData) if ret == -1: resultJson = {"result": "failed"} else: resultJson = {"result": "success"} return packOutput(resultJson) elif action == "setWorkerStatus": ret = self.setWorkerStatus(webData) if ret == -1: resultJson = {"result": "failed"} else: resultJson = {"result": "success"} return packOutput(resultJson) elif action == "checkIP": try: result = self.checkIP(webData) return packOutput(result) except Exception as e: return packOutput({}, code=500, errorInfo=str(e)) else: return packOutput({}, "500", "unsupport action")
def POST(self, name): data = json.loads(web.data()) action = data.get("action") try: if action == "regist": ret = self.regist(data) return packOutput(ret) elif action == "cancel": ret = self.cancel(data) return packOutput(ret) except Exception, e: print "Exception:", Exception, e print traceback.format_exc() return packOutput({}, "500", str(e))
def POST(self): myfile = web.input(myfile={}, uptype="") filename = myfile['filename'] logging.warning('Upload file ' + filename) name, ext = os.path.splitext(filename) # avoid none ascii issue myMd5 = hashlib.md5() if isinstance(name, str): myMd5.update(name.decode('utf8').encode('utf8')) elif isinstance(name, unicode): myMd5.update(name.encode('utf8')) dirPath = cfg.headPicPath name_md5 = myMd5.hexdigest() ext = ext.lower() newFileName = "%s%s" % (name_md5, ext) dest = os.path.join(dirPath, newFileName) os.rename(myfile['filepath'], dest) rst = { 'result': "success", 'upload_path': cfg.upload_http_base + newFileName, 'size': myfile.size } # return '<script>parent.uploadCallback(%s);window.location.href="upload%s.html";</script>'% (json.dumps(rst),myfile.uptype) return packOutput(rst)
def POST(self,name): webData = json.loads(web.data()) action = webData["action"] LogOut.info("worker Post Request action : "+action) if action == "getCallerInfo": ret = self.getCallerInfo(webData) return packOutput(ret) elif action == "getQueueList": ret = self.getQueueList(webData) return packOutput(ret) elif action == "getQueueListAll": try: ret = self.getQueueListAll(webData) return packOutput(ret) except Exception as e: return packOutput({}, code="400", errorInfo=str(e)) elif action == "getMovetoList": ret = self.getMovetoList(webData) return packOutput(ret) elif action == "visitorAppendQueue": try: self.visitorAppendQueue(webData) ret = {"result":"success"} except Exception, e: print Exception, ":", e ret = {"result": "faild"} return packOutput(ret,"500",str(e)) return packOutput(ret)
def POST(self, data): webData = json.loads(web.data()) action = webData["action"] if action == "addScene": try: result = self.addScene(webData) return packOutput(result) except Exception as e: return packOutput({}, code="400", errorInfo=str(e)) elif action == "editScene": try: result = self.editScene(webData) return packOutput(result) except Exception as e: return packOutput({}, code="400", errorInfo=str(e)) elif action == "getSceneInfo": try: result = self.getSceneInfo(webData) return packOutput(result) except Exception as e: return packOutput({}, code="400", errorInfo=str(e)) else: return packOutput({}, "500", "unsupport action")
def POST(self, data): """Interface to handle different requests to manage media box.""" data = json.loads(web.data()) action = data.pop("action", None) if action is None: return packOutput({}, "400", "action required.") if action == "getListAll": try: result = self.getListAll() return packOutput(result) except Exception as e: print str(e) return packOutput({}, code="400", errorInfo=str(e)) elif action == "getInfo": try: result = self.getInfo(data) return packOutput(result) except Exception as e: print str(e) return packOutput({}, code="400", errorInfo=str(e)) elif action == "edit": try: result = self.edit(data) return packOutput(result) except Exception as e: print str(e) return packOutput({}, code="400", errorInfo=str(e)) elif action == "delete": try: result = self.delete(data) return packOutput(result) except Exception as e: print str(e) return packOutput({}, code="400", errorInfo=str(e)) else: return packOutput({}, code="500", errorInfo="unsupport action.")
def POST(self, inputData): data = json.loads(web.data()) token = data.pop("token", None) action = data.pop("action", None) if token is None and action != "getExpertSchedule": return packOutput({}, code='400', errorInfo='token required') if action is None: return packOutput({}, code='400', errorInfo='action required') if action not in self.support_action: return packOutput({}, code='400', errorInfo='unsupported action') try: result = getattr(self, self.support_action[action])(data) return packOutput(result) except Exception as e: exc_traceback = sys.exc_info()[2] errorInfo = traceback.format_exc(exc_traceback) return packOutput({"errorInfo": str(e), "rescode": "500"}, code='500', errorInfo=errorInfo)
class StationMainController: def __init__(self): pass def POST(self, name): webData = json.loads(web.data()) action = webData["action"] LogOut.info("Station Post Request action : " + action) if action == "getQueueListInfo": try: jsonData = self.getQueueListInfo(webData) return packOutput(jsonData) except Exception as e: return packOutput({}, code="400", errorInfo=str(e)) elif action == "getQueueListAll": try: jsonData = self.getQueueListAll(webData, useCache=0) return packOutput(jsonData) except Exception as e: return packOutput({}, code="400", errorInfo=str(e)) elif action == "getVisitorInfo": try: jsonData = self.getVisitorInfo(webData) except Exception as e: print Exception, ":", e ret = {"result": "failed"} return packOutput(ret, "500", str(e)) return packOutput(jsonData) elif action == "visitorFuzzySearch": try: list = self.visitorFuzzySearch(webData) ret = {"resultList": list} except Exception, e: print Exception, ":", e ret = {"result": "faild"} return packOutput(ret, "500", str(e)) return packOutput(ret) elif action == "visitorMoveto": try: self.visitorMoveto(webData) ret = {"result": "success"} except Exception, e: print Exception, ":", e ret = {"result": "faild"} return packOutput(ret, "500", str(e))
def POST(self, input_data): """上传医生头像""" file = web.input(image={}) avatar = file["image"].file.read() filename = file["image"].filename filepath = os.path.join(cfg.headPicPath, filename) result = {"result": ""} try: if not os.path.exists(filepath): with open(filepath, 'wb') as f: f.write(avatar) result.update({"result": "success"}) except: result.update({"result": "failed"}) return packOutput(result)
def POST(self, name): webData = json.loads(web.data()) action = webData["action"] if "token" in webData: token = webData["token"] if checkSession(token) == False: return packOutput({}, "401", "Tocken authority failed") if action == "getList": slist = self.getList() num = len(slist) if num == -1: return packOutput({}, "500", "getStationList Error") else: resultJson = {"stationNum": num, "stationList": []} for item in slist: station = {} station['id'] = item["id"] station['name'] = item["name"] resultJson['stationList'].append(station) print " get stationList func ok ,station num " + str(num) return packOutput(resultJson) elif action == "getInfo": print(" Controller get stationInfo ") req = json.loads(web.data()) stationID = req["stationID"] ret = self.getInfo({"id": stationID}) if ret == {}: return packOutput({}, "500", "getStationInfo Error") else: return packOutput(ret) elif action == "add": print(" Controller Add station ") addObj = json.loads(web.data()) try: id = self.add(addObj) resultJson = {"stationID": id} return packOutput(resultJson) except Exception, e: print Exception, ":", e return packOutput({}, "500", "Add station error : " + str(e))
def POST(self,name): webData = json.loads(web.data()) user = webData["user"] passwd = webData["passwd"] if user == "root" and passwd == "clear!@#": ret = {"token": common.func.getToken(user,passwd), "userType": "Manager" } return packOutput(ret) #判断是否为分诊台帐号 ret = DB.DBLocal.where("account", user=user,password = passwd) if len(ret) != 0: account = ret[0] ret = { "userType": "station","stationID":account["stationID"]} ret["token"] = common.func.getToken(user,passwd) else: #判断是否为医生账号 ret = DB.DBLocal.where("workers", user=user, password=passwd) if len(ret) != 0: for account in ret: # 判断是否在允许的叫号器上登录 if "localIP" in webData: account["localIP"] = webData["localIP"] caller = mainWorker.WorkerMainController().getCallerInfo(account) if caller != {}: #不合法的医生账户登录 ret = {"userType": "worker","stationID": account["stationID"]} ret["callerID"] = caller["id"] onlineMsg = {"stationID":account["stationID"],"callerID":caller["id"],\ "workerID":account["id"],"status":"online"} CallerInterface().setWorkerStatus(onlineMsg) ret["token"] = common.func.getToken(user,passwd) return packOutput(ret) if "localIP" in webData: return packOutput({}, "500", "not allowed caller,ip: " + webData["localIP"]) else: return packOutput({}, "500", "not allowed caller,ip: " + web.ctx.ip) else: return packOutput({},"500","uncorrect user and password") return packOutput(ret)
def POST(self, name): x = web.input(myfile={}) filedir = cfg.headPicPath if 'myfile' in x: filepath = x.myfile.filename.replace( '\\', '/') # replaces the windows-style slashes with linux ones. filename = filepath.split( '/' )[-1] # splits the and chooses the last part (the filename with extension) fout = open( filedir + '/' + filename, 'w' ) # creates the file where the uploaded file should be stored fout.write(x.myfile.file.read() ) # writes the uploaded file to the newly created file. fout.close() # closes the file, upload complete. rst = { 'result': "success", 'upload_path': cfg.upload_http_base + filename, 'size': x.myfile.size } return packOutput(rst) raise web.seeother('/upload')
def POST(self,name): webData = json.loads(web.data()) action = webData["action"] if action == "getCallerList": try: ret = self.getCallerList(webData) return packOutput(ret) except Exception as e: return packOutput({}, code="400", errorInfo=str(e)) elif action == "getStationList": try: ret = self.getStationList(webData) return packOutput(ret) except Exception as e: return packOutput({}, code="400", errorInfo=str(e)) elif action == "getWinList": try: ret = self.getWinList(webData) return packOutput(ret) except Exception as e: return packOutput({},code="400", errorInfo=str(e))
def POST(self, data): data = json.loads(web.data()) action = data.pop("action", None) if not action: return packOutput({}, code="400", errorInfo="action required.") elif action == "heartbeat": try: result = self.heartBeat(data) return packOutput(result) except Exception as e: return packOutput({}, code="400", errorInfo=str(e)) elif action == "getListAll": try: result = self.getListAll() return packOutput(result) except Exception as e: return packOutput({}, code="400", errorInfo=str(e)) else: return packOutput({}, code="500", errorInfo="unsupport action.")
def POST(self, name): webData = json.loads(web.data()) action = webData["action"] if "token" in webData: token = webData["token"] if checkSession(token) == False: return packOutput({}, "401", "Tocken authority failed") if action == "getList": list = self.getList(webData) num = len(list) resultJson = {"workerNum": num, "workerList": []} for item in list: worker = item.copy() del worker["callerList"] resultJson["workerList"].append(worker) return packOutput(resultJson) elif action == "getInfo": worker = self.getInfo(webData) return packOutput(worker) elif action == "import": self.imports(webData) return packOutput({}) elif action == "add": id = self.addWorker(webData) return packOutput({}) elif action == "del": ret = self.delWorker(webData) if ret == -1: resultJson = {"result": "failed"} else: resultJson = {"result": "success"} return packOutput(resultJson) elif action == "edit": id = self.editWorker(webData) return packOutput({}) elif action == "testSource": ret = self.testImportSource(webData) if ret: resultJson = {"result": "success"} else: resultJson = {"result": "failed"} return packOutput(resultJson) elif action == "testSourceConfig": ret = self.testImportSourceConfig(webData) sql = self.getAliasSql(webData) if ret: resultJson = {"result": "success", "sql": sql} else: resultJson = {"result": "failed", "sql": sql} return packOutput(resultJson) elif action == "checkID": ret = self.checkConflict(webData) resultJson = {"conflict": ret} return packOutput(resultJson) else: return packOutput({}, "500", "unsupport action")
def POST(self, name): webData = json.loads(web.data()) action = webData["action"] if "token" in webData: token = webData["token"] if checkSession(token) == False: return packOutput({}, "401", "Tocken authority failed") if action == "getList": list = self.getList(webData) num = len(list) resultJson = {"num": num, "list": []} for item in list: queue = item.copy() queue["workerLimit"] = str2List(queue["workerLimit"]) resultJson["list"].append(queue) return packOutput(resultJson) elif action == "getInfo": queueInfo = self.getInfo(webData) queueInfo["workerLimit"] = str2List(queueInfo["workerLimit"]) return packOutput(queueInfo) elif action == "add": webData["workerLimit"] = list2Str(webData["workerLimit"]) ret = self.add(webData) return packOutput({}) elif action == "edit": webData["workerLimit"] = list2Str(webData["workerLimit"]) id = self.edit(webData) return packOutput({}) elif action == "delete": ret = self.delete(webData) if ret == -1: resultJson = {"result": "failed"} else: resultJson = {"result": "success"} return packOutput(resultJson) elif action == "getSourceQueueList": ret = self.getSourceQueueList(webData) jsonData = {"num": len(ret), "list": ret} return packOutput(jsonData) elif action == "getSceneSupportList": ret = self.getSceneSupportList(webData) list = [] for item in ret: list.append(item) jsonData = {"num": len(ret), "list": list} return packOutput(jsonData) elif action == "getAvgWaitTime": try: result = self.getAvgWaitTime(webData) return packOutput(result) except Exception as errorInfo: return packOutput({}, code="400", errorInfo=str(errorInfo)) else: return packOutput({}, "500", "unsupport action")
ret = {"resultList": list} except Exception, e: print Exception, ":", e ret = {"result": "faild"} return packOutput(ret, "500", str(e)) return packOutput(ret) elif action == "visitorMoveto": try: self.visitorMoveto(webData) ret = {"result": "success"} except Exception, e: print Exception, ":", e ret = {"result": "faild"} return packOutput(ret, "500", str(e)) return packOutput(ret) elif action == "visitorMoveby": try: self.visitorMoveby(webData) ret = {"result": "success"} except Exception, e: print Exception, ":", e ret = {"result": "faild"} return packOutput(ret, "500", str(e)) return packOutput(ret) elif action == "visitorProirSet": try: self.visitorProirSet(webData) ret = {"result": "success"}
elif action == "delete": print(" Controller del station ") req = json.loads(web.data()) id = req["stationID"] ret = self.delete({"id": id}) if ret == -1: return packOutput({}, "500", "del station error") else: return packOutput({}) elif action == "edit": print(" Controller change station ") data = json.loads(web.data()) ret = self.edit(data) if ret != "success": return packOutput({}, "500", "change station error") else: return packOutput({}) elif action == "sourceTest": print(" Controller source Test ") data = json.loads(web.data()) if integrateType == "VIEW": importFunc = ImportTableFromView(self, "test_visitor_Config", visitor_para_name) ret = importFunc.testImportSource(data) else: ret = "success" if ret == "success": resultJson = {"testResult": "success"} else:
ret = {"result":"success"} except Exception, e: print Exception, ":", e ret = {"result": "faild"} return packOutput(ret,"500",str(e)) return packOutput(ret) elif action == "visitorMoveby": try: self.visitorMoveby(webData) ret = {"result": "success"} except Exception, e: print Exception, ":", e ret = {"result": "faild"} return packOutput(ret,"500",str(e)) return packOutput(ret) elif action == "callNext": try: ret = self.callNext(webData) ret["result"] = "success" except Exception, e: print Exception, ":", e ret = {"result": "faild"} return packOutput(ret,"500",str(e)) return packOutput(ret) elif action == "reCall": try: ret = self.reCall(webData) ret["result"] = "success"