Subversion Repositories SmartDukaan

Rev

Rev 3910 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3910 Rev 19686
Line 5... Line 5...
5
'''
5
'''
6
import logging
6
import logging
7
import subprocess
7
import subprocess
8
 
8
 
9
from shop2020.config.client.ConfigClient import ConfigClient
9
from shop2020.config.client.ConfigClient import ConfigClient
10
from shop2020.thriftpy.content.ttypes import ContentServiceException
10
from shop2020.thriftpy.content.ttypes import ContentServiceException, BulkContentUploadResult
-
 
11
from shop2020.utils import ContentUploadUtil
11
logging.basicConfig(level=logging.DEBUG)
12
logging.basicConfig(level=logging.DEBUG)
12
 
13
 
13
class ContentHandler:
14
class ContentHandler:
14
    '''
15
    '''
15
    classdocs
16
    classdocs
Line 32... Line 33...
32
        retval = subprocess.call([self.scriptPath, str(entityId)])
33
        retval = subprocess.call([self.scriptPath, str(entityId)])
33
        if retval:
34
        if retval:
34
            raise ContentServiceException(id=1, message="Pushing content to production failed")
35
            raise ContentServiceException(id=1, message="Pushing content to production failed")
35
        return True
36
        return True
36
    
37
    
-
 
38
    def uploadContent(self,bulkContentList):
-
 
39
        notUpdated = []
-
 
40
        for bulkContentUpload in bulkContentList:
-
 
41
            result = ContentUploadUtil.migrate_content(bulkContentUpload)
-
 
42
            try:
-
 
43
                if not result['updatedExisting'] or result['n']==0:
-
 
44
                    obj = BulkContentUploadResult()
-
 
45
                    obj.entity_id = bulkContentUpload.new_entity_id
-
 
46
                    obj.message = "Not updated, probably due to error in cloning"
-
 
47
                    notUpdated.append(obj)
-
 
48
            except:
-
 
49
                obj = BulkContentUploadResult()
-
 
50
                obj.entity_id = bulkContentUpload.new_entity_id
-
 
51
                obj.message = "Not updated, probably due to error in cloning"
-
 
52
                notUpdated.append(obj)
-
 
53
        return notUpdated
-
 
54
    
37
    def close_session(self):
55
    def close_session(self):
38
        pass
56
        pass
39
    
57
    
40
    def isAlive(self, ):
58
    def isAlive(self, ):
41
        """
59
        """