Exemple #1
0
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
Exemple #2
0
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"
Exemple #3
0
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
Exemple #4
0
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
Exemple #5
0
def getOrderProductInfoLst(insurancecodeid,securityplanid,premiumplanid,ageplan):
    try:
        logger = getLogger()
        logger.debug("start GET Order Product Info.")

        buf = cStringIO.StringIO() #define in function.
        c = pycurl.Curl()
        #TODO: how to disable the age.
        if (ageplan != 'null') & (ageplan is not None):
            localURL = getConfig('RESTService','orderProductInfourl','str')+'?INSURANCECODE='+insurancecodeid+"&SECURITYPLAN="+securityplanid+"&PREMIUMPLAN="+premiumplanid+"&AGEPLAN="+ageplan
        else:
            localURL = getConfig('RESTService','orderProductInfourl','str')+'?INSURANCECODE='+insurancecodeid+"&SECURITYPLAN="+securityplanid+"&PREMIUMPLAN="+premiumplanid
        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.
        localOrderInfoLst = json.loads(buf.getvalue())
        buf.close()
        c.close()

        logger.debug("get localOrder Product Info List success.")

        return localOrderInfoLst
    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 getOrderTrans(inOrderid):
    try:
        buf = cStringIO.StringIO() #define in function.
        c = pycurl.Curl()
        localURL = getConfig('RESTService','transUrl','str')+inOrderid
        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()

        #get the data from json.
        localOrderInfo = json.loads(buf.getvalue())
        buf.close()

        return localOrderInfo

    except pycurl.error, error:
        errno, errstr = error
        print 'An error occurred: ', errstr
