Subversion Repositories SmartDukaan

Rev

Rev 14823 | Rev 15175 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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