Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
3893 chandransh 1
'''
2
Created on 25-Oct-2011
3
 
4
@author: Chandranshu
5
'''
6
import logging
3896 chandransh 7
import subprocess
8
 
9
from shop2020.config.client.ConfigClient import ConfigClient
3910 chandransh 10
from shop2020.thriftpy.content.ttypes import ContentServiceException
3893 chandransh 11
logging.basicConfig(level=logging.DEBUG)
12
 
13
class ContentHandler:
14
    '''
15
    classdocs
16
    '''
17
 
18
    def __init__(self):
3896 chandransh 19
        try:
20
            config_client = ConfigClient()
21
            self.scriptPath = config_client.get_property('PUSH_PRICES_TO_PROD_SCRIPT_PATH')
22
        except:
23
            logging.error("Error while connecting to the config server")
24
            self.scriptPath = "/root/code/trunk/runutils/push-content-to-production.sh"
3893 chandransh 25
 
26
    def pushContentToProduction(self, entityId):
27
        """
3896 chandransh 28
        Push the content of one entity to production
3893 chandransh 29
        Parameters:
30
         - entityId
31
        """
3910 chandransh 32
        retval = subprocess.call([self.scriptPath, str(entityId)])
3896 chandransh 33
        if retval:
3910 chandransh 34
            raise ContentServiceException(id=1, message="Pushing content to production failed")
3896 chandransh 35
        return True
3893 chandransh 36
 
37
    def close_session(self):
38
        pass
39
 
40
    def isAlive(self, ):
41
        """
42
        For checking weather service is active alive or not. It also checks connectivity with database
43
        """
44
        try:
45
            return True
46
        except:
47
            return False
48
        finally:
49
            self.close_session()