Beispiel #1
0
 def __init__(self, srcRoot, storageRoot, stateStoragePath = 'd:/state.txt', 
                     tmpStorageRoot = 'd:/tmp/removeAfterComplete', decCopier = encryptionStorageBase.arc4DecSimpleCopier('defaultPass')):
     misc.ensureDir(tmpStorageRoot)
     misc.ensureDir(storageRoot)
     zipStorage.zipStorage.__init__(self, srcRoot, storageRoot, stateStoragePath)
     self.tmpStorageRoot = transform.transformDirToInternal(tmpStorageRoot)
     self.decCopier = decCopier
Beispiel #2
0
def backupDbSingle(dbName, targetDir, password, user):
    if user is None:
        dbSysInst = dbSys.dbSysSmart()
    else:
        dbSysInst = dbSys.dbSysSmart(sessionBase.sessionInstanceBase(user))
        

    db = dbSysInst.getDb(dbName)
    res = []
    e = enc.encryptor()
    if not os.path.exists(targetDir):
        misc.ensureDir(targetDir)
    for i in db.keys():
        #print i
        #values = db.testFunc(i)
        values = db[i]
        encryptedValues = []
        for i in values:
            print i.encode('gbk', 'replace')
            encryptedValues.append(e.en(i, password))
        j = {"key":e.en(i, password), "value":encryptedValues,
            "encHash":unicode(md5.new(password).hexdigest())}

        res.append(j)
        
    #print res
    s = json.dumps(res, sort_keys=True, indent=4)
    f = open(os.path.join(targetDir, dbName+'_for_user_'+str(user)+'.json'),'w')
    f.write(s)
    f.close()
Beispiel #3
0
 def __init__(self, lastState, workingDir, zipStorageDir, passwd):
     self.lastState = zipStorageLocalState(lastState)
     self.zipContentState = {}
     self.workingDir = workingDir + '/zipfiles'
     self.decryptionWorkingDir = workingDir + '/decrypted'
     self.zipStorageDir = zipStorageDir
     self.passwd = passwd
     self.encCopier = encryptionStorageBase.arc4EncSimpleCopier(passwd)
     self.decCopier = encryptionStorageBase.arc4DecSimpleCopier(passwd)
     
     misc.ensureDir(self.workingDir)
     misc.ensureDir(self.decryptionWorkingDir)
     
     
     ########################################
     #Internal used vars
     ########################################
     #The current zipfile object
     self.curArchive = None
     #Not necessary init as it will be inited with self.curArchive
     #The current archived size
     self.curArchivedSize = 0
     
     #The info of files in the current zip file
     self.zippedFileInfo = {}
     
     #The info of the whole storage
     self.zipStorageState = None
Beispiel #4
0
 def encInfoZip(self, pendingCollection):
     ############################
     # Save info for zipped files
     ############################
     logFilePath = transform.transformDirToInternal(
         fileTools.getTimestampWithFreeName(self.workingDir, '.log'))
     s = json.dumps(self.zippedFileInfo, sort_keys=True, indent=4)
     f = open(logFilePath,'w')
     f.write(s)
     f.close()
     logZipPath = logFilePath.replace(u'.log',u'.log.zip')
     logZip = zipClass.ZFile(logZipPath, 'w')
     logZip.addfile(unicode(logFilePath), os.path.basename(logFilePath))
     logZip.close()
     
     gTimeV = time.gmtime()
     yearStr = time.strftime("%Y", gTimeV)
     monthStr = time.strftime("%m", gTimeV)
     dayStr = time.strftime("%d", gTimeV)
     dateTimeDir = yearStr+"/"+monthStr+"/"+dayStr
     newEncDir = unicode(os.path.join(self.zipStorageDir, dateTimeDir))
     misc.ensureDir(newEncDir)
     targetPath = transform.transformDirToInternal(
             fileTools.getTimestampWithFreeName(newEncDir, '.enc'))
     self.encCopier.copy(logZipPath, targetPath.replace('.enc', '.encziplog'))
     
     
     ############################
     # Update state in storage state
     ############################
     self.updateZipLog(self.zippedFileInfo, pendingCollection)
     #Clean the current zipped file info
     self.zippedFileInfo = {}
