| Line 78... |
Line 78... |
| 78 |
except:
|
78 |
except:
|
| 79 |
#Write all cases here for Order Not created Known
|
79 |
#Write all cases here for Order Not created Known
|
| 80 |
try:
|
80 |
try:
|
| 81 |
if not soup.body:
|
81 |
if not soup.body:
|
| 82 |
resp['result'] = 'ORDER_NOT_CREATED_KNOWN'
|
82 |
resp['result'] = 'ORDER_NOT_CREATED_KNOWN'
|
| 83 |
elif 'Securely redirecting you' in soup.h3.text.strip() or soup.h3.text.strip()=="Orders":
|
83 |
elif 'Securely redirecting you' in soup.find("h3").text.strip() or soup.find("h3").text.strip()=="Orders":
|
| 84 |
resp['result'] = 'ORDER_NOT_CREATED_KNOWN'
|
84 |
resp['result'] = 'ORDER_NOT_CREATED_KNOWN'
|
| 85 |
else:
|
85 |
else:
|
| 86 |
raise
|
86 |
raise
|
| 87 |
except:
|
87 |
except:
|
| 88 |
try:
|
88 |
try:
|
| Line 571... |
Line 571... |
| 571 |
if shippingEstimate:
|
571 |
if shippingEstimate:
|
| 572 |
updateMap['subOrders.$.estimatedShippingDate'] = shippingEstimate
|
572 |
updateMap['subOrders.$.estimatedShippingDate'] = shippingEstimate
|
| 573 |
if not closedStatus:
|
573 |
if not closedStatus:
|
| 574 |
closed = False
|
574 |
closed = False
|
| 575 |
#{"subOrders.closed":False,"subOrders.trackingUrl":{"$exists":False},"subOrders.trackAfter":{"$lt":utils.getCurrTimeStamp()}
|
575 |
#{"subOrders.closed":False,"subOrders.trackingUrl":{"$exists":False},"subOrders.trackAfter":{"$lt":utils.getCurrTimeStamp()}
|
| - |
|
576 |
updateMap['status']='success'
|
| 576 |
bulk.find(findMap).update({'$set' : updateMap})
|
577 |
bulk.find(findMap).update({'$set' : updateMap})
|
| 577 |
break
|
578 |
break
|
| 578 |
bulk.find({'orderId': activeOrder['orderId']}).update({"$set":{'closed':closed}})
|
579 |
bulk.find({'orderId': activeOrder['orderId']}).update({"$set":{'closed':closed}})
|
| 579 |
break
|
580 |
break
|
| 580 |
if not matched:
|
581 |
if not matched:
|
| Line 755... |
Line 756... |
| 755 |
# print "No summary for", userId
|
756 |
# print "No summary for", userId
|
| 756 |
# else:
|
757 |
# else:
|
| 757 |
# print userId, directory+summaryFile
|
758 |
# print userId, directory+summaryFile
|
| 758 |
# store.trackOrdersForUser(userId, 'https://www.amazon.in/gp/css/order-history', readSSh(directory + summaryFile))
|
759 |
# store.trackOrdersForUser(userId, 'https://www.amazon.in/gp/css/order-history', readSSh(directory + summaryFile))
|
| 759 |
#"storeId":1, "status":"parse_failed", "subOrders":{"$exists":False}
|
760 |
#"storeId":1, "status":"parse_failed", "subOrders":{"$exists":False}
|
| 760 |
for order in store.db.merchantOrder.find({"storeId":1, "status":"parse_failed", "subOrders":{"$exists":False}}):
|
761 |
for order in store.db.merchantOrder.find({}):
|
| 761 |
try:
|
762 |
try:
|
| 762 |
orderId=order.get("orderId")
|
763 |
orderId=order.get("orderId")
|
| 763 |
o = session.query(OrdersRaw).filter_by(id = orderId).one()
|
764 |
o = session.query(OrdersRaw).filter_by(id = orderId).one()
|
| - |
|
765 |
print orderId
|
| - |
|
766 |
if order.get("status")=="success" and o.status!='DETAIL_CREATED':
|
| - |
|
767 |
o.status='DETAIL_CREATED'
|
| - |
|
768 |
o.order_url = order.get("orderTrackingUrl")
|
| - |
|
769 |
print o.status
|
| - |
|
770 |
session.commit()
|
| - |
|
771 |
if order.get('status')=="html_required" and (o.status != 'ORDER_CREATED'):
|
| - |
|
772 |
o.status='ORDER_CREATED'
|
| - |
|
773 |
print o.status
|
| - |
|
774 |
session.commit()
|
| - |
|
775 |
if order.get('status')=="parse_failed" and (o.status != 'DETAIL_NOT_CREATED_UNKNOWN'):
|
| - |
|
776 |
o.status='DETAIL_NOT_CREATED_UNKNOWN'
|
| - |
|
777 |
print o.status
|
| - |
|
778 |
session.commit()
|
| - |
|
779 |
if order.get('status')=="cancelled" and (o.status != 'ORDER_CANCELLED'):
|
| - |
|
780 |
o.status='ORDER_CANCELLED'
|
| - |
|
781 |
print o.status
|
| - |
|
782 |
session.commit()
|
| - |
|
783 |
|
| 764 |
store.parseOrderRawHtml(o.id, o.sub_tag, o.user_id, o.rawhtml, order['orderTrackingUrl'])
|
784 |
#store.parseOrderRawHtml(o.id, o.sub_tag, o.user_id, o.rawhtml, order['orderTrackingUrl'])
|
| 765 |
except:
|
785 |
except:
|
| 766 |
print "Could not parse", orderId
|
786 |
print "Could not parse", orderId
|
| 767 |
|
787 |
|
| 768 |
#store.trackOrdersForUser(8703, 'https://www.amazon.in/gp/css/order-history', readSSh('/home/amit/Downloads/orderSummary06-10_12_15_54'))
|
788 |
#store.trackOrdersForUser(8703, 'https://www.amazon.in/gp/css/order-history', readSSh('/home/amit/Downloads/orderSummary06-10_12_15_54'))
|
| 769 |
|
789 |
|