def GET(self): logger = getLogger() try: logger.debug("start thirdval Page GET response") parsed_url = urlparse.urlparse(web.ctx.fullpath) query_url = parsed_url.query query_url = query_url.encode('utf-8') if (query_url != ''): query_dict = dict(urlparse.parse_qsl(query_url)) if 'orderid' in query_dict: orderid = query_dict['orderid'] return render.thirdeval(orderid = orderid,queryDict = query_dict) else: #if no orderid, according the query_dict to show a file. orderid = None return render.thirdeval(orderid = orderid,queryDict = query_dict) else: #if no querey string. show blank file orderid = None query_dict = None return render.thirdeval(orderid = orderid,queryDict = query_dict) except : logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() finally: pass
def getQuestionCount(self,itemID): """ 通过itemID查找到录音问题的答案数量 author: J.Wong args: itemID,string 问题ID return: itemCount,int 答案数量 """ try: logger = getLogger() logger.debug("start iRecorderQuestionModuleObj.getQuestionCount") conn = msSqlConnect() cur = conn.cursor() sqlstr = "SELECT ITEMID"\ " FROM [TRQ_SCRSUB]"\ " WHERE [TRQ_SCRSUB].[ITEMID] = %s" cur.execute(sqlstr,itemID) logger.info("sql:"+str(sqlstr)+"\n itemID:"+str(itemID)) result = [] for row in cur: result.append(row) return len(result) except Exception,ex: if logger is not None: logger.error("exception occur, see the traceback.log") if sqlstr is not None: logger.effof("sql:"+str(sqlstr)+"\n itemID:"+str(itemID)) #异常写入日志文件. f = open('Logs/traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() return 0
def saveData2DbSqlite(inOrderId): try: logger = getLogger() logger.debug("start saveData2DbSqlite") ret = True t = None dbSqlite = DbSqliteConnect() t = dbSqlite.transaction() dbSqlite.insert('orderHist',orderid=inOrderId) logger.debug("saveData2DbSqlite success.") except : logger.debug("saveData2DbSqlite go into excption.") logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() ret = False t.rollback() else: t.commit() pass finally: pass return ret
def GET(self): logger = getLogger() try: logger.debug("start thirdevalList Page GET response") parsed_url = urlparse.urlparse(web.ctx.fullpath) query_url = parsed_url.query if (query_url != ''): query_dict = dict(urlparse.parse_qsl(query_url)) if 'orderid' in query_dict: orderid = query_dict['orderid'] else: orderid = None if 'pageindex' in query_dict: pageindex = query_dict['pageindex'] else: pageindex = None return render.thirdevalList(orderid=orderid,pageindex=pageindex) else: orderid = None pageindex = None return render.thirdevalList(orderid=orderid,pageindex=pageindex) except: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() finally: pass
def getData4DbSqlite(): try: logger = getLogger() logger.debug("start getData4DbSqlite") retList = list() dbSqlite = DbSqliteConnect() entries = dbSqlite.select('orderHist',what='orderid') for val in entries: localOrderid = val.orderid retList.append(localOrderid) if (len(retList)>0): return retList logger.debug("getData4DbSqlite success") except : logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() ret = False else: pass finally: pass
def GET(self): try: logger = getLogger() logger.debug("start OrderProduct Page GET response") globalDefine.globalOrderInfoErrorlog = "No Error" #TODO: open the auth in future.also need purview. # authreq = checkUserAuth(web) # # if authreq: # web.header('WWW-Authenticate','Basic realm="Auth example"') # web.ctx.status = '401 Unauthorized' # logger.debug("no right HTTP_AUTHORIZATION") # return render.error(error = web.ctx.status) parsed_url = urlparse.urlparse(web.ctx.fullpath) query_url = parsed_url.query if (query_url != ''): query_dict = dict(urlparse.parse_qsl(query_url)) if 'INSURANCECODE' in query_dict: insurancecodeid = query_dict['INSURANCECODE'] else: insurancecodeid = None if 'SECURITYPLAN' in query_dict: securityplanid = query_dict['SECURITYPLAN'] else: securityplanid = None if 'PREMIUMPLAN' in query_dict: premiumplanid = query_dict['PREMIUMPLAN'] else: premiumplanid = None if 'AGEPLAN' in query_dict: ageplan = query_dict['AGEPLAN'] else: ageplan = None return render.orderProduct(insurancecodeid = insurancecodeid,securityplanid=securityplanid,premiumplanid=premiumplanid,ageplan=ageplan) else: insurancecodeid = None securityplanid = None premiumplanid = None ageplan = None return render.orderProduct(insurancecodeid = insurancecodeid,securityplanid=securityplanid,premiumplanid=premiumplanid,ageplan=ageplan) except : logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() else: pass finally: pass
def GET(self,filename): try: logger = getLogger() logger.debug("start rqscoscr Page GET response") globalDefine.globalOrderInfoErrorlog = "No Error" #TODO: open the auth in future.also need purview. # authreq = checkUserAuth(web) # # if authreq: # web.header('WWW-Authenticate','Basic realm="Auth example"') # web.ctx.status = '401 Unauthorized' # logger.debug("no right HTTP_AUTHORIZATION") # return render.error(error = web.ctx.status) #TODO: when None happen? if filename is '' or filename is None: return render.error(error = 'no filename') else: return render.RacorderScoreView(outdicrqscoscr=getTestData()) except : logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() else: pass finally: pass
def NotExitsOrderid(inOrderid): ret = True try: logger = getLogger() logger.debug("start NotExitsOrderid") dbI8 = DbConnect() myvar = dict(orderid="GWImp"+inOrderid) #entries = dbI8.select('con_orderhist',myvar,where="orderid=$orderid",_test=True) entries = dbI8.select('i8.con_orderhist',myvar,where="orderid=$orderid") #exits order id. for val in entries: ret = False globalDefine.globalOrderInfoErrorlog="orderid existed" return ret except : logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() else: pass finally: pass return ret
def saveOrderInfo(self,inOrderInfo): try: logger = getLogger() logger.debug("start saveOrderInfo") ret = True ret &= self.compareOrderInfo(inOrderInfo) #all condition is ok if(ret): ret = DbModule.saveData2Db(inOrderInfo) if (ret): ret = DbModule.saveData2DbSqlite("GWImp"+inOrderInfo["orderId"]) except : logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() else: pass finally: pass return ret
def putOrderInfoContact(inOrderid,storageData,inStatus,inCrusr): logger = getLogger() try: logger.debug("start PUT Order Info according contact id.") jsonData = json.dumps(storageData) dictData = json.loads(jsonData) retStr = {"RETURNFLAG":True,"OrderID":1} logger.debug("put OrderInfo success.") return retStr except pycurl.error, error: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() errno, errstr = error print 'An error occurred: ', errstr
def IsExitsProductid(inOrderDet): ret = False try: logger = getLogger() logger.debug("start IsExitsProductid") dbI8 = DbConnect() for localOrderDet in inOrderDet: myvar = dict(prodid=localOrderDet["orderProductId"]) entries = dbI8.select('i8.dic_sys_product',myvar,where="prodid=$prodid") ret = False #exits order id. for val in entries: ret = True if (ret == False): globalDefine.globalOrderInfoErrorlog = "prodid not existed" except : logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() else: pass finally: pass return ret
def getUsrInfoSource(inQueryDict): """get insurant user info from query string. we need get the data from out usr info. but now ,the function do nothing. """ try: logger = getLogger() logger.debug("start get user info from query string .") if inQueryDict is None: return None #PolicyHolder_Usr 投保人 configPageUsing = configPage['PolicyHolder_Usr'] retDict = inQueryDict return retDict except: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() else: pass finally: pass
def POST(self, orderid): try: logger = getLogger() logger.debug("start Order POST response") globalDefine.globalOrderInfoErrorlog = "No Error" data = web.data() # result = urlparse.parse_qs(data) # uid = result['child1'][0] # add_count = 0 # list = json.loads(result['child2'][0]) # for u in list: # add_count += self.add_orderInfo(orderid , u[0]) except: logger.error("exception occur, see the traceback.log") # 异常写入日志文件. f = open("traceback.txt", "a") traceback.print_exc() traceback.print_exc(file=f) f.flush() f.close() else: pass finally: return orderid
def putOrderInfoContact(inOrderid, storageData, inStatus, inCrusr): logger = getLogger() try: logger.debug("start PUT Order Info according contact id.") jsonData = json.dumps(storageData) dictData = json.loads(jsonData) retStr = {"RETURNFLAG": True, "OrderID": 1} logger.debug("put OrderInfo success.") return retStr except pycurl.error, error: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt', 'a') traceback.print_exc() traceback.print_exc(file=f) f.flush() f.close() errno, errstr = error print 'An error occurred: ', errstr
def POST(self): logger = getLogger() try: logger.debug("start Order Page POST response") #get POST form data data = web.input() retStr = ThirdEvalDomainHandler.postThirdEvalInfo(data) if retStr is None: return render.error(error = 'add failure.') #according the response #retDict = json.loads(retStr) retDict = retStr if (retDict["RETURNFLAG"] == True): #refresh the order. orderidStr = retDict["OrderID"] return render.thirdeval(orderid = orderidStr) else: return render.error(error = 'add failure.') except : logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() finally: pass
def getThirdEvalInfo(inOrderid,configPage): """ get the third eval info from DB now, we simulate some json data. """ logger = getLogger() try: logger.debug("start GET Order Info according order id.") if inOrderid is None: return None #from db to get the data. import web import sqlite3 dbSqlite = web.database(dbn='sqlite',db='thirdeval.s3db') myvar = dict(id=inOrderid) results = dbSqlite.select('thirdeval_detail', myvar, where="id = $id") for item in results: localOrderInfo = { "basic":{ "BASIC_NAME":item['basic_name'], "BASIC_SEX":item['basic_sex'], }, "third":{ "NORMAL_ADL":item['third_normal_adl'], "NORMAL_IADL":item['third_normal_iadl'], "NORMAL_RECOGNIZE":item['third_normal_recognize'], "THIRDEVAL_CLASS":item['thirdeval_class'] }, "leer":{ "LEER_NORMAL_ADL":item['leer_normal_adl'], "LEER_SPIRIT_DEPRESS":item['leer_spirit_depress'], "LEER_FEEL_SOUL":item['leer_feel_soul'], "LEER_CLASS":item['leer_class'] } } logger.debug("get localOrderInfo success.") #we need change the data structure, so the html show simple. if localOrderInfo is not None: localOrderInfo = flatThirdEvalInfo(localOrderInfo) return localOrderInfo except: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() finally: pass
def getThirdEvalInfo(inOrderid): """ get the third eval info from DB now, we simulate some json data. """ logger = getLogger() try: logger.debug("start GET Order Info according order id.") if inOrderid is None: return None #from db to get the data. import web import sqlite3 dbSqlite = web.database(dbn='sqlite',db='thirdeval.s3db') myvar = dict(id=inOrderid) results = dbSqlite.select('thirdeval_detail', myvar, where="id = $id") for item in results: localOrderInfo = { "basic":{ "BASIC_NAME":item['basic_name'], "BASIC_SEX":item['basic_sex'], }, "third":{ "NORMAL_ADL":item['third_normal_adl'], "NORMAL_IADL":item['third_normal_iadl'], "NORMAL_RECOGNIZE":item['third_normal_recognize'], "THIRDEVAL_CLASS":item['thirdeval_class'] }, "leer":{ "LEER_NORMAL_ADL":item['leer_normal_adl'], "LEER_SPIRIT_DEPRESS":item['leer_spirit_depress'], "LEER_FEEL_SOUL":item['leer_feel_soul'], "LEER_CLASS":item['leer_class'] } } logger.debug("get localOrderInfo success.") #we need change the data structure, so the html show simple. if localOrderInfo is not None: localOrderInfo = flatThirdEvalInfo(localOrderInfo) return localOrderInfo except: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() finally: pass
def GET(self,contactid): #must have contactid, otherwise,the data will be wrong. try: logger = getLogger() logger.debug("start Order Page GET response") globalDefine.globalOrderInfoErrorlog = "No Error" #TODO: open the auth in future.also need purview. # authreq = checkUserAuth(web) # # if authreq: # web.header('WWW-Authenticate','Basic realm="Auth example"') # web.ctx.status = '401 Unauthorized' # logger.debug("no right HTTP_AUTHORIZATION") # return render.error(error = web.ctx.status) if contactid is None: return render.error(error = 'no contactid') else: #if has orderid according the orderid to get the order info. #query_dict = dict(urlparse.parse_qsl(web.ctx.env['QUERY_STRING'])) parsed_url = urlparse.urlparse(web.ctx.fullpath) query_url = parsed_url.query query_url = query_url.encode('utf-8') if (query_url != ''): query_dict = dict(urlparse.parse_qsl(query_url)) if 'orderid' in query_dict: orderid = query_dict['orderid'] role = web.ctx.session.session_role; return render.order(contactid = contactid,orderid = orderid,queryDict = query_dict,outrole =role) else: #if no orderid, according the query_dict to show a file. orderid = None role = web.ctx.session.session_role; return render.order(contactid = contactid,orderid = orderid,queryDict = query_dict,outrole = role) else: #if no querey string. show blank file orderid = None query_dict = None role = web.ctx.session.session_role; return render.order(contactid = contactid,orderid = orderid,queryDict = query_dict,outrole =role) except : logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() else: pass finally: pass
def GET(self, orderid): try: logger = getLogger() logger.debug("start Trans GET response") globalDefine.globalOrderInfoErrorlog = "No Error" auth = web.ctx.env.get("HTTP_AUTHORIZATION") authreq = False if auth is None: authreq = True else: auth = re.sub("^Basic ", "", auth) username, password = base64.decodestring(auth).split(":") if (username, password) in allowed: logger.debug("has right HTTP_AUTHORIZATION") pass else: authreq = True if authreq: web.header("WWW-Authenticate", 'Basic realm="Auth example"') web.ctx.status = "401 Unauthorized" logger.debug("no right HTTP_AUTHORIZATION") # TODO:why only two para? return {"orderid": "", "mailid": "", "companytitle": ""} if not orderid: orderid = "no orderid" mailid = "no mailid" companytitle = "no companytitle" else: OTO = orderTransObj() transInfo = OTO.getTransInfo(orderid) mailid = transInfo["mailid"] companytitle = transInfo["companytitle"] utf8companytitle = unicode(companytitle, "cp936") return { "orderid": orderid, "mailid": mailid, "companytitle": utf8companytitle, "error info": globalDefine.globalOrderTransErrorlog, } except: logger.error("exception occur, see the traceback.log") # 异常写入日志文件. f = open("traceback.txt", "a") traceback.print_exc() traceback.print_exc(file=f) f.flush() f.close() else: pass finally: pass
def IsValidContactAddress(inOrderInfo): ret = True try: logger = getLogger() logger.debug("start IsValidContactAddress") dbI8 = DbConnect() #according the contact province,city,district to get the snapid. #get provinceid from dic_sys_province myvar = dict(chinese=inOrderInfo["contactProvince"]) entries = dbI8.select('i8.dic_sys_province',myvar,what="provinceid",where="chinese=$chinese") localProvinceId = entries[0].PROVINCEID updateDict = {'orderProvinceId':localProvinceId} inOrderInfo.update(updateDict) logger.debug("localProvinceID is :"+localProvinceId ) #get cityid from dic_sys_city myvar = dict(chinese=inOrderInfo["contactCity"]) entries = dbI8.select('i8.dic_sys_city',myvar,what="cityid",where="chinese=$chinese") localCityId = entries[0].CITYID updateDict = {'orderCityId':localCityId} inOrderInfo.update(updateDict) logger.debug("localCityId is :"+localCityId ) #get addressid from dic_sys_ems myvar = dict(name=inOrderInfo["contactDistrict"],provinceid=localProvinceId,city=localCityId) entries = dbI8.select('i8.dic_sys_ems',myvar,what="spellid",where="name=$name and provinceid=$provinceid and city=$city") localSpellId = entries[0].SPELLID logger.debug("localSpellId is :"+localSpellId ) updateDict = {'orderSpellId':localSpellId} inOrderInfo.update(updateDict) except : logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() ret = False globalDefine.globalOrderInfoErrorlog="contact province,contact city,contact district can not be finded in I8 system" else: pass finally: pass return ret
def postThirdEvalInfo(storageData): logger = getLogger() try: logger.debug("start PUT Order Info according contact id.") jsonData = json.dumps(storageData) dictData = json.loads(jsonData) # save data to sqlite db. import web import sqlite3 dbSqlite = web.database(dbn='sqlite',db='thirdeval.s3db') thirdevalid = 0 if dictData is not None: thirdevalid = dbSqlite.insert('thirdeval_detail', basic_name=dictData['BASIC_NAME'], basic_sex=dictData['BASIC_SEX'], third_normal_adl=dictData['NORMAL_ADL'], third_normal_iadl=dictData['NORMAL_IADL'], third_normal_recognize=dictData['NORMAL_RECOGNIZE'], thirdeval_class=dictData['THIRDEVAL_CLASS'], leer_normal_adl=dictData['LEER_NORMAL_ADL'], leer_spirit_depress=dictData['LEER_SPIRIT_DEPRESS'], leer_feel_soul=dictData['LEER_FEEL_SOUL'], leer_class=dictData['LEER_CLASS'] ) else: pass if thirdevalid is 0: pass else: logger.debug("save the third eval info success.") retStr = {"RETURNFLAG":True,"OrderID":thirdevalid} logger.debug("put OrderInfo success.") return retStr except pycurl.error, error: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() errno, errstr = error print 'An error occurred: ', errstr
def flatThirdEvalInfo(inThirdEvalInfo): """update the third eval info according the web page show.show the data. so we need pull all data in list ,make them flat to show in the page.so in the page, the show will be easy. TODO: in future, we need create the function according the config data.2017.10.30. 这个函数感觉也有点多余,要简化. """ logger = getLogger() try: logger.debug("start flat third eval Info .") if inThirdEvalInfo is None: return None # we only get the message we needed: #change the list to flat data. localThirdEvalInfo = inThirdEvalInfo #basic_page 基本信息 configPageUsing = configPage['basic_page'] item = localThirdEvalInfo["basic"] addDictItemValue(item,'BASIC_NAME',localThirdEvalInfo,configPageUsing['name']['dataName']) addDictItemValue(item,'BASIC_SEX',localThirdEvalInfo,configPageUsing['sex']['dataName']) #third_page 第三方评估 configPageUsing = configPage['third_page'] item = localThirdEvalInfo["third"] addDictItemValue(item,'NORMAL_ADL',localThirdEvalInfo,configPageUsing['normal_adl']['dataName']) addDictItemValue(item,'NORMAL_IADL',localThirdEvalInfo,configPageUsing['normal_iadl']['dataName']) addDictItemValue(item,'NORMAL_RECOGNIZE',localThirdEvalInfo,configPageUsing['normal_recognize']['dataName']) addDictItemValue(item,'THIRDEVAL_CLASS',localThirdEvalInfo,configPageUsing['thirdeval_class']['dataName']) #leer_page 乐尔之家评估 configPageUsing = configPage['leer_page'] item = localThirdEvalInfo["leer"] addDictItemValue(item,"LEER_NORMAL_ADL",localThirdEvalInfo,configPageUsing['normal_adl']['dataName']) addDictItemValue(item,"LEER_SPIRIT_DEPRESS",localThirdEvalInfo,configPageUsing['spirit_depress']['dataName']) addDictItemValue(item,"LEER_FEEL_SOUL",localThirdEvalInfo,configPageUsing['feel_soul']['dataName']) addDictItemValue(item,"LEER_CLASS",localThirdEvalInfo,configPageUsing['leer_class']['dataName']) logger.debug("update localOrderInfo success.") return localThirdEvalInfo except: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() finally: pass
def compareOrderInfo(self,inOrderInfo): try: logger = getLogger() logger.debug("start compareOrderInfo") ret = True #exists contact,same name,same phone? 现在电话加密,所以不能比较. #ret &= DbModule.NotExitsContact(inOrderInfo) #if (ret == False): # return ret #exists orderid? ret &= DbModule.NotExitsOrderid(inOrderInfo["orderId"]) if (ret == False): return ret #exists productid? ret &= DbModule.IsExitsProductid(inOrderInfo["orderDet"]) if (ret == False): return ret #valid crusr? ret &= DbModule.IsValidCrusr(inOrderInfo["crusr"]) if (ret == False): return ret #valid order status? ret &= DbModule.IsValidOrderStatus(inOrderInfo["orderStatus"]) if (ret == False): return ret #valid contact address ret &= DbModule.IsValidContactAddress(inOrderInfo) if (ret == False): return ret except : logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() ret = False else: pass finally: return ret
def GetRacorderQuestionUrl(fid): """get the order info from REST """ try: logger = getLogger() logger.debug("start GET RacorderQuestion Info according fid id.") if fid is None: return None buf = cStringIO.StringIO() #define in function. c = pycurl.Curl() localURL = getConfig('RESTService','irecorderQuestionUrl','str')+fid localURL = str(localURL) print localURL; c.setopt(pycurl.URL,localURL) c.setopt(c.WRITEFUNCTION,buf.write) c.setopt(c.VERBOSE, True) c.setopt(pycurl.USERPWD,getConfig('allowedUser1','UserName','str')+':'+getConfig('allowedUser1','Password','str')) c.perform() http_code = c.getinfo(pycurl.HTTP_CODE) #judge get success. if http_code != 200: return None #get the data from json. if (len(buf.getvalue())>0): s = buf.getvalue() localRacorderQuestion = json.loads(buf.getvalue()) else: localRacorderQuestion= None buf.close() c.close() logger.debug("get GetRacorderQuestionUrl success.") #we need change the data structure, so the html show simple. if localRacorderQuestion is not None: #localRacorderQuestion = flatOrderInfoOrder(localRacorderQuestion) return localRacorderQuestion except pycurl.error, error: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() errno, errstr = error print 'An error occurred: ', errstr
def POST(self,contactid): try: logger = getLogger() logger.debug("start Order Page POST response") globalDefine.globalOrderInfoErrorlog = "No Error" #TODO: open the auth in future.also need purview. # authreq = checkUserAuth(web) # # if authreq: # web.header('WWW-Authenticate','Basic realm="Auth example"') # web.ctx.status = '401 Unauthorized' # logger.debug("no right HTTP_AUTHORIZATION") # return render.error(error = web.ctx.status) if contactid is None: return render.error(error = 'no contactid') else: #get POST form data data = web.input() #call REST post data #TODO: 1 means 待审核订单 status = '1' retStr = OrderDomainHandler.postOrderInfoContact(contactid,data,status,web.ctx.session.session_usrid,web.ctx.session.session_grpid) if retStr is None: return render.error(error = 'add failure.') #according the response retDict = json.loads(retStr) if (retDict["RETURNFLAG"] == True): #refresh the order. orderidStr = retDict["OrderID"] role = web.ctx.session.session_role; return render.order(contactid = contactid,orderid = orderidStr,outrole = role) else: return render.error(error = 'add failure.') except : logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() else: pass finally: pass
def getiRecorderListByFileName(self,filename): """ 通过录音文件名查找到录音资源 author: J.Wong args: filename,string 录音文件名 return: iRecorderList,list 对应的录音资源list """ try: logger = getLogger() logger.debug("start iRecorderListModuleObj.getiRecorderListByFileName") conn = msSqlConnect() cur = conn.cursor() sqlstr = "SELECT [HOSTNAME]"\ ",[FILENAME]"\ ",[CHANNELNO]"\ ",[STARTTIME]"\ ",[SPENDTIME]"\ ",[AVAILABLE]"\ ",[AGENTID]"\ ",[FILEPATH]"\ ",[CHANNELDN]"\ ",[CALLTYPE]"\ ",[TELNO]"\ ",[TELDNIS]"\ ",[CALLID]"\ ",[ENDTIME]"\ ",[TRQ_SCORE].[TOTAL]"\ " FROM [T_RECORDER]"\ " LEFT JOIN [TRQ_SCORE]"\ " ON [T_RECORDER].[FILENAME] = [TRQ_SCORE].[RECKEY]"\ " WHERE [T_RECORDER].[FILENAME] = %s" cur.execute(sqlstr,filename) logger.info("sql:"+str(sqlstr)+"\n filename:"+str(filename)) result = [] for row in cur: result.append(row) if len(result): return result else: return 'No data.' except Exception,ex: if logger is not None: logger.error("exception occur, see the traceback.log") if sqlstr is not None: logger.error("sql:"+str(sqlstr)+"\n filename:"+str(filename)) #异常写入日志文件. f = open('Logs/traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() return ex.message
def postThirdEvalInfo(storageData): logger = getLogger() try: logger.debug("start PUT Order Info according contact id.") jsonData = json.dumps(storageData) dictData = json.loads(jsonData) # save data to sqlite db. import web import sqlite3 dbSqlite = web.database(dbn='sqlite', db='thirdeval.s3db') thirdevalid = 0 if dictData is not None: thirdevalid = dbSqlite.insert( 'thirdeval_detail', basic_name=dictData['BASIC_NAME'], basic_sex=dictData['BASIC_SEX'], third_normal_adl=dictData['NORMAL_ADL'], third_normal_iadl=dictData['NORMAL_IADL'], third_normal_recognize=dictData['NORMAL_RECOGNIZE'], thirdeval_class=dictData['THIRDEVAL_CLASS'], leer_normal_adl=dictData['LEER_NORMAL_ADL'], leer_spirit_depress=dictData['LEER_SPIRIT_DEPRESS'], leer_feel_soul=dictData['LEER_FEEL_SOUL'], leer_class=dictData['LEER_CLASS']) else: pass if thirdevalid is 0: pass else: logger.debug("save the third eval info success.") retStr = {"RETURNFLAG": True, "OrderID": thirdevalid} logger.debug("put OrderInfo success.") return retStr except pycurl.error, error: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt', 'a') traceback.print_exc() traceback.print_exc(file=f) f.flush() f.close() errno, errstr = error print 'An error occurred: ', errstr
def Login(username,password): ret = False try: logger = getLogger() logger.debug("start GET RacorderQuestion Info according fid id.") if username is not None and username != '': localURL = '&id=' + username if password is not None and password != '': localURL = localURL + '&pwd=' + password buf = cStringIO.StringIO() #define in function. c = pycurl.Curl() localURL = getConfig('RESTService','irecorderloginUrl','str')+"?"+localURL localURL = str(localURL) print localURL c.setopt(pycurl.URL,localURL) c.setopt(c.WRITEFUNCTION,buf.write) c.setopt(c.VERBOSE, True) c.setopt(pycurl.USERPWD,getConfig('allowedUser1','UserName','str')+':'+getConfig('allowedUser1','Password','str')) c.perform() http_code = c.getinfo(pycurl.HTTP_CODE) #judge get success. if http_code != 200: return False #get the data from json. if (len(buf.getvalue())>0): s = buf.getvalue() localRacorderQuestion = json.loads(buf.getvalue()) buf.close() c.close() logger.debug("get GetRacorderQuestionUrl success.") #we need change the data structure, so the html show simple. if localRacorderQuestion is not None: #localRacorderQuestion = flatOrderInfoOrder(localRacorderQuestion) ret = localRacorderQuestion["message"] except pycurl.error, error: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() ret = False; print 'An error occurred: ', "login"
def RacorderQuestionContact(storageData,retPost): try: logger = getLogger() logger.debug("start POST RacorderQuestionContact Info according contact id.") jsonData = storageData; print jsonData; #print jsonData buf = cStringIO.StringIO() c = pycurl.Curl() localURL = getConfig('RESTService','irecorderscoreUrl','str') localURL = str(localURL) c.setopt(pycurl.URL,localURL) c.setopt(pycurl.HTTPHEADER,['Content-Type: application/json','Content-Length: '+str(len(jsonData))]) c.setopt(c.VERBOSE, True) c.setopt(pycurl.CUSTOMREQUEST,retPost) c.setopt(pycurl.POSTFIELDS,jsonData) c.setopt(c.WRITEFUNCTION,buf.write) c.setopt(pycurl.USERPWD,getConfig('allowedUser1','UserName','str')+':'+getConfig('allowedUser1','Password','str')) c.perform() #TODO: how to show succes code? 200 or OK? http_code = c.getinfo(pycurl.HTTP_CODE) #judge post success. if http_code != 200: return None logger.debug(buf.getvalue()) retStr = buf.getvalue() buf.close() c.close() logger.debug("RacorderQuestionContact success.") return retStr except pycurl.error, error: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() errno, errstr = error print 'An error occurred: ', errstr
def getiRecorderScoreByFileName(self,filename): try: logger = getLogger() logger.debug("start iRecorderScoreModuleObj.getiRecorderScoreByFileName") conn = msSqlConnect() cur = conn.cursor() sqlstr = "SELECT [RECKEY]"\ ",[RATERS]"\ ",[TOTAL]"\ ",[UPDT]"\ ",[REMARK]"\ ",[SCRVALS]"\ ",[SCRVAL0]"\ ",[SCRVAL1]"\ ",[SCRVAL2]"\ ",[SCRVAL3]"\ ",[SCRVAL4]"\ ",[SCRVAL5]"\ ",[SCRVAL6]"\ ",[SCRVAL7]"\ ",[SCRVAL8]"\ ",[SCRVAL9]"\ ",[SCRVAL10]"\ ",[SCRVAL11]"\ ",[SCRVAL12]"\ ",[SCRVAL13]"\ ",[SCRVAL14]"\ ",[SCRVAL15]"\ " FROM [TRQ_SCORE]"\ " WHERE [TRQ_SCORE].[RECKEY] = %s" cur.execute(sqlstr,filename) row = cur.fetchone() logger.info("sql:"+str(sqlstr)+"\n filename:"+str(filename)) if row: return row else: return 'No data.' except Exception,ex: if logger is not None: logger.error("exception occur, see the traceback.log") if sqlstr is not None: logger.error("sql:"+str(sqlstr)+"\n filename:"+str(filename)) #异常写入日志文件. f = open('Logs/traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() return ex.message
def checkUserAuth(inWeb): logger = getLogger() auth = inWeb.ctx.env.get('HTTP_AUTHORIZATION') authreq = False if auth is None: authreq = True else: auth = re.sub('^Basic ','',auth) username,password = base64.decodestring(auth).split(':') if (username,password) in allowed: logger.debug("has right HTTP_AUTHORIZATION") pass else: authreq = True return authreq
def getStaticLst(inTid): try: logger = getLogger() logger.debug("start GET static list.") if inTid is None: return None if inTid == '': return None buf = cStringIO.StringIO() #define in function. c = pycurl.Curl() localURL = getConfig('RESTService','staticLstUrl','str') localURL = localURL + inTid localURL = str(localURL) c.setopt(pycurl.URL,localURL) c.setopt(c.WRITEFUNCTION,buf.write) c.setopt(c.VERBOSE, True) c.setopt(pycurl.USERPWD,getConfig('allowedUser1','UserName','str')+':'+getConfig('allowedUser1','Password','str')) c.perform() http_code = c.getinfo(pycurl.HTTP_CODE) #judge get success. if http_code != 200: return None #get the data from json. localStaticLst = json.loads(buf.getvalue()) buf.close() c.close() logger.debug("get static List success.") return localStaticLst except pycurl.error, error: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() errno, errstr = error print 'An error occurred: ', errstr
def putiRecorderScoreByJson(self,scoreDic): try: logger = getLogger() logger.debug("start iRecorderScoreModuleObj.putiRecorderScoreByJson") conn = msSqlConnectutf() cur = conn.cursor() sqlstr = "UPDATE [TRQ_SCORE]"\ " SET"\ "[RATERS] = '"+scoreDic['RATERS']+"'"\ ",[TOTAL] = '"+scoreDic['TOTAL']+"'"\ ",[UPDT] = CONVERT(varchar(32), GETDATE(), 20)"\ ",[REMARK] = '"+scoreDic['REMARK']+"'"\ ",[SCRVALS] ='"+scoreDic['SCRVALS']+"'"\ ",[SCRVAL0] ='"+scoreDic['SCRVAL0']+"'"\ ",[SCRVAL1] ='"+scoreDic['SCRVAL1']+"'"\ ",[SCRVAL2] ='"+scoreDic['SCRVAL2']+"'"\ ",[SCRVAL3] ='"+scoreDic['SCRVAL3']+"'"\ ",[SCRVAL4] ='"+scoreDic['SCRVAL4']+"'"\ ",[SCRVAL5] ='"+scoreDic['SCRVAL5']+"'"\ ",[SCRVAL6] ='"+scoreDic['SCRVAL6']+"'"\ ",[SCRVAL7] ='"+scoreDic['SCRVAL7']+"'"\ ",[SCRVAL8] ='"+scoreDic['SCRVAL8']+"'"\ ",[SCRVAL9] ='"+scoreDic['SCRVAL9']+"'"\ ",[SCRVAL10] ='"+scoreDic['SCRVAL10']+"'"\ ",[SCRVAL11] ='"+scoreDic['SCRVAL11']+"'"\ ",[SCRVAL12] ='"+scoreDic['SCRVAL12']+"'"\ ",[SCRVAL13] ='"+scoreDic['SCRVAL13']+"'"\ ",[SCRVAL14] ='"+scoreDic['SCRVAL14']+"'"\ ",[SCRVAL15] ='"+scoreDic['SCRVAL15']+"'"\ "WHERE [RECKEY] = '"+scoreDic['RECKEY']+"'" cur.execute(sqlstr) conn.commit() logger.info("sql:"+str(sqlstr)) return scoreDic['RECKEY'] except Exception,ex: if logger is not None: logger.error("exception occur, see the traceback.log") if sqlstr is not None: logger.error("sql:"+str(sqlstr)) #异常写入日志文件. f = open('Logs/traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() return ex.message
def zipOrderInfoOrder(inOrderInfo): """update the order info according the web page show.post the data. so we need pull all data in form ,make them zip to post in the page. 2017.10.30. 这个函数感觉有点多余啊。 """ try: logger = getLogger() logger.debug("start zip Order Info .") if inOrderInfo is None: return None # we only get the message we needed: #change the flat to list data. localOrderInfo = inOrderInfo localCrdt = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) #PolicyHolder_Usr 投保人 configPageUsing = configPage['PolicyHolder_Usr'] item = {} addItemDictValue(item, 'NAME', localOrderInfo, configPageUsing['name']['dataName']) addItemDictValue(item, 'SEX', localOrderInfo, configPageUsing['sex']['dataName']) addItemDictValue(item, 'BIRTHDAY', localOrderInfo, configPageUsing['birthday']['dataName']) addItemDictValue(item, 'AGE', localOrderInfo, configPageUsing['age']['dataName']) addItemDictValue(item, 'PROFESSION', localOrderInfo, configPageUsing['profession']['dataName']) addItemDictValue(item, 'PHONE', localOrderInfo, configPageUsing['phone']['dataName']) addItemDictValue(item, 'IDCARDTYPE', localOrderInfo, configPageUsing['idcardtype']['dataName']) addItemDictValue(item, 'IDCARDNO', localOrderInfo, configPageUsing['idcardno']['dataName']) addItemDictValue(item, 'HEIGHT', localOrderInfo, configPageUsing['height']['dataName']) addItemDictValue(item, 'WEIGHT', localOrderInfo, configPageUsing['weight']['dataName']) addItemDictValue( item, 'PROVINCE', localOrderInfo, configPageUsing['briefAddress']['select']['select1']['inDataName']) addItemDictValue( item, 'CITY', localOrderInfo, configPageUsing['briefAddress']['select']['select2']['inDataName']) addItemDictValue( item, 'AREA', localOrderInfo, configPageUsing['briefAddress']['select']['select3']['inDataName']) addItemDictValue(item, 'ADDRESS', localOrderInfo, configPageUsing['detailAddress']['dataName']) addItemDictValue(item, 'ZIPCODE', localOrderInfo, configPageUsing['postcode']['dataName']) #创建人和创建时间 upDict = {'CRUSR': inOrderInfo['CRUSR']} item.update(upDict) upDict = {'CRDT': localCrdt} item.update(upDict) upDict = {'POLICYHOLDER_USR': item} localOrderInfo.update(upDict) #InsurantUsr 被保人 #a loop for multi data #total save 4 Insurant, the 4 Insurant DIV saved in html file. #only save used Insurant. if 'INSURANT_USR_NAMEA' in localOrderInfo: configDict = {0: 'InsurantUsr', 1: 'InsurantUsrA'} else: configDict = {0: 'InsurantUsr'} if 'INSURANT_USR_NAMEB' in localOrderInfo: upDict = {2: 'InsurantUsrB'} configDict.update(upDict) else: pass if 'INSURANT_USR_NAMEC' in localOrderInfo: upDict = {3: 'InsurantUsrC'} configDict.update(upDict) else: pass localLst = [] #a dictionary list step = len(configDict) for i in range(step): item = {} configShowPage = configDict.get(i) configPageUsing = configPage[configShowPage] addItemDictValue(item, "BENEFICIARIESRELATION", localOrderInfo, configPageUsing['relation']['dataName']) addItemDictValue(item, "NAME", localOrderInfo, configPageUsing['name']['dataName']) addItemDictValue(item, "SEX", localOrderInfo, configPageUsing['sex']['dataName']) addItemDictValue(item, "BIRTHDAY", localOrderInfo, configPageUsing['birthday']['dataName']) addItemDictValue(item, "AGE", localOrderInfo, configPageUsing['age']['dataName']) addItemDictValue(item, "PROFESSION", localOrderInfo, configPageUsing['profession']['dataName']) addItemDictValue(item, "PHONE", localOrderInfo, configPageUsing['phone']['dataName']) addItemDictValue(item, "IDCARDTYPE", localOrderInfo, configPageUsing['idcardtype']['dataName']) addItemDictValue(item, "IDCARDNO", localOrderInfo, configPageUsing['idcardno']['dataName']) addItemDictValue(item, "HEIGHT", localOrderInfo, configPageUsing['height']['dataName']) addItemDictValue(item, "WEIGHT", localOrderInfo, configPageUsing['weight']['dataName']) addItemDictValue( item, 'PROVINCE', localOrderInfo, configPageUsing['briefAddress']['select']['select1'] ['inDataName']) addItemDictValue( item, 'CITY', localOrderInfo, configPageUsing['briefAddress'] ['select']['select2']['inDataName']) addItemDictValue( item, 'AREA', localOrderInfo, configPageUsing['briefAddress'] ['select']['select3']['inDataName']) addItemDictValue(item, "ADDRESS", localOrderInfo, configPageUsing['detailAddress']['dataName']) addItemDictValue(item, "ZIPCODE", localOrderInfo, configPageUsing['postcode']['dataName']) #创建人和创建时间 upDict = {'CRUSR': inOrderInfo['CRUSR']} item.update(upDict) upDict = {'CRDT': localCrdt} item.update(upDict) localLst.append(item) upDict = {'LstINSURANT_USR': localLst} localOrderInfo.update(upDict) #Lstbeneficiaries 受益人 #a loop for multi data #only show 1 BeneficiaryUsr #TODO: every time ,save 1 data? if 'Lstbeneficiaries_NAME' in localOrderInfo: configDict = {0: 'BeneficiaryUsr'} else: configDict = {} localLst = [] #a dictionary list step = len(configDict) #TODO: how to dynamic in page?多个受益人还没有实现,参考多个被保人. for i in range(step): item = {} configShowPage = configDict.get(i) configPageUsing = configPage[configShowPage] addItemDictValue(item, "BENEFICIARIESRELATION", localOrderInfo, configPageUsing['relation']['dataName']) addItemDictValue(item, "NAME", localOrderInfo, configPageUsing['name']['dataName']) addItemDictValue(item, "SEX", localOrderInfo, configPageUsing['sex']['dataName']) addItemDictValue(item, "BIRTHDAY", localOrderInfo, configPageUsing['birthday']['dataName']) addItemDictValue(item, "AGE", localOrderInfo, configPageUsing['age']['dataName']) addItemDictValue(item, "PHONE", localOrderInfo, configPageUsing['phone']['dataName']) addItemDictValue(item, "IDCARDTYPE", localOrderInfo, configPageUsing['idcardtype']['dataName']) addItemDictValue(item, "IDCARDNO", localOrderInfo, configPageUsing['idcardno']['dataName']) #创建人和创建时间 upDict = {'CRUSR': inOrderInfo['CRUSR']} item.update(upDict) upDict = {'CRDT': localCrdt} item.update(upDict) localLst.append(item) upDict = {'Lstbeneficiaries': localLst} localOrderInfo.update(upDict) #InsurantPlan 保险计划 configPageUsing = configPage['InsurantPlan'] item = localOrderInfo addItemDictValue(item, 'INSURANCECODE', localOrderInfo, configPageUsing['product']['dataName']) addItemDictValue(item, 'SECURITYPLAN', localOrderInfo, configPageUsing['plan']['dataName']) addItemDictValue(item, 'PREMIUMPLAN', localOrderInfo, configPageUsing['planFamily']['dataName']) addItemDictValue(item, 'PAYMENTSTATUS', localOrderInfo, configPageUsing['paymentstatus']['dataName']) addItemDictValue(item, 'DMPAYMODE', localOrderInfo, configPageUsing['dmpaymode']['dataName']) addItemDictValue(item, 'DMPAYBANK', localOrderInfo, configPageUsing['paybank']['dataName']) addItemDictValue(item, 'CARDID', localOrderInfo, configPageUsing['cardid']['dataName']) #TODO: right 续期帐号 addItemDictValue(item, 'DMPAYCOMPANY', localOrderInfo, configPageUsing['dmpaybankext']['dataName']) addItemDictValue(item, 'PURCHASECOUNT', localOrderInfo, configPageUsing['purchasecount']['dataName']) addItemDictValue(item, 'DMCONTINUATIONYEARS', localOrderInfo, configPageUsing['dmcontinuationyears']['dataName']) addItemDictValue(item, 'DMPAYTYPE', localOrderInfo, configPageUsing['dmpaytype']['dataName']) addItemDictValue(item, 'DMPOLICYDATES', localOrderInfo, configPageUsing['dmpolicydates']['dataName']) addItemDictValue(item, 'NOTE', localOrderInfo, configPageUsing['note']['dataName']) #delivery 保单配送 configPageUsing = configPage['delivery'] item = localOrderInfo addItemDictValue(item, 'DELIVERYDATE', localOrderInfo, configPageUsing['dateTime']['dataName']) addItemDictValue( item, 'PROVINCE', localOrderInfo, configPageUsing['deliveryAddress']['select']['select1'] ['inDataName']) addItemDictValue( item, 'CITY', localOrderInfo, configPageUsing['deliveryAddress'] ['select']['select2']['inDataName']) addItemDictValue( item, 'AREA', localOrderInfo, configPageUsing['deliveryAddress'] ['select']['select3']['inDataName']) addItemDictValue(item, 'DELIVERYADDRESS', localOrderInfo, configPageUsing['detailAddress']['dataName']) logger.debug("update localOrderInfo success.") return localOrderInfo except: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt', 'a') traceback.print_exc() traceback.print_exc(file=f) f.flush() f.close() else: pass finally: pass
def flatThirdEvalInfo(inThirdEvalInfo): """update the third eval info according the web page show.show the data. so we need pull all data in list ,make them flat to show in the page.so in the page, the show will be easy. TODO: in future, we need create the function according the config data.2017.10.30. 这个函数感觉也有点多余,要简化. """ logger = getLogger() try: logger.debug("start flat third eval Info .") if inThirdEvalInfo is None: return None # we only get the message we needed: #change the list to flat data. localThirdEvalInfo = inThirdEvalInfo #basic_page 基本信息 configPageUsing = configPage['basic_page'] item = localThirdEvalInfo["basic"] addDictItemValue(item, 'BASIC_NAME', localThirdEvalInfo, configPageUsing['name']['dataName']) addDictItemValue(item, 'BASIC_SEX', localThirdEvalInfo, configPageUsing['sex']['dataName']) #third_page 第三方评估 configPageUsing = configPage['third_page'] item = localThirdEvalInfo["third"] addDictItemValue(item, 'NORMAL_ADL', localThirdEvalInfo, configPageUsing['normal_adl']['dataName']) addDictItemValue(item, 'NORMAL_IADL', localThirdEvalInfo, configPageUsing['normal_iadl']['dataName']) addDictItemValue(item, 'NORMAL_RECOGNIZE', localThirdEvalInfo, configPageUsing['normal_recognize']['dataName']) addDictItemValue(item, 'THIRDEVAL_CLASS', localThirdEvalInfo, configPageUsing['thirdeval_class']['dataName']) #leer_page 乐尔之家评估 configPageUsing = configPage['leer_page'] item = localThirdEvalInfo["leer"] addDictItemValue(item, "LEER_NORMAL_ADL", localThirdEvalInfo, configPageUsing['normal_adl']['dataName']) addDictItemValue(item, "LEER_SPIRIT_DEPRESS", localThirdEvalInfo, configPageUsing['spirit_depress']['dataName']) addDictItemValue(item, "LEER_FEEL_SOUL", localThirdEvalInfo, configPageUsing['feel_soul']['dataName']) addDictItemValue(item, "LEER_CLASS", localThirdEvalInfo, configPageUsing['leer_class']['dataName']) logger.debug("update localOrderInfo success.") return localThirdEvalInfo except: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt', 'a') traceback.print_exc() traceback.print_exc(file=f) f.flush() f.close() finally: pass
def putOrderStatusInfoContact(inOrderid, inStatus, storageData, inCrusr): try: logger = getLogger() logger.debug("start PUT Order Status Info according contact id.") jsonData = json.dumps(storageData) dictData = json.loads(jsonData) #update status updateDictSingleValue(dictData, "STATUS", inStatus) #add orderid updateDictSingleValue(dictData, "ORDERID", inOrderid) #add crusr updateDictSingleValue(dictData, "CRUSR", inCrusr) dictData = zipOrderInfoOrder(dictData) jsonData = json.dumps(dictData) buf = cStringIO.StringIO() c = pycurl.Curl() localURL = getConfig('RESTService', 'orderInfoUrl', 'str') localURL = str(localURL) c.setopt(pycurl.URL, localURL) c.setopt(pycurl.HTTPHEADER, [ 'Content-Type: application/json', 'Content-Length: ' + str(len(jsonData)) ]) c.setopt(c.VERBOSE, True) c.setopt(pycurl.CUSTOMREQUEST, "PUT") c.setopt(pycurl.POSTFIELDS, jsonData) c.setopt(c.WRITEFUNCTION, buf.write) c.setopt( pycurl.USERPWD, getConfig('allowedUser1', 'UserName', 'str') + ':' + getConfig('allowedUser1', 'Password', 'str')) c.perform() #TODO: how to show succes code? 200 or OK? http_code = c.getinfo(pycurl.HTTP_CODE) #judge put success. if http_code != 201: return None logger.debug(buf.getvalue()) retStr = buf.getvalue() buf.close() c.close() logger.debug("put OrderInfo success.") return retStr except pycurl.error, error: logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt', 'a') traceback.print_exc() traceback.print_exc(file=f) f.flush() f.close() errno, errstr = error print 'An error occurred: ', errstr
def getThirdEvalInfoLst(inOrderid,inPageIndex): logger = getLogger() try: logger.debug("start GET ThirdEval Info according query condition.") localURL = '' #from db to get the data. import web import sqlite3 dbSqlite = web.database(dbn='sqlite',db='thirdeval.s3db') if inOrderid is None: results = dbSqlite.select('thirdeval_detail') inOrderid = '' for item in results: localThirdEvalInfoLst = {"ThirdEvalInfoLst":[{'orderid':item['id'], 'name':item['basic_name'], 'normal_adl':item['third_normal_adl'], 'thirdeval_class':item['thirdeval_class'], 'leer_normal_adl':item['leer_normal_adl'], 'leer_class':item['leer_class']}], "PageManager":{ "DataCount":5, "PageSize":5, "PageCount":1, "PageIndex":1, } } if inOrderid != '': myvar = dict(id=inOrderid) results = dbSqlite.select('thirdeval_detail', myvar, where="id = $id") for item in results: localThirdEvalInfoLst = {"ThirdEvalInfoLst":[{'orderid':inOrderid, 'name':item['basic_name'], 'normal_adl':item['third_normal_adl'], 'thirdeval_class':item['thirdeval_class'], 'leer_normal_adl':item['leer_normal_adl'], 'leer_class':item['leer_class']}], "PageManager":{ "DataCount":5, "PageSize":5, "PageCount":1, "PageIndex":1, } } logger.debug("get localThirdEvalInfoLst List success.") return localThirdEvalInfoLst except : logger.error("exception occur, see the traceback.log") #异常写入日志文件. f = open('traceback.txt','a') traceback.print_exc() traceback.print_exc(file = f) f.flush() f.close() finally: pass