Subversion Repositories SmartDukaan

Rev

Rev 3896 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

'''
Created on 25-Oct-2011

@author: Chandranshu
'''
import logging
import subprocess

from shop2020.config.client.ConfigClient import ConfigClient
from shop2020.thriftpy.content.ttypes import ContentServiceException
logging.basicConfig(level=logging.DEBUG)

class ContentHandler:
    '''
    classdocs
    '''
    
    def __init__(self):
        try:
            config_client = ConfigClient()
            self.scriptPath = config_client.get_property('PUSH_PRICES_TO_PROD_SCRIPT_PATH')
        except:
            logging.error("Error while connecting to the config server")
            self.scriptPath = "/root/code/trunk/runutils/push-content-to-production.sh"
    
    def pushContentToProduction(self, entityId):
        """
        Push the content of one entity to production
        Parameters:
         - entityId
        """
        retval = subprocess.call([self.scriptPath, str(entityId)])
        if retval:
            raise ContentServiceException(id=1, message="Pushing content to production failed")
        return True
    
    def close_session(self):
        pass
    
    def isAlive(self, ):
        """
        For checking weather service is active alive or not. It also checks connectivity with database
        """
        try:
            return True
        except:
            return False
        finally:
            self.close_session()