Subversion Repositories SmartDukaan

Rev

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

from dtr.utils import FetchLivePrices, AddDataToMaster
from shop2020.model.v1.dtr.impl.Convertors import to_t_livePricing
import traceback

class DtrServiceHandler:
    '''
    classdocs
    '''
    
    def __init__(self):
        '''
        Constructor
        '''
        
    def getLatestPricing(self, skuBundleId, source_id):
        try:
            pricing_info = FetchLivePrices.getLatestPrice(skuBundleId, source_id)
            if len(pricing_info) == 0:
                raise
            return [to_t_livePricing(pricing) for pricing in pricing_info]
        except Exception as e:
            print "Dtr handler exception ",e
            return [to_t_livePricing(pricing) for pricing in [{}]]
    
    def updateLatestPriceForItem(self, id):
        try:
            FetchLivePrices.getLatestPriceById(id)
        except Exception as e:
            print "Dtr handler exception while updating latest price ",e
    
    def isAlive(self, ):
        """
        For checking whether service is alive or not.
        """
        return True
    
    def addItemsInBulk(self, bulkItemsList):
        try:
            return AddDataToMaster.addData(bulkItemsList)
        except:
            traceback.print_exc()
            
        
    def closeSession(self):
        pass
    
                   
if __name__ == '__main__':
    dt  = DtrServiceHandler()
    print dt.getLatestPricing(100, 1)