本文整理匯總了Python中xia2.Handlers.Flags.Flags.get_migrate_data方法的典型用法代碼示例。如果您正苦於以下問題:Python Flags.get_migrate_data方法的具體用法?Python Flags.get_migrate_data怎麽用?Python Flags.get_migrate_data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類xia2.Handlers.Flags.Flags
的用法示例。
在下文中一共展示了Flags.get_migrate_data方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: migrate
# 需要導入模塊: from xia2.Handlers.Flags import Flags [as 別名]
# 或者: from xia2.Handlers.Flags.Flags import get_migrate_data [as 別名]
def migrate(self, directory):
'''Migrate (or not) data to a local directory.'''
if not Flags.get_migrate_data():
# we will not migrate this data
return directory
if directory in self._data_migrate.keys():
# we have already migrated this data
return self._data_migrate[directory]
# create a directory to move data to...
self._data_migrate[directory] = tempfile.mkdtemp()
# copy all files in source directory to new directory
# retaining timestamps etc.
start_time = time.time()
migrated = 0
migrated_dir = 0
for f in os.listdir(directory):
# copy over only files....
if os.path.isfile(os.path.join(directory, f)):
shutil.copy2(os.path.join(directory, f),
self._data_migrate[directory])
migrated += 1
elif os.path.isdir(os.path.join(directory, f)):
shutil.copytree(os.path.join(directory, f),
os.path.join(self._data_migrate[directory],
f))
migrated_dir += 1
Debug.write('Migrated %d files from %s to %s' % \
(migrated, directory, self._data_migrate[directory]))
if migrated_dir > 0:
Debug.write('Migrated %d directories from %s to %s' % \
(migrated_dir, directory,
self._data_migrate[directory]))
end_time = time.time()
duration = end_time - start_time
Debug.write('Migration took %s' % \
time.strftime("%Hh %Mm %Ss", time.gmtime(duration)))
return self._data_migrate[directory]