Subversion Repositories SmartDukaan

Rev

Rev 3893 | Rev 3910 | 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
3893 chandransh 10
logging.basicConfig(level=logging.DEBUG)
11
 
12
class ContentHandler:
13
    '''
14
    classdocs
15
    '''
16
 
17
    def __init__(self):
3896 chandransh 18
        try:
19
            config_client = ConfigClient()
20
            self.scriptPath = config_client.get_property('PUSH_PRICES_TO_PROD_SCRIPT_PATH')
21
        except:
22
            logging.error("Error while connecting to the config server")
23
            self.scriptPath = "/root/code/trunk/runutils/push-content-to-production.sh"
3893 chandransh 24
 
25
    def pushContentToProduction(self, entityId):
26
        """
3896 chandransh 27
        Push the content of one entity to production
3893 chandransh 28
        Parameters:
29
         - entityId
30
        """
3896 chandransh 31
        retval = subprocess.call([self.scriptPath, entityId])
32
        if retval:
33
            raise Exception("Pushing content to production failed")
34
        return True
3893 chandransh 35
 
36
    def close_session(self):
37
        pass
38
 
39
    def isAlive(self, ):
40
        """
41
        For checking weather service is active alive or not. It also checks connectivity with database
42
        """
43
        try:
44
            return True
45
        except:
46
            return False
47
        finally:
48
            self.close_session()