def deliverySend(orderid,title,mailid):
    try:
        logger = getLogger()
        logger.debug("start deliverySend")
        """send the mail id using the api"""
        # build the dict for the mail id.
        data = dict({
            'user':getConfig('soapWebservice','UserName','str'),
            'pass':getConfig('soapWebservice','Password','str'),
            'order_id':orderid,
            'title':title,
            'track_id':mailid,
            })
        jsonData = json.dumps(data)
        url = getConfig('soapWebservice','url','str')
        #无法直接连接,因为不同的soap标准,所以要加上配置参数
        #c = Client(url)
        c = Client(url,doctor=ImportDoctor(Import(getConfig('soapWebservice','soapencoding','str'))))
        sid = c.service.login(getConfig('soapWebservice','UserName','str'), getConfig('soapWebservice','Password','str'))
        #result = c.service.sales_order_shipment.deliverySend(data)
        result = c.service.call(sid,getConfig('soapWebservice','serviceName','str'),jsonData)

        jsonResults = json.loads(result)
        returnStatus = jsonResults['status']

        logger.debug('returnStatus is :'+returnStatus)

        if (returnStatus == '5'):
            logger.debug('deliverySend 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()
    else:
        pass
    finally:
        pass
        return returnStatus
def DbConnect():
    db = web.database(dbn=getConfig('db','dbname','str'),db=getConfig('db','dbservice','str'),user=getConfig('db','dbuser','str'),pw=getConfig('db','dbpwd','str'))
    return db
def saveData2Db(inOrderInfo):
    try:
        logger = getLogger()
        logger.debug("start saveData2Db")
        ret = True
        t = None
        dbI8 = DbConnect()
        t = dbI8.transaction()

        #get sequence for con_contactId
        entries = dbI8.query('select i8.seq_con_contact.nextval from dual')
        localContactId = entries[0].NEXTVAL

        #get sysdate from oracle server
        entries = dbI8.query('select sysdate from dual')
        localCrdt = entries[0].SYSDATE

        dbI8.insert('i8.con_contact',contactid=localContactId,name=inOrderInfo["contactName"],crdt=localCrdt,crusr=inOrderInfo["crusr"],point=0,ticket=0,coupon=0)

        #get sequence for con_address
        entries = dbI8.query('select i8.seq_con_address.nextval from dual')
        localAddressId = entries[0].NEXTVAL

        dbI8.insert('i8.con_address',addressid=localAddressId,contactid=localContactId,nation='china',province=inOrderInfo["orderProvinceId"],city=inOrderInfo["orderCityId"],district=inOrderInfo["orderSpellId"],spellid=inOrderInfo["orderSpellId"],address = inOrderInfo["contactAddr"],prmadd='Y',addrtypeid='1',zip=inOrderInfo['contactPostCode'],crdt=localCrdt,crusr=inOrderInfo["crusr"])

        #get sequence for con_phone
        entries = dbI8.query('select i8.seq_con_phone.nextval from dual')
        localPhoneId = entries[0].NEXTVAL

        dbI8.insert('i8.con_phone',phoneid=localPhoneId,contactid=localContactId,phone=inOrderInfo["contactMobilePhone"],phonetypeid='1',prmphn='Y',crdt=localCrdt,crusr=inOrderInfo["crusr"])

        if (inOrderInfo["contactFixPhone"] != ''):
            #get sequence for con_phone
            entries = dbI8.query('select i8.seq_con_phone.nextval from dual')
            localPhoneId = entries[0].NEXTVAL
            dbI8.insert('i8.con_phone',phoneid=localPhoneId,contactid=localContactId,phone=inOrderInfo["contactFixPhone"],phonetypeid='2',prmphn='N',crdt=localCrdt,crusr=inOrderInfo["crusr"])

        localOrderId ="GWImp"+inOrderInfo["orderId"]

        if(inOrderInfo["orderStatus"] == 'yifu'):
            localStatus = getConfig("orderInfo","orderstatus_yifu","str")
            localOrderDetStatus = getConfig("orderDet","status_yifu","str")
        else:
            localStatus = getConfig("orderInfo","orderstatus_weifu","str")
            localOrderDetStatus = getConfig("orderDet","status_weifu","str")

        dbI8.insert('i8.con_orderhist',orderid=localOrderId,contactid=localContactId,addressid=localAddressId,paytype=getConfig("orderInfo","paytype","str"),mailtype=getConfig("orderInfo","mailtype","str"),ordertype=getConfig("orderInfo","ordertype","str"),crdt=localCrdt,crusr=inOrderInfo["crusr"],grpid='',status=localStatus,mailprice=inOrderInfo["mailPrice"],prodprice=100,discount=0,totalprice=inOrderInfo["orderPrice"],pointuse=0,couponuse=0,couponget=0,nowmoney=100,consignee=inOrderInfo["contactName"],consignphn=inOrderInfo["contactMobilePhone"])

        for localOrderDet in inOrderInfo["orderDet"]:
            #get sequence for con_orderdet
            entries = dbI8.query('select i8.seq_con_orderdet.nextval from dual')
            localOrderDetId = entries[0].NEXTVAL

            #get uprice,snapid from dic_sys_product
            myvar = dict(prodid=localOrderDet["orderProductId"])
            entries = dbI8.select('i8.dic_sys_product',myvar,what="snapid",where="prodid=$prodid")
            localProdSnapId = entries[0].SNAPID

            myvar = dict(prodid=localOrderDet["orderProductId"])
            entries = dbI8.select('i8.dic_sys_product',myvar,what="unitprice",where="prodid=$prodid")
            localProdUnitPrice = entries[0].UNITPRICE

            localDiscout = (float)(localProdUnitPrice) - (float)(localOrderDet["orderProductSalePrice"])

            dbI8.insert('i8.con_orderdet',orderdetid=localOrderDetId,orderid=localOrderId,contactid=localContactId,prodid=localOrderDet["orderProductId"],soldwith=getConfig("orderDet","soldwith","str"),status=localOrderDetStatus,uprice = localProdUnitPrice,prodnum=localOrderDet["orderProductNum"],payment=localOrderDet["orderProductSalePrice"],crdt=localCrdt,snapid=localProdSnapId,discount=localDiscout,pointget=0)

    except :
        t.rollback()
        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:
        t.commit()
        globalDefine.globalOrderInfoErrorlog = "operation success"
        pass
    finally:
        pass
        return ret
Exemple #10
0
    def POST(self,retPost):
        localwebs = web.input();
        #startdate enddate agentid totalmin totalmax rater

        startdate = str(localwebs["startdate"]);
        enddate =  str(localwebs["enddate"]);
        agentid = str(localwebs["agentid"]);
        totalmin =  str(localwebs["totalmin"]);
        totalmax = str(localwebs["totalmax"]);
        rater = str(localwebs["rater"]);

        localURL = "";
        if startdate is not None and startdate != '':
            localURL = localURL + '&startdate=' + startdate

        if enddate is not None and enddate != '':
            localURL = localURL + '&enddate=' + enddate

        if  agentid is not None and agentid != '':
            localURL = localURL + '&agentid=' + agentid

        if totalmin is not None and totalmin != '':
            localURL += '&totalmin=' + totalmin

        if totalmax is not None and totalmax != '':
            localURL += '&totalmax=' + totalmax

        if  rater is not None and rater != '':
            localURL = localURL + '&rater=' + rater

        try:
            logger = getLogger()
            logger.debug("start POST RacorderQuestionContact Info according contact id.")

            #print jsonData
            buf = cStringIO.StringIO() #define in function.
            c = pycurl.Curl()
            localURL = getConfig('RESTService','irecorderReportExportUrl','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()
            #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

            retStr = json.loads(buf.getvalue())
            #retStrData = eval(retStr);

            buf.close()
            c.close()

            logger.debug("RacorderQuestionContact success.")
            retStr = json.dumps(retStr)

            web.header('Content-Type', 'application/json')
            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
Exemple #11
0
def dbMSSqlConnect():
    db = web.database(dbn=getConfig('dbMSSql','dbname','str'),host=getConfig('dbMSSql','dbhost','str'),db=getConfig('dbMSSql','db','str'),user=getConfig('dbMSSql','dbuser','str'),pw=getConfig('dbMSSql','dbpwd','str'))
    return db
Exemple #12
0
def msSqlConnectutf():
    """
    获取pymssql的数据库连接
    """
    db = pymssql.connect(host=getConfig('dbMSSql','dbhost','str'),user=getConfig('dbMSSql','dbuser','str'),password=getConfig('dbMSSql','dbpwd','str'),database=getConfig('dbMSSql','db','str'), as_dict=True,charset='utf8')
    return db
Exemple #13
0
def GetRaccemSearchUrl(instartdate, inenddate, incalltype, inagentid, intelno, inavailablein, totalmin, intotalmax,
                       inchanneldn, inteldnis,inpageno, inpagesize,spendmin,spendmax):
    """get the order info from REST """
    try:
        logger = getLogger()
        logger.debug("start GET RaccemSearch Info ")
        localURL = ""

        if instartdate is not None and instartdate != '':
            localURL = localURL + '&startdate=' + instartdate

        if inenddate is not None and inenddate != '':
            localURL = localURL + '&enddate=' + inenddate

        if  inagentid is not None and inagentid != '':
            localURL = localURL + '&agentid=' + inagentid

        if incalltype is not None and incalltype != '':
            localURL += '&calltype=' + incalltype

        if intelno is not None and intelno != '':
            localURL += '&telno=' + intelno

        if  inavailablein is not None and inavailablein != '':
            localURL = localURL + '&available=' + inavailablein

        if totalmin is not None and totalmin != '':
            localURL = localURL + '&totalmin=' + totalmin

        if intotalmax is not None and intotalmax != '':
            localURL = localURL + '&totalmax=' + intotalmax

        if inchanneldn is not None and inchanneldn != '':
            localURL = localURL + '&channeldn=' + inchanneldn

        if inteldnis is not None and inteldnis != '':
            localURL = localURL + '&teldnis=' + inteldnis


        if inpageno is not None and inpageno != '':
            localURL = localURL + '&pageno=' + inpageno

        if inpagesize is not None and inpagesize != '':
            localURL = localURL + '&pagesize=' + inpagesize


        if spendmin is not None and spendmin != '':
            localURL = localURL + '&spendmin=' + spendmin

        if spendmax is not None and spendmax != '':
            localURL = localURL + '&spendmax=' + spendmax
        print localURL;
        buf = cStringIO.StringIO() #define in function.
        c = pycurl.Curl()
        if localURL != '':
            localURL = getConfig('RESTService', 'irecorderSearchList', 'str') + '?' + localURL
           # localURL = "http://127.0.0.1:8088/irecorderservice/irecorderlist?&pageno=1&pagesize=10"
            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()
                localRecorderSearchlist = json.loads(buf.getvalue())
            else:
                localRecorderSearchlist = None
            buf.close()
            c.close()
            logger.debug("get localOrderInfo success.")
            print localURL
        else:
            localRecorderSearchlist = None

        return localRecorderSearchlist
    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 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 DbSqliteConnect():
    db = web.database(dbn=getConfig('dbSqlite','dbname','str'),db=getConfig('dbSqlite','dbfile','str'))
    return db
Exemple #16
0
def getOrderInfoLst(inGrpid,inCrusr,inContactid,inOrderid,inStartDt,inEndDt,inOrderStatus,inPageIndex):
    try:
        logger = getLogger()
        logger.debug("start GET Order Info according query condition.")

        localURL = ''


        if inGrpid is None:
            inGrpid = ''
        if inGrpid != '':
            localURL = localURL+'&Grpid='+inGrpid

        if inCrusr is None:
            inCrusr = ''
        if inCrusr != '':
            localURL = localURL+'&Crusr='******''
        if inContactid != '':
            localURL = localURL+'&Contactid='+inContactid

        if inOrderid is None:
            inOrderid = ''
        if inOrderid != '':
            localURL = localURL+'&Orderid='+ inOrderid

        if inStartDt is None:
            inStartDt = ''
        if inStartDt != '':
            localURL = localURL+'&Scrdt='+ inStartDt

        if inEndDt is None:
            inEndDt = ''
        if inEndDt != '':
            localURL = localURL+'&Ecrdt='+ inEndDt

        if inOrderStatus  is None:
            inOrderStatus = ''
        if inOrderStatus != '':
            localURL = localURL+'&Status='+ inOrderStatus

        if inPageIndex  is None:
            inPageIndex = ''
        if inPageIndex != '':
            localURL = localURL+'&PageIndex='+ inPageIndex

        buf = cStringIO.StringIO() #define in function.
        c = pycurl.Curl()
        if localURL != '':
            #use 1=1 to use all condition.
            localURL = getConfig('RESTService','orderInfoSearchUrl','str') + '?1=1' + localURL
        else:
            localURL = getConfig('RESTService','orderInfoSearchUrl','str')
        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.
        localOrderInfoLst = json.loads(buf.getvalue())
        buf.close()
        c.close()

        logger.debug("get localOrderInfo List success.")

        return localOrderInfoLst
    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
render_html_order = lambda ret: "<html><body>ret is:%s<body></html>" % ret
render_txt_order = lambda ret: ret

render_xml_trans = lambda orderid, mailid: "<orderid>%s</orderid><mailid>%s</mailid>" % (orderid, mailid)
render_json_trans = lambda **args: json.dumps(args)
render_html_trans = lambda orderid, mailid: "<html><body>orderid is:%s<br>mailid is:%s</body></html>" % (
    orderid,
    mailid,
)
render_txt_trans = lambda orderid, mailid: orderid + mailid

urls = ("/orderTrans/(.+)", "trans", "/orderInfo/(.+)", "order")
app = web.application(urls, globals())

allowed = (
    (getConfig("allowedUser1", "UserName", "str"), getConfig("allowedUser1", "Password", "str")),
    (getConfig("allowedUser2", "UserName", "str"), getConfig("allowedUser2", "Password", "str")),
)


class trans:
    @mimerender(
        default="json", html=render_html_trans, xml=render_xml_trans, json=render_json_trans, txt=render_txt_trans
    )
    def GET(self, orderid):
        try:
            logger = getLogger()
            logger.debug("start Trans GET response")

            globalDefine.globalOrderInfoErrorlog = "No Error"
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
                pass
    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

sched.add_interval_job(job_function, seconds = getConfig('freqTimer','freqSecond','int') ,start_date= getConfig('freqTimer','starttime','str'))
sched.start()

#def job_function():
#    print "Hello World"

#sched.add_interval_job(job_function, minutes=1, start_date='2012-09-20 18:00:00')
#sched.add_interval_job(job_function, seconds=5, start_date='2012-09-20 18:00:00')
#sched.start()


#@sched.interval_schedule(seconds=5, start_date='2012-04-12 09:54:59')
#def job_function():
#    print "Hello World"

        '/login', 'Login.Login',
        '/RecSearch/(.*)', 'RecSearch.RecSelect',
        '/ReportExport/(.*)', 'RacorderClient.ReportExport',
    )

app = web.application(urls,globals(),autoreload=True)
session = web.session.Session(app,web.session.DiskStore('sessions'),
initializer={'session_grpid':'','session_usrid':'','session_loginned':'','session_pwd':''})

def session_hook():
    web.ctx.session = session

app.add_processor(web.loadhook(session_hook))

allowed = (
    (getConfig('allowedUser1','UserName','str'),getConfig('allowedUser1','Password','str')),
    (getConfig('allowedUser2','UserName','str'),getConfig('allowedUser2','Password','str'))
    )

# input_encoding and output_encoding is important for unicode
# template file. Reference:
# http://www.makotemplates.org/docs/documentation.html#unicode
render = render_mako(
        directories = ['templates'],
        input_encoding = 'utf-8',
        output_encoding = 'utf-8',
        )

# 问题页面
class rqscoscr():
        def POST(self,filename):
Exemple #21
0
# -*- coding: utf-8 -*-
"""
Created on Sun Nov  8 20:16:48 2015

@author: snoran
"""

import json
from time import time
import re
import os
import configData

configData = configData.getConfig();

def getRacistWords():
	res = [];
	with open(configData.racistWordsFile) as f :
		for line in f :
			res.append(line.strip())
	return res;
	
def getCountries() :
	res = []
	with open(configData.countryFile) as f :
		for line in f :
			res.append(line.strip())
	return res

def getLanguages() :
	res = []