Subversion Repositories SmartDukaan

Rev

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

Rev 14466 Rev 14545
Line 67... Line 67...
67
                merchantOrder = Order(orderId, userId, subTagId, self.store_id, orderSuccessUrl)
67
                merchantOrder = Order(orderId, userId, subTagId, self.store_id, orderSuccessUrl)
68
                soup = BeautifulSoup(rawHtml)
68
                soup = BeautifulSoup(rawHtml)
69
                try:
69
                try:
70
                    self.parseOldStlye(merchantOrder, soup)
70
                    self.parseOldStlye(merchantOrder, soup)
71
                except:
71
                except:
-
 
72
                    try:
72
                    self.parseNewStlye(merchantOrder, soup)
73
                        self.parseNewStlye(merchantOrder, soup)
-
 
74
                    except:
-
 
75
                        self.parseCancelled(merchantOrder, soup)
73
                resp['result'] = 'ORDER_CREATED'
76
                resp['result'] = 'ORDER_CREATED'
74
                return resp    
77
                return resp    
75
            except:
78
            except:
76
                print "Error occurred"
79
                print "Error occurred"
77
                traceback.print_exc()
80
                traceback.print_exc()
Line 227... Line 230...
227
                subOrder.cashBackAmount = cashbackAmount
230
                subOrder.cashBackAmount = cashbackAmount
228
                if percentage > 0:
231
                if percentage > 0:
229
                    subOrder.cashBackPercentage = percentage
232
                    subOrder.cashBackPercentage = percentage
230
                subOrders.append(subOrder)
233
                subOrders.append(subOrder)
231
        self._updateToOrder(todict(merchantOrder))
234
        self._updateToOrder(todict(merchantOrder))
-
 
235
        
-
 
236
    def parseCancelled(self, merchantOrder,soup):
-
 
237
        fonts = soup.body.findAll("table", recursive=False)[1].findAll("font")
-
 
238
        if fonts[0].text == "Important Message":
-
 
239
            if fonts[1].text=="This order has been cancelled.":
-
 
240
                merchantOrder.closed = True
-
 
241
                merchantOrder.status = "Cancelled"
-
 
242
                merchantOrder.requireDetail = False
-
 
243
                self._updateToOrder(todict(merchantOrder))
-
 
244
            else:
-
 
245
                raise ParseException("parseCancelled", "Found detailed status" + fonts[1].text)
232
 
246
 
233
    def getTrackingUrls(self, userId):
247
    def getTrackingUrls(self, userId):
234
        
248
        
235
        missingOrderUrls = []
249
        missingOrderUrls = []
236
        missingOrders = self._getMissingOrders({'userId':userId})
250
        missingOrders = self._getMissingOrders({'userId':userId})
Line 356... Line 370...
356
 
370
 
357
 
371
 
358
def main():
372
def main():
359
    store = getStore(1)
373
    store = getStore(1)
360
    #store.scrapeStoreOrders()    
374
    #store.scrapeStoreOrders()    
361
    store.parseOrderRawHtml(1, 'saad', '21232211', readSSh('/tmp/1.html'), 'https://www.amazon.in/gp/css/summary/edit.html?orderID=12212')
375
    store.parseOrderRawHtml(1, 'saad', '21232211', readSSh('/home/amit/Downloads/710.html'), 'https://www.amazon.in/gp/css/summary/edit.html?orderID=12212')
362
    #store.trackOrdersForUser(8,'https://www.amazon.in/gp/css/order-history', readSSh('/tmp/User2/2015-03-03 00:29:40.165513'))
376
    #store.trackOrdersForUser(8,'https://www.amazon.in/gp/css/order-history', readSSh('/tmp/User2/2015-03-03 00:29:40.165513'))
363
    #readSSh('snapdeal.csv')
377
    #readSSh('snapdeal.csv')
364
def readSSh(fileName):
378
def readSSh(fileName):
365
    try:
379
    try:
366
            str1 = open(fileName).read()
380
            str1 = open(fileName).read()