Subversion Repositories SmartDukaan

Rev

Rev 23265 | Rev 23267 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23265 Rev 23266
Line 374... Line 374...
374
            root = fromstring(responseString)
374
            root = fromstring(responseString)
375
            print root.tag
375
            print root.tag
376
            awbs = []
376
            awbs = []
377
            for awbEle in root:
377
            for awbEle in root:
378
                
378
                
379
                awbNumber = __findElementByAttr(awbEle, 'name', 'awb_number').text.strip()
379
                awbNumber = __findElementByAttr(awbEle, 'name', 'awb_number').text  
380
                reasonCode = __findElementByAttr(awbEle, 'name', 'reason_code_number').text.strip()
380
                reasonCode = __findElementByAttr(awbEle, 'name', 'reason_code_number').text
381
                deliveryDate =  __findElementByAttr(awbEle, 'name', 'delivery_date').text
381
                deliveryDate =  __findElementByAttr(awbEle, 'name', 'delivery_date').text
382
                lastUpdateDate = __findElementByAttr(awbEle, 'name', 'last_update_date').text.strip()
382
                lastUpdateDate = __findElementByAttr(awbEle, 'name', 'last_update_date').text
383
                xmlScans = __findElementByAttr(awbEle, 'name', 'scans')
383
                xmlScans = __findElementByAttr(awbEle, 'name', 'scans')
384
                awbStatuses[awbNumber] = {'awbNumber': awbNumber, 'reasonCode': reasonCode, 'deliveryDate':deliveryDate, 'lastUpdateDate':lastUpdateDate, 'xmlScans': xmlScans}
384
                awbStatuses[awbNumber] = {'awbNumber': awbNumber, 'reasonCode': reasonCode, 'deliveryDate':deliveryDate, 'lastUpdateDate':lastUpdateDate, 'xmlScans': xmlScans}
385
            
385
            
386
        doneAwbs += batchSize
386
        doneAwbs += batchSize
387
        print awbStatuses
387
        print awbStatuses
Line 402... Line 402...
402
    print "xmlScansTag", xmlScans.text
402
    print "xmlScansTag", xmlScans.text
403
    awbStatusObj = None
403
    awbStatusObj = None
404
    for xmlScan in xmlScans:
404
    for xmlScan in xmlScans:
405
        print "xmlScanText", xmlScan.text
405
        print "xmlScanText", xmlScan.text
406
        print "xmlScanTag", xmlScan.tag
406
        print "xmlScanTag", xmlScan.tag
407
        reasonCodeNumber = __findElementByAttr(xmlScan, 'name', 'reason_code_number').text.strip()
407
        reasonCodeNumber = __findElementByAttr(xmlScan, 'name', 'reason_code_number').text
408
        if reasonCodeNumber in codes:
408
        if reasonCodeNumber in codes:
409
            statusDescription = __findElementByAttr(xmlScan, 'name', 'status').text.strip()
409
            statusDescription = __findElementByAttr(xmlScan, 'name', 'status').text
410
            statusDate = get_py_datetime(__findElementByAttr(xmlScan, 'name', 'updated_on').text.strip())
410
            statusDate = get_py_datetime(__findElementByAttr(xmlScan, 'name', 'updated_on').text)
411
            awbStatusObj = __AWBStatusObj(None, reasonCodeNumber, statusDescription, statusDate)
411
            awbStatusObj = __AWBStatusObj(None, reasonCodeNumber, statusDescription, statusDate)
412
            print awbStatusObj
412
            print awbStatusObj
413
    return awbStatusObj
413
    return awbStatusObj
414
 
414
 
415
def __findElementByAttr(xmlElement, name, value=None):
415
def __findElementByAttr(xmlElement, name, value=None):
Line 665... Line 665...
665
    except:
665
    except:
666
        print "Some issue while closing crm tickets for orders in DELIVERY_SUCCESS status"
666
        print "Some issue while closing crm tickets for orders in DELIVERY_SUCCESS status"
667
        traceback.print_exc()
667
        traceback.print_exc()
668
 
668
 
669
def get_py_datetime(time_string):
669
def get_py_datetime(time_string):
-
 
670
    if time_string is None:
-
 
671
        return None
-
 
672
    time_string = time_string.strip()
670
    # This should be a command line argument.
673
    # This should be a command line argument.
671
    # Refer http://docs.python.org/library/time.html#time.strftime to
674
    # Refer http://docs.python.org/library/time.html#time.strftime to
672
    # get a complete list of format specifiers available for date time.
675
    # get a complete list of format specifiers available for date time.
673
    time_format = "%d %b, %Y, %H:%M"
676
    time_format = "%d %b, %Y, %H:%M"
674
    if time_string == '':
677
    if time_string == '':
675
        return None
678
        return None
676
    return datetime.datetime.strptime(time_string, time_format)
679
    return datetime.datetime.strptime(time_string, time_format)
677
 
680
 
678
def get_py_date(time_string):
681
def get_py_date(time_string):
-
 
682
    if time_string is None:
-
 
683
        return None
-
 
684
    time_string = time_string.strip()
679
    # This should be a command line argument.
685
    # This should be a command line argument.
680
    # Refer http://docs.python.org/library/time.html#time.strftime to
686
    # Refer http://docs.python.org/library/time.html#time.strftime to
681
    # get a complete list of format specifiers available for date time.
687
    # get a complete list of format specifiers available for date time.
682
    time_format = "%d-%b-%Y"
688
    time_format = "%d-%b-%Y"
683
    if time_string == '':
689
    if time_string == '':