Ejemplo n.º 1
0
Archivo: syncTk.py Proyecto: weijia/ufs
def main():
    top = Tkinter.Tk()
    config = configDict.configFileDict('config.txt',{'srcDir':"", 'destDir':""})
    label1 = Tkinter.Label(top, text=textStr["originalDir"])
    srcTxt = Tkinter.StringVar()
    srcTextEntry = Tkinter.Entry(top, width = 50, textvariable = srcTxt)
    srcTxt.set(config["srcDir"])
    srcSelector = dirSelector(srcTxt, top)
    selectSrc = Tkinter.Button(top,text=textStr['selectDir'],command=srcSelector.showDialog,activeforeground='white',
activebackground='red')
    label2 = Tkinter.Label(top, text=textStr["archiveDir"])
    dstTxt = Tkinter.StringVar()
    dstTextEntry = Tkinter.Entry(top, width = 50, textvariable = dstTxt)
    dstTxt.set(config["destDir"])
    dstSelector = dirSelector(dstTxt, top)

    selectDst = Tkinter.Button(top,text=textStr['selectDir'],command=dstSelector.showDialog,activeforeground='white',
activebackground='red')

    label1.pack()
    srcTextEntry.pack()
    selectSrc.pack()
    label2.pack()
    dstTextEntry.pack()
    selectDst.pack()
    
    quitActionHandler = saveConfigQuitAction(top, config, srcTxt, dstTxt)
    
    syncBut = Tkinter.Button(top,text='Sync',command=startSync,activeforeground='white',
activebackground='red')
    quit = Tkinter.Button(top,text='QUIT',command=top.quit,activeforeground='white',
activebackground='red')
    syncBut.pack()
    quit.pack()
Ejemplo n.º 2
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
Ejemplo n.º 3
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
Ejemplo n.º 4
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
Ejemplo n.º 5
0
 def __init__(self):
     self.config = configDict.configFileDict("config.txt", {"srcDir": "", "destDir": "", "workingDir": ""})