Example #1
0
    def __init__(self, taskId, folderRoot, 
                            encZipRoot, passwd, workingDir = 'd:/tmp/fileman/working', appUuid = gAppUuid):
        processorBase.processorBase.__init__(self, taskId, appUuid)
        self.appConfigObj = self.getAppCfg()
        if self.appConfigObj is None:
            self.appConfigObj = {}
            self.appConfigObj["encZipRoot"] = transform.transformDirToInternal(encZipRoot)
            self.appConfigObj["folderRoot"] = transform.transformDirToInternal(folderRoot)
            self.appConfigObj["workingDir"] = transform.transformDirToInternal(workingDir)
            self.appConfigObj["targetBackupDir"] = transform.transformDirToInternal(os.path.join(workingDir, "backup"))
            self.appConfigObj["syncFolderCollectionId"] = unicode(str(uuid.uuid4()))
            self.appConfigObj["logCollectionId"] = unicode(str(uuid.uuid4()))
            self.appConfigObj["archivePendingCollectionId"] = unicode(str(uuid.uuid4()))
            self.appConfigObj["extractionPendingCollectionId"] = unicode(str(uuid.uuid4()))
            self.appConfigObj["archiveNextToProcessTimestamp"] = 0
            self.appConfigObj["extractionNextToProcessTimestamp"] = 0
            self.saveAppConfig()
        else:
            self.expectedDict = {}
            self.expectedDict["encZipRoot"] = transform.transformDirToInternal(encZipRoot)
            self.expectedDict["folderRoot"] = transform.transformDirToInternal(folderRoot)
            self.expectedDict["workingDir"] = transform.transformDirToInternal(workingDir)
            self.expectedDict["targetBackupDir"] = transform.transformDirToInternal(os.path.join(workingDir, "backup"))            
            self.checkParamInternal(self.expectedDict)
        self.curTimestampName = "extractionNextToProcessTimestamp"

        self.archivePendingCollectionId = self.appConfigObj["archivePendingCollectionId"]
        self.extractionPendingCollectionId = self.appConfigObj["extractionPendingCollectionId"]
        self.syncFolderCollectionId = self.appConfigObj["syncFolderCollectionId"]
        self.logCollectionId = self.appConfigObj["logCollectionId"]
        
        collectionDbInst = self.db.getCollectionDb()        
        self.archivePending = collectionDatabase.collectionOnMongoDbBase(self.archivePendingCollectionId, 
                                                                            collectionDbInst)
        self.extractionPending = collectionDatabase.collectionOnMongoDbBase(self.extractionPendingCollectionId, 
                                                                            collectionDbInst)
        
        #Create the 2 collections
        #print self.db
        self.folderCol = syncFolderCollection.syncFolderCollection(self.appConfigObj["folderRoot"], 
                                self.appConfigObj["targetBackupDir"],
                                self.appConfigObj["syncFolderCollectionId"], self.db)
        self.encZipCol = encZipCollection.encZipCollection(self.appConfigObj["encZipRoot"], 
                                self.appConfigObj["logCollectionId"], 
                                self.appConfigObj["workingDir"], passwd, self.db)
        ncl(self.appConfigObj)
Example #2
0
    def __init__(self, taskId, appUuid, targetRootDir, targetBackupDir, 
                            collectionId, workingDir, passwd):
                            
        #First set the input param, __init__ will create initial config from this by calling subClassInitialCfg
        advCollectionProcessor.__init__(self, taskId, appUuid, collectionId)
        #The param initiated in this class should be check by this class
        if self.appConfigObj["logCollectionId"] != logCollectionId:
            raise "Task parameter does not match"

        #Create the 2 collections
        #print self.db
        self.folderCol = syncFolderCollection.syncFolderCollection(transform.transformDirToInternal(targetRootDir), 
                                transform.transformDirToInternal(targetBackupDir),
                                syncFolderCollectionId, self.db)
        self.encZipCol = encZipCollection.encZipCollection(transform.transformDirToInternal(collectionId), 
                                logCollectionId, 
                                transform.transformDirToInternal(workingDir), passwd, self.db)