Rev 19686 | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 25-Oct-2011@author: Chandranshu'''import loggingimport subprocessfrom shop2020.config.client.ConfigClient import ConfigClientfrom shop2020.thriftpy.content.ttypes import ContentServiceException, BulkContentUploadResultfrom shop2020.utils import ContentUploadUtillogging.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 productionParameters:- entityId"""retval = Falseif retval:raise ContentServiceException(id=1, message="Pushing content to production failed")return Truedef uploadContent(self,bulkContentList):notUpdated = []for bulkContentUpload in bulkContentList:result = ContentUploadUtil.migrate_content(bulkContentUpload)try:if not result['updatedExisting'] or result['n']==0:obj = BulkContentUploadResult()obj.entity_id = bulkContentUpload.new_entity_idobj.message = "Not updated, probably due to error in cloning"notUpdated.append(obj)except:obj = BulkContentUploadResult()obj.entity_id = bulkContentUpload.new_entity_idobj.message = "Not updated, probably due to error in cloning"notUpdated.append(obj)return notUpdateddef close_session(self):passdef isAlive(self, ):"""For checking weather service is active alive or not. It also checks connectivity with database"""try:return Trueexcept:return Falsefinally:self.close_session()