Subversion Repositories SmartDukaan

Rev

Rev 19247 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
19247 kshitij.so 1
from dtr.utils import FetchLivePrices, AddDataToMaster
14371 kshitij.so 2
from shop2020.model.v1.dtr.impl.Convertors import to_t_livePricing
19317 kshitij.so 3
import traceback
14371 kshitij.so 4
 
5
class DtrServiceHandler:
6
    '''
7
    classdocs
8
    '''
9
 
10
    def __init__(self):
11
        '''
12
        Constructor
13
        '''
14
 
15
    def getLatestPricing(self, skuBundleId, source_id):
16
        try:
17
            pricing_info = FetchLivePrices.getLatestPrice(skuBundleId, source_id)
14435 kshitij.so 18
            if len(pricing_info) == 0:
14436 kshitij.so 19
                raise
14371 kshitij.so 20
            return [to_t_livePricing(pricing) for pricing in pricing_info]
14796 kshitij.so 21
        except Exception as e:
22
            print "Dtr handler exception ",e
14436 kshitij.so 23
            return [to_t_livePricing(pricing) for pricing in [{}]]
14822 kshitij.so 24
 
15165 kshitij.so 25
    def updateLatestPriceForItem(self, id):
26
        try:
27
            FetchLivePrices.getLatestPriceById(id)
28
        except Exception as e:
29
            print "Dtr handler exception while updating latest price ",e
30
 
14822 kshitij.so 31
    def isAlive(self, ):
32
        """
15175 kshitij.so 33
        For checking whether service is alive or not.
14822 kshitij.so 34
        """
35
        return True
18739 kshitij.so 36
 
19247 kshitij.so 37
    def addItemsInBulk(self, bulkItemsList):
19317 kshitij.so 38
        try:
39
            return AddDataToMaster.addData(bulkItemsList)
40
        except:
41
            traceback.print_exc()
19247 kshitij.so 42
 
43
 
18739 kshitij.so 44
    def closeSession(self):
45
        pass
19247 kshitij.so 46
 
14371 kshitij.so 47
 
48
if __name__ == '__main__':
14435 kshitij.so 49
    dt  = DtrServiceHandler()
50
    print dt.getLatestPricing(100, 1)