def domanage(infilename, mode, versionname, oldname, comment, merge): availablemodes = ['list','save','restore','delete','rename'] if mode in availablemodes: namer = filenamer('sdflagmanager',infilename) msfilename = namer.configure_name(kind='temp',suffix='ms') # if directories 'msfilename' and 'msfilename.flagversions' already exist accidentally, # rename it for backup (backupms, backupmsfver) sdfverfile = namer.flagversion_name(infilename) msfverfile = namer.flagversion_name(msfilename) if os.path.exists(sdfverfile): move(sdfverfile, msfverfile) sdutil.save(sd.scantable(infilename,False), msfilename, 'MS2', False) task_flagmanager.flagmanager(msfilename, mode, versionname, oldname, comment, merge) if mode=='restore': backupinfile = namer.configure_name(kind='backup',suffix='asap') # if a directory with the same name as backupinfile exists, rename it for backup move(infilename, backupinfile) sdutil.save(sd.scantable(msfilename,False), infilename, 'ASAP', False) remove(msfilename) move(msfverfile, sdfverfile) # if backupms and backupmsfver exist, rename them back # to msfilename and msfilename.flagversions, respectively else: raise Exception, "Unknown mode" + str(mode)
def domanage(infilename, mode, versionname, oldname, comment, merge): availablemodes = ['list', 'save', 'restore', 'delete', 'rename'] if mode in availablemodes: namer = filenamer('sdflagmanagerold', infilename) msfilename = namer.configure_name(kind='temp', suffix='ms') # if directories 'msfilename' and 'msfilename.flagversions' already exist accidentally, # rename it for backup (backupms, backupmsfver) sdfverfile = namer.flagversion_name(infilename) msfverfile = namer.flagversion_name(msfilename) if os.path.exists(sdfverfile): move(sdfverfile, msfverfile) sdutil.save(sd.scantable(infilename, False), msfilename, 'MS2', False) task_flagmanager.flagmanager(msfilename, mode, versionname, oldname, comment, merge) if mode == 'restore': backupinfile = namer.configure_name(kind='backup', suffix='asap') # if a directory with the same name as backupinfile exists, rename it for backup move(infilename, backupinfile) sdutil.save(sd.scantable(msfilename, False), infilename, 'ASAP', False) remove(msfilename) move(msfverfile, sdfverfile) # if backupms and backupmsfver exist, rename them back # to msfilename and msfilename.flagversions, respectively else: raise Exception, "Unknown mode" + str(mode)
def execute(self): if os.path.exists(self.sdfverfile): move(self.sdfverfile, self.msfverfile) sdutil.save(self.scan, self.msfile, 'MS2', False) task_flagmanager.flagmanager(self.msfile, self.mode, self.versionname, self.oldname, self.comment, self.merge) if self.mode == 'restore': # if a directory with the same name as backupinfile exists, rename it for backup del self.scan move(self.infile_abs, self.backupfile) sdutil.save(sd.scantable(self.msfile, False), self.infile_abs, 'ASAP', False) move(self.msfverfile, self.sdfverfile)
def execute(self): if os.path.exists(self.sdfverfile): move(self.sdfverfile, self.msfverfile) sdutil.save(self.scan, self.msfile, 'MS2', False) task_flagmanager.flagmanager(self.msfile, self.mode, self.versionname, self.oldname, self.comment, self.merge) if self.mode=='restore': # if a directory with the same name as backupinfile exists, rename it for backup del self.scan move(self.infile_abs, self.backupfile) sdutil.save(sd.scantable(self.msfile,False), self.infile_abs, 'ASAP', False) move(self.msfverfile, self.sdfverfile)