Subversion Repositories SmartDukaan

Rev

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

Rev 18037 Rev 18038
Line 365... Line 365...
365
            subOrder.trackingNumber = trackingDet.span.a.text.strip()
365
            subOrder.trackingNumber = trackingDet.span.a.text.strip()
366
 
366
 
367
        subOrders.append(subOrder)
367
        subOrders.append(subOrder)
368
        return subOrder
368
        return subOrder
369
    
369
    
370
    def getOrderJSON(self, rawHtml, supcMap):
370
    def getOrderJSON(self, pq, supcMap):
371
        #print rawHtml
371
        #print rawHtml
372
#        replace_with = {
372
#        replace_with = {
373
#        '<': '&gt;',
373
#        '<': '&gt;',
374
#        '>': '&lt;',
374
#        '>': '&lt;',
375
#        '&': '&amp;',
375
#        '&': '&amp;',
376
#        '"': '&quot;', # should be escaped in attributes
376
#        '"': '&quot;', # should be escaped in attributes
377
#        "'": '&apos;'    # should be escaped in attributes
377
#        "'": '&apos;'    # should be escaped in attributes
378
#        }
378
#        }
379
        pq = PyQuery(rawHtml)
-
 
380
        jsonValue = pq("#orderJSON").attr("value")
379
        jsonValue = pq("#orderJSON").attr("value")
381
        jsonValue.replace("&quot;", '"')
380
        jsonValue.replace("&quot;", '"')
382
        jsonValue.replace("&amp;", '&')
381
        jsonValue.replace("&amp;", '&')
383
        jsonValue.replace("&gt;", '>')
382
        jsonValue.replace("&gt;", '>')
384
        jsonValue.replace("&lt;", '<')
383
        jsonValue.replace("&lt;", '<')
Line 410... Line 409...
410
        if self.db.merchantOrder.find_one({"merchantOrderId":moId}):
409
        if self.db.merchantOrder.find_one({"merchantOrderId":moId}):
411
            resp['result'] = 'ORDER_ALREDY_CREATED_IGNORED'
410
            resp['result'] = 'ORDER_ALREDY_CREATED_IGNORED'
412
            return resp
411
            return resp
413
        supcMap = {}
412
        supcMap = {}
414
        try:
413
        try:
-
 
414
            pq = PyQuery(rawHtml)
415
            try:
415
            try:
-
 
416
                if pq("title").text()=="Webpage not available":
-
 
417
                    raise                
416
                orderJSON = self.getOrderJSON(rawHtml, supcMap)
418
                orderJSON = self.getOrderJSON(pq, supcMap)
417
            except:
419
            except:
418
                traceback.print_exc()
-
 
419
                try:
-
 
420
                    page = fetchResponseUsingProxy(orderSuccessUrl)
-
 
421
                    orderJSON = self.getOrderJSON(page,supcMap)
420
                resp['result'] = 'ORDER_NOT_CREATED_KNOWN'
422
                except:
421
                return resp
423
                    traceback.print_exc()
-
 
424
                    orderJSON = None
-
 
425
            if orderJSON is None:
-
 
426
                page =fetchResponseUsingProxy(url)
422
                '''page =fetchResponseUsingProxy(url)
427
                try:
423
                try:
428
                    merchantOrder = self._parseB(orderId, subTagId, userId, page, orderSuccessUrl)
424
                    merchantOrder = self._parseB(orderId, subTagId, userId, page, orderSuccessUrl)
429
                except:
425
                except:
430
                    traceback.print_exc()
426
                    traceback.print_exc()
431
                    merchantOrder = self._parse(orderId, subTagId, userId, page, orderSuccessUrl)
427
                    merchantOrder = self._parse(orderId, subTagId, userId, page, orderSuccessUrl)'''
432
            else:
-
 
-
 
428
 
433
                merchantOrder = self._parseC(orderId, subTagId, userId, supcMap, orderJSON, orderSuccessUrl)
429
            merchantOrder = self._parseC(orderId, subTagId, userId, supcMap, orderJSON, orderSuccessUrl)
434
            
-
 
435
            merchantOrder.orderTrackingUrl = url
430
            merchantOrder.orderTrackingUrl = url
436
               
431
               
437
            if self._saveToOrder(todict(merchantOrder)):
432
            if self._saveToOrder(todict(merchantOrder)):
438
                resp['result'] = 'ORDER_CREATED'
433
                resp['result'] = 'ORDER_CREATED'
439
            else:
434
            else: