本文整理匯總了Python中rapuma.core.tools.Tools.incrementFileName方法的典型用法代碼示例。如果您正苦於以下問題:Python Tools.incrementFileName方法的具體用法?Python Tools.incrementFileName怎麽用?Python Tools.incrementFileName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rapuma.core.tools.Tools
的用法示例。
在下文中一共展示了Tools.incrementFileName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ProjData
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import incrementFileName [as 別名]
#.........這裏部分代碼省略.........
except :
self.log.writeToLog(self.errorCodes['3410'], [f])
# Remove oldest file(s)
while len(cullList) > maxStoreBackups :
fn = min(cullList)
cullList.remove(min(cullList))
os.remove(os.path.join(bakDir, str(fn) + '.zip'))
def backupProject (self, targetPath=None) :
'''Backup a project. Send the compressed backup file with a date-stamp
file name to the user-specified backup folder. If a target path is
specified, put the archive there but use the PID in the name. If other
backups with the same name exist there, increment with a number.'''
# First see if this is even a valid project
if self.pid not in self.projList :
self.log.writeToLog(self.errorCodes['3610'], [self.pid])
# Set some paths and file names
if not targetPath :
# Now check for a valid location to backup to
if self.local.userLibBackup == '' :
self.log.writeToLog(self.errorCodes['3622'])
elif not os.path.exists(self.local.userLibBackup) :
self.log.writeToLog(self.errorCodes['3620'], [self.local.userLibBackup])
projBackupFolder = os.path.join(self.local.userLibBackup, self.pid)
backupTarget = os.path.join(projBackupFolder, self.tools.fullFileTimeStamp() + '.zip')
else :
projBackupFolder = self.tools.resolvePath(targetPath)
# Now check for a valid target path
if not os.path.exists(projBackupFolder) :
self.log.writeToLog(self.errorCodes['3625'], [targetPath])
backupTarget = self.tools.incrementFileName(os.path.join(projBackupFolder, self.pid + '.zip'))
# Make sure the dir is there
if not os.path.exists(projBackupFolder) :
os.makedirs(projBackupFolder)
# import pdb; pdb.set_trace()
# Zip up but use a list of files we don't want
self.zipUpProject(backupTarget, self.makeExcludeFileList(source))
# Cull out any excess backups
if not targetPath :
self.cullBackups(self.userConfig['System']['maxStoreBackups'], projBackupFolder)
# Finish here
pc = Config(self.pid)
pc.getProjectConfig()
pc.projectConfig['Backup']['lastBackup'] = self.tools.fullFileTimeStamp()
self.tools.writeConfFile(pc.projectConfig)
self.log.writeToLog(self.errorCodes['3630'], [self.pid,backupTarget])
return True
def backupRestore (self, backup, target = None) :
'''Restore a backup to the current or specified project.'''
# import pdb; pdb.set_trace()
if not target :
target = self.local.projHome
# Now remove the orginal