Beispiel #5
0
    def store(self, item):
        #Check if the item in folder storage is newer than the target one
        relaPath = item.getRelaPath()
        localFullPath = os.path.join(self.rootDir, relaPath)


        localItem = folderStorageItem(self.rootDir, localFullPath)
        extItem = externalItem(self.rootDir, localFullPath, item.getItemInfo())
        extItemLocalCopy = folderStorageItem(self.rootDir, localFullPath, self.lastState.getItemState(item))
        
        localPathDir = os.path.dirname(localFullPath)
        fullPath = item.getFullPath()
        if (not os.path.exists(localFullPath)):
            #Copy the updated file to local path
            misc.ensureDir(localPathDir)
            item.saveTo(self.rootDir)
            #Check if the timestamp are updated
            if localItem.getTimestamp() != extItem.timestamp():
                raise 'not work as expected, need to manually update time for local copy'
            self.lastState.update(extItem)
        elif self.lastState.updated(item):
            #print 'item updated:', item.getRelaPath()
            #The item has been updated, check content
            if isSameItems(item, localItem):
                print 'same, ignore:', fullPath.encode('gbk','replace'), localFullPath.encode('gbk','replace')
                #Need to update the item state
                self.lastState.update(extItem)
            else:
                #Seems external storage and local storage both updated this file. What to do? Ignore for now?
                pass
        else:
            #Not updated, check if the 2 items are same
            if isSameItems(item, extItemLocalCopy):
                print 'According to saved state, same, ignore:', fullPath.encode('gbk','replace'), localFullPath.encode('gbk','replace')
                #Need to update the item state
                self.lastState.update(extItem)
            elif extItemLocalCopy.isExternal():
                #It is an external file, check time
                if (extItemLocalCopy.getExtTs() < item.getTimestamp()):
                    #External storage has updated the item, update the local one
                    backupFullPath = fileTools.getFreeNameFromFullPath(os.path.join(self.backupDir, relaPath))
                    backupPathDir = os.path.dirname(backupFullPath)
                    misc.ensureDir(backupPathDir)            
                    shutil.move(localFullPath, backupFullPath)
                    #Copy the updated file to local path
                    misc.ensureDir(localPathDir)
                    item.saveTo(self.rootDir)
                    self.lastState.update(extItem)
            else:
                if extItemLocalCopy.getTimestamp < item.getTimestamp():
                    #External storage has updated the item, update the local one
                    backupFullPath = fileTools.getFreeNameFromFullPath(os.path.join(self.backupDir, relaPath))
                    backupPathDir = os.path.dirname(backupFullPath)
                    misc.ensureDir(backupPathDir)            
                    shutil.move(localFullPath, backupFullPath)
                    #Copy the updated file to local path
                    misc.ensureDir(localPathDir)
                    item.saveTo(self.rootDir)
                    self.lastState.update(extItem)
Beispiel #6
0
    def store(self, item, pendingCollection):
        
        #Check if the item in folder storage is newer than the target one
        relaPath = item.getRelaPath()
        localFullPath = os.path.join(self.rootDir, relaPath)
        localPathDir = os.path.dirname(localFullPath)
        localItem = folderStorage.folderStorageItem(self.rootDir, localFullPath)
        extItem = folderStorage.externalItem(self.rootDir, localFullPath, item.getItemInfo())
        #This item stores the item info in local collection. It will be used to check 
        #if the item is changed after the last write from external storage
        info = self.lastState.getItemState(localItem)
        if info is None:
            info = {}
        extItemLocalCopy = folderStorage.folderStorageItem(self.rootDir, localFullPath, info)

        if (not os.path.exists(localFullPath)):
            cl('item does not exist, add it')
            #Copy the updated file to local path
            misc.ensureDir(localPathDir)
            item.saveTo(self.rootDir)
            #Check if the timestamp are updated
            if localItem.getTimestamp() != extItem.timestamp():
                raise 'not work as expected, need to manually update time for local copy'
            self.lastState.update(extItem)
        elif self.lastState.updated(localItem):
            ncl('item updated, check it')
            if extItemLocalCopy.isExternal():
                ncl("External obj")
                #It is an external file, check time
                if (extItemLocalCopy.getExtTs() < item.getTimestamp()):
                    ncl("External storage has updated the item, update the local one")
                    #External storage has updated the item, update the local one
                    backupFullPath = fileTools.getFreeNameFromFullPath(os.path.join(self.backupDir, relaPath))
                    backupPathDir = os.path.dirname(backupFullPath)
                    misc.ensureDir(backupPathDir)            
                    shutil.move(localFullPath, backupFullPath)
                    #Copy the updated file to local path
                    misc.ensureDir(localPathDir)
                    item.saveTo(self.rootDir)
                    self.lastState.update(extItem)
            else:
                if extItemLocalCopy.getTimestamp() < item.getTimestamp():
                    #External storage has updated the item, update the local one
                    cl(extItemLocalCopy.getTimestamp() , item.getTimestamp())
                    backupFullPath = fileTools.getFreeNameFromFullPath(os.path.join(self.backupDir, relaPath))
                    backupPathDir = os.path.dirname(backupFullPath)
                    misc.ensureDir(backupPathDir)            
                    shutil.move(localFullPath, backupFullPath)
                    #Copy the updated file to local path
                    misc.ensureDir(localPathDir)
                    item.saveTo(self.rootDir)
                    self.lastState.update(extItem)
                else:
                    ncl("The item need to be stored is not newer than the local one, the info for local item will be updated")
                    self.lastState.updateLocal(localItem)
Beispiel #7
0
def getStorgePathWithDateFolder(rootPath, ext = ".enc"):
    gTimeV = time.gmtime()
    yearStr = time.strftime("%Y", gTimeV)
    monthStr = time.strftime("%m", gTimeV)
    dayStr = time.strftime("%d", gTimeV)
    dateTimeDir = yearStr+"/"+monthStr+"/"+dayStr
    newEncDir = unicode(os.path.join(rootPath, dateTimeDir))
    misc.ensureDir(newEncDir)
    targetPath = transform.transformDirToInternal(
            fileTools.getTimestampWithFreeName(newEncDir, ext))
    return targetPath
Beispiel #8
0
 def __init__(self, taskId, appUuid, collectionId, workingDir, passwd, targetCollection):
     processorBase.cacheCollectionProcessorBase.__init__(self, taskId, appUuid, collectionId)
     #This dir stores zip files which were decrypted
     self.workingDir = workingDir
     self.decryptionWorkingDir = workingDir + '/decrypted'
     misc.ensureDir(self.decryptionWorkingDir)
     self.logCollectionId = self.appConfigObj["logCollectionId"]
     self.logCollection = collectionDatabase.collectionOnMongoDbBase(self.logCollectionId, self.db.getCollectionDb())
     self.targetCollection = targetCollection
     self.passwd = passwd
     self.encCopier = encryptionStorageBase.arc4EncSimpleCopier(passwd)
     self.decCopier = encryptionStorageBase.arc4DecSimpleCopier(passwd)
 def __init__ ( self, tubeName, workingDir = "d:/tmp/working/zippedCollectionListHandler", passwd = '123'):
     misc.ensureDir(workingDir)
     super(zippedCollectionListHandler, self).__init__(tubeName)
     threading.Thread.__init__(self)
     # Stores collection instance for given monitoring path, all zipped objects
     # in this monitoring path will be stored in this collection
     self.collectionInDbForMonitoringPath = {}
     self.dbInst = objectDatabase.objectDatabase()
     self.workingDir = workingDir
     self.encCopier = encryptionStorageBase.arc4EncSimpleCopier(passwd)
     self.decCopier = encryptionStorageBase.arc4DecSimpleCopier(passwd)
     self.zippedInfoCollectionList = collectionDatabase.collectionOnMongoDbBase(gZippedInfoCollectionId, self.dbInst.getCollectionDb())
Beispiel #10
0
 def processItem(self, job, item):
     #fullPath = transform.transformDirToInternal(item["fullPath"])
     #monitoringFullPath = transform.transformDirToInternal(item["monitoringPath"])
     workingDir = item["workingDir"]
     misc.ensureDir(workingDir)
     inputTubeName = item["inputTubeName"]
     if self.taskDict.has_key(inputTubeName):
         job.delete()
         return False
     t = fileArchiveThread(inputTubeName, self.storageClass(workingDir))
     self.taskDict[inputTubeName] = t
     t.start()
     return True
Beispiel #11
0
    def initParam(self, zipDir, folderDir, workingDir, encryptionPass, direction):
        #################################
        #Make dir if not exist
        #################################
        misc.ensureDir(zipDir)
        misc.ensureDir(workingDir)
        misc.ensureDir(folderDir)
        self.configPath = os.path.join(workingDir, 'workingState.txt')
        self.backupPath = os.path.join(workingDir, 'backup')
        misc.ensureDir(self.backupPath)
        self.tmpStorageRoot = transform.transformDirToInternal(os.path.join(workingDir, 'working'))
        self.config = configDict.configFileDict(self.configPath, {"zipStorageState":{}, "folderState":{}})

        #################################
        #Create source storage
        #################################
        
        self.storage1 = encZipStorage.encZipStorage(self.config["zipStorageState"], 
                self.tmpStorageRoot, zipDir, encryptionPass)
        #################################
        #Create target storage
        #################################
        self.storage2 = folderStorage.folderStorage(self.config["folderState"], 
                folderDir, self.backupPath)
        
        if direction == "extract":
            self.srcStorage = self.storage1
            self.dstStorage = self.storage2
        else:
            self.srcStorage = self.storage2
            self.dstStorage = self.storage1
Beispiel #12
0
 def store(self, item):
     #Check if the item in folder storage is newer than the target one
     fullPath = item.getFullPath()
     relaPath = item.getRelaPath()
     localFullPath = os.path.join(self.rootDir, relaPath)
     localItem = folderStorageItem(self.rootDir, localFullPath)
     localPathDir = os.path.dirname(localFullPath)
     if (not os.path.exists(localFullPath)):
         #Copy the updated file to local path
         misc.ensureDir(localPathDir)
         shutil.move(fullPath, localFullPath)
         #print localFullPath
         self.lastState.update(item)
     elif isSameItems(item, localItem):
         print 'same, ignore:', fullPath, localFullPath
     elif isItem1Newer(item, localItem):
         #The file need to be stored is newer, copy the older file to backup storage
         backupFullPath = fileTools.getFreeNameFromFullPath(os.path.join(self.backupDir, relaPath))
         backupPathDir = os.path.dirname(backupFullPath)
         misc.ensureDir(backupPathDir)            
         shutil.move(localFullPath, backupFullPath)
         #Copy the updated file to local path
         misc.ensureDir(localPathDir)
         shutil.copy(fullPath, localFullPath)
         self.lastState.update(item)
     else:
         #The file need to be stored is old, copy it to backup storage
         backupFullPath = fileTools.getFreeNameFromFullPath(os.path.join(self.backupDir, relaPath))
         backupPathDir = os.path.dirname(backupFullPath)
         misc.ensureDir(backupPathDir)            
         shutil.copy(fullPath, backupPathDir)
Beispiel #13
0
 def createNewZip(self):
     ####################
     # Create new zip file
     ####################
     gTimeV = time.gmtime()
     yearStr = time.strftime("%Y", gTimeV)
     monthStr = time.strftime("%m", gTimeV)
     dayStr = time.strftime("%d", gTimeV)
     dateTimeDir = yearStr+"/"+monthStr+"/"+dayStr
     newEncDir = unicode(os.path.join(self.zipStorageDir, dateTimeDir))
     misc.ensureDir(newEncDir)
     self.curArchiveName = transform.transformDirToInternal(
         fileTools.getTimestampWithFreeName(self.workingDir, '.zip'))
     self.targetPath = transform.transformDirToInternal(
             fileTools.getTimestampWithFreeName(newEncDir, '.enc'))
     cl("Creating new zip file", self.curArchiveName)
     self.curArchive = zipClass.ZFile(self.curArchiveName, 'w')
     self.curArchivedSize = 0
Beispiel #14
0
 def __init__(self, collectionId, logCollectionId, workingDir, passwd, dbInst):
     '''
     collectionId is the ID of the enc zip storage collection, it should be the dir path storing 
     the enc zip files, and it will be used to retieve all enc zip files.
     '''
     super(encZipInfoCollection, self).__init__(collectionId, logCollectionId, workingDir, passwd, dbInst)
     
     ########################################
     #Internal used vars
     ########################################
     #The info of files in the current zip file
     self.zippedFileInfo = {}
     
     #File count for the current info storage, encZipCollection does
     #not have this
     self.fileCnt = 0
     
     self.zipStorageDir = transform.transformDirToInternal(collectionId)
     misc.ensureDir(self.zipStorageDir)
Beispiel #15
0
def backupDbSingle(dbName, targetDir, password, user, afterTimeStamp, beforeTimeStamp):
    if user is None:
        dbSysInst = dbSys.dbSysSmart()
    else:
        dbSysInst = dbSys.dbSysSmart(sessionBase.sessionInstanceBase(user))
        

    db = dbSysInst.getDb(dbName)
    res = []

    if not os.path.exists(targetDir):
        misc.ensureDir(targetDir)
    for i in db.keysDuring(afterTimeStamp, beforeTimeStamp):
        #print i
        #values = db.testFunc(i)
        values = db[i]
        j = {"db": dbName, "user": user, "key":i, "value":values, "t": beforeTimeStamp}
        res.append(j)
        
    return res
Beispiel #16
0
 def __init__(self, collectionId, logCollectionId, workingDir, passwd, dbInst):
     '''
     collectionId is the ID of the enc zip storage collection, it should be the dir path storing 
     the enc zip files, and it will be used to retieve all enc zip files.
     '''
     encZipStorageCollectionEnum.encZipStorageCollectionEnum.__init__(self, collectionId, logCollectionId, workingDir, passwd, dbInst)
     
     ########################################
     #Internal used vars
     ########################################
     #The current zipfile object
     self.curArchive = None
     
     #Not necessary init as it will be inited with self.curArchive
     #The current archived size
     self.curArchivedSize = 0
     
     #The info of files in the current zip file
     self.zippedFileInfo = {}
     
     self.zipStorageDir = transform.transformDirToInternal(collectionId)
     misc.ensureDir(self.zipStorageDir)
Beispiel #17
0
 def store(self, item, pendingCollection):
     #Check if the item in folder storage is newer than the target one
     relaPath = item["idInCol"]
     localFullPath = transform.transformDirToInternal(os.path.join(self.rootDir, relaPath))
     localPathDir = transform.transformDirToInternal(os.path.dirname(localFullPath))
     #Check the updates of the object is done in advCollectionProcess.
     #When we come here, the item is for sure needed for update
     
     #Backup if it exists
     if os.path.exists(localFullPath):
         backupFullPath = fileTools.getFreeNameFromFullPath(os.path.join(self.backupDir, relaPath))
         backupPathDir = os.path.dirname(backupFullPath)
         misc.ensureDir(backupPathDir)
         shutil.move(localFullPath, backupFullPath)
             
     misc.ensureDir(localPathDir)
     item.saveTo(self.rootDir)
     #################################
     #Update collection info
     #################################
     #Remove the legacy timestamp
     objInfo = copy.copy(item.getItemInfo())
     if objInfo.has_key("timestamp"):
         objInfo["externalTimestamp"] = objInfo["timestamp"]
         del objInfo["timestamp"]
     
     
     obj = objectDatabase.fsObjBase(localFullPath, objInfo)
     #ncl(obj.getItemInfo())
     #print type(obj.getItemInfo())
     #ncl(self.objDb.getDbObj(obj.getItemObjUrl()))
     itemUuid = self.objDb.addDbObj(obj.getObjUrl(), obj.getItemInfo())
     ncl("collection obj uuid:", itemUuid)
     #ncl(self.objDb.getDbObj(obj.getItemObjUrl()))
     self.updateObjUuid(item["idInCol"], itemUuid)
     return True
Beispiel #18
0
    def __init__(self, lastState, workingDir, zipStorageDir, passwd):
        self.lastState = folderStorage.folderStorageState(lastState)
        #self.selfState = folderStorage.folderStorageState({})
        self.zipContentState = {}
        self.workingDir = workingDir + '/zipfiles'
        self.decryptionWorkingDir = workingDir + '/decrypted'
        self.zipStorageDir = zipStorageDir
        self.passwd = passwd
        self.encCopier = encryptionStorageBase.arc4EncSimpleCopier(passwd)
        self.decCopier = encryptionStorageBase.arc4DecSimpleCopier(passwd)
        
        misc.ensureDir(self.workingDir)
        misc.ensureDir(self.decryptionWorkingDir)
        
        
        ########################################
        #Internal used vars
        ########################################
        self.curArchive = None
        #Not necessary init as it will be inited with self.curArchive
        self.curArchivedSize = 0
        self.zippedFileInfo = {}

        self.zipStorageState = None
Beispiel #19
0
 def __init__(self, collectionId, logCollectionId, workingDir, passwd, dbInst):
     '''
     collectionId is the id of a collection contains all enc zip files
     logCollectionId is the id of a collection contains all extracted info
     '''
     self.objDb = dbInst
     self.collectionDbInst = dbInst.getCollectionDb()
     #This dir stores zip files which were decrypted
     self.workingDir = workingDir
     self.decryptionWorkingDir = workingDir + '/decrypted'
     misc.ensureDir(self.decryptionWorkingDir)
     #This is the folder collection that contains all encrypted zip files
     self.collectionId = collectionId
     ncl(collectionId)
     self.collection = folderRecursiveEnumCollection.folderRecursiveEnumCollection(self.collectionId, dbInst)
     
     #This is the log collection which stores all extracted info, these info may 
     #be extracted every time the folder is scaned, but it'll be better to store them for future use
     self.logCollectionId = logCollectionId
     self.logCollection = collectionDatabase.collectionOnMongoDbBase(self.logCollectionId, self.collectionDbInst)
     
     self.passwd = passwd
     self.encCopier = encryptionStorageBase.arc4EncSimpleCopier(passwd)
     self.decCopier = encryptionStorageBase.arc4DecSimpleCopier(passwd)
Beispiel #20
0
    def __init__(self, taskName):
        #print taskName
        taskInterface.localTaskBase.__init__(self, taskName)
        parser = OptionParser()

        parser.add_option("-f", "--folder", action="store",help="copy from which directory")
        parser.add_option("-p", "--encryptionPass", action="store",help="encryption password")
        parser.add_option("-z", "--zipDir", action="store", help="target directory")
        #parser.add_option("-c", "--configPath", action="store", help="path for the config file")
        parser.add_option("-w", "--workingPath", action="store", help="path for temp file")
        #parser.add_option("-b", "--backupPath", action="store", help="path for backup files")
        parser.add_option("-d", "--direction", action="store", help="syncDirection")
        (options, args) = parser.parse_args()
        self.options = options
        
        #################################
        #Make dir if not exist
        #################################
        misc.ensureDir(options.zipDir)
        misc.ensureDir(options.workingPath)
        misc.ensureDir(self.options.folder)
        self.configPath = os.path.join(options.workingPath, 'workingState.txt')
        self.backupPath = os.path.join(options.workingPath, 'backup')
        misc.ensureDir(self.backupPath)
        self.tmpStorageRoot = transform.transformDirToInternal(os.path.join(options.workingPath, 'working'))
        self.config = configDict.configFileDict(self.configPath, {"zipStorageState":{}, "folderState":{}})

        #################################
        #Create source storage
        #################################
        
        self.storage1 = encZipStorage.encZipStorage(self.config["zipStorageState"], 
                self.tmpStorageRoot, self.options.zipDir, self.options.encryptionPass)
        #################################
        #Create target storage
        #################################
        self.storage2 = folderStorage.folderStorage(self.config["folderState"], 
                self.options.folder, self.backupPath)
        
        if self.options.direction == "extract":
            self.srcStorage = self.storage1
            self.dstStorage = self.storage2
        else:
            self.srcStorage = self.storage2
            self.dstStorage = self.storage1
Beispiel #21
0
    def __init__(self, taskName):
        #print taskName
        taskInterface.localTaskBase.__init__(self, taskName)
        parser = OptionParser()

        parser.add_option("-s", "--sourceDir", action="store",help="copy from which directory")
        parser.add_option("-p", "--encryptionPass", action="store",help="encryption password")
        parser.add_option("-t", "--targetDir", action="store", help="target directory")
        parser.add_option("-c", "--configPath", action="store", help="path for the config file")
        parser.add_option("-w", "--workingPath", action="store", help="path for temp file")
        (options, args) = parser.parse_args()
        self.options = options
        self.configPath = options.configPath
        self.config = configDict.configFileDict(options.configPath, {'timestamp':{}})
        misc.ensureDir(options.targetDir)
        self.objList = dirTreeGenerator(self.options.sourceDir)
        self.tmpStorageRoot = transform.transformDirToInternal(options.workingPath)
        misc.ensureDir(self.tmpStorageRoot)
        misc.ensureDir(self.options.targetDir)
        self.encCopier = encryptionStorageBase.arc4DecSimpleCopier(options.encryptionPass)
        #self.createNewZip()
        self.curArchive = None
Beispiel #22
0
    #print c
    sys.path.insert(0, os.path.join(c,'prodRoot'))
    #import localLibs.localDb.sqliteAttrDb.sqliteEntryDbWithHistory as entryDbMod
    #import localLibs.localDb.sqliteAttrDb.sqliteTokenDb as tokenDbMod
    import localLibs.localDb.shoveInDefaultPath as shove
    #gAppPath = 'd:/tmp/fileman/'
    #gDbPath = os.path.join(gAppPath, 'db')
    #import libs.utils.misc as misc
    #import libs.ufsDb.ufsDbBase as ufsDbBase
    #misc.ensureDir(gAppPath)
    #misc.ensureDir(gDbPath)

gAppPath = 'd:/tmp/test/'
gDbPath = os.path.join(gAppPath, 'db')
import wwjufsdatabase.libs.utils.misc as misc
misc.ensureDir(gAppPath)
misc.ensureDir(gDbPath)


class testDbSys(dbSysInterface.dbSysInterface):
    def __init__(self, sessionInstance = None):
        self.sessInst = sessionInstance
    def getObjId2PathShove(self):
        return self.getDb("objId2PathShove")
    def getPath2ObjIdShove(self):
        return self.getDb("path2ObjIdShove")
    def getCollectionCacheIdDb(self):
        return self.getDb("collectionCacheIdDb")
    def getCollectionCacheUpdateDb(self):
        return self.getDb("collectionCacheUpdateDb")
    def getCollectionCacheDb(self):
Beispiel #23
0
import dbus.service
import localLibSys
import localLibs.logWin.dbusServices.dbusServiceBase as dbusServiceBase
import wwjufsdatabase.libs.ufsDb.ufsDbSingleUser as ufsDbSingleUser
import wwjufsdatabase.libs.utils.transform as transform
import wwjufsdatabase.libs.thumb.thumbInterface as thumbLib
import wwjufsdatabase.libs.utils.misc as misc
import os
import uuid

gAppPath = 'd:/tmp/fileman/'
gThumbPath = os.path.join(gAppPath, 'thumb')

misc.ensureDir(gAppPath)
misc.ensureDir(gThumbPath)

INTERFACE_NAME = 'com.wwjufsdatabase.thumbService'

class simpleSysUser:
    def getUserName(self):
        return 'system.default'
    def getPasswd(self):
        return 'simplePass'

def getProdRoot():
    c = os.getcwd()
    while c.find('prodRoot') != -1:
        c = os.path.dirname(c)
    return os.path.join(c, 'prodRoot')

class thumbService(dbusServiceBase.dbusServiceBase):
Beispiel #24
0
from optparse import OptionParser
import localLibSys
import desktopApp.lib.archiver.encryptionStorageBase as encryptionStorageBase
import desktopApp.lib.archiver.archiveStorageBase as archiveStorageBase
import desktopApp.lib.archiver.archiverV2 as archiver
import wwjufsdatabase.libs.utils.misc as misc


if __name__ == "__main__":
    parser = OptionParser()
    parser.add_option("-s", "--sourceDir", action="store",help="copy from which directory")
    parser.add_option("-p", "--encryptionPass", action="store",help="encryption password")
    parser.add_option("-t", "--targetDir", action="store", help="target directory")
    parser.add_option("-c", "--configPath", action="store", help="path for the config file")
    (options, args) = parser.parse_args()
        
        
    ar = archiver.archiverInterface()

    src = archiveStorageBase.folder(options.sourceDir)
    misc.ensureDir(options.targetDir)

    s = encryptionStorageBase.encryptionStorageBase(options.sourceDir, options.targetDir,
        stateStoragePath = options.configPath, 
        encCopier = encryptionStorageBase.arc4EncSimpleCopier(options.encryptionPass))
    ar.archive(src, s)
    s.saveState()