本文整理汇总了Python中attic.archive.Archive.save方法的典型用法代码示例。如果您正苦于以下问题:Python Archive.save方法的具体用法?Python Archive.save怎么用?Python Archive.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类attic.archive.Archive
的用法示例。
在下文中一共展示了Archive.save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_create
# 需要导入模块: from attic.archive import Archive [as 别名]
# 或者: from attic.archive.Archive import save [as 别名]
def do_create(self, args):
"""Create new archive"""
t0 = datetime.now()
repository = self.open_repository(args.archive, exclusive=True)
manifest, key = Manifest.load(repository)
cache = Cache(repository, key, manifest, do_files=args.cache_files)
archive = Archive(repository, key, manifest, args.archive.archive, cache=cache,
create=True, checkpoint_interval=args.checkpoint_interval,
numeric_owner=args.numeric_owner, progress=args.progress)
# Add cache dir to inode_skip list
skip_inodes = set()
try:
st = os.stat(get_cache_dir())
skip_inodes.add((st.st_ino, st.st_dev))
except IOError:
pass
# Add local repository dir to inode_skip list
if not args.archive.host:
try:
st = os.stat(args.archive.path)
skip_inodes.add((st.st_ino, st.st_dev))
except IOError:
pass
for path in args.paths:
if path == '-': # stdin
path = 'stdin'
self.print_verbose(path)
try:
archive.process_stdin(path, cache)
except IOError as e:
self.print_error('%s: %s', path, e)
continue
path = os.path.normpath(path)
if args.dontcross:
try:
restrict_dev = os.lstat(path).st_dev
except OSError as e:
self.print_error('%s: %s', path, e)
continue
else:
restrict_dev = None
self._process(archive, cache, args.excludes, args.exclude_caches, skip_inodes, path, restrict_dev)
archive.save(timestamp=args.timestamp)
if args.progress:
archive.stats.show_progress(final=True)
if args.stats:
t = datetime.now()
diff = t - t0
print('-' * 78)
print('Archive name: %s' % args.archive.archive)
print('Archive fingerprint: %s' % hexlify(archive.id).decode('ascii'))
print('Start time: %s' % t0.strftime('%c'))
print('End time: %s' % t.strftime('%c'))
print('Duration: %s' % format_timedelta(diff))
print('Number of files: %d' % archive.stats.nfiles)
archive.stats.print_('This archive:', cache)
print('-' * 78)
return self.exit_code
示例2: do_create
# 需要导入模块: from attic.archive import Archive [as 别名]
# 或者: from attic.archive.Archive import save [as 别名]
def do_create(self, args):
"""Create new archive
"""
t0 = datetime.now()
repository = self.open_repository(args.archive)
manifest, key = Manifest.load(repository)
cache = Cache(repository, key, manifest)
archive = Archive(repository, key, manifest, args.archive.archive, cache=cache,
create=True, checkpoint_interval=args.checkpoint_interval,
numeric_owner=args.numeric_owner)
# Add Attic cache dir to inode_skip list
skip_inodes = set()
try:
st = os.stat(get_cache_dir())
skip_inodes.add((st.st_ino, st.st_dev))
except IOError:
pass
# Add local repository dir to inode_skip list
if not args.archive.host:
try:
st = os.stat(args.archive.path)
skip_inodes.add((st.st_ino, st.st_dev))
except IOError:
pass
for path in args.paths:
path = os.path.normpath(path)
if args.dontcross:
try:
restrict_dev = os.lstat(path).st_dev
except OSError as e:
self.print_error('%s: %s', path, e)
continue
else:
restrict_dev = None
self._process(archive, cache, args.excludes, skip_inodes, path, restrict_dev)
archive.save()
if args.stats:
t = datetime.now()
diff = t - t0
print('-' * 40)
print('Archive name: %s' % args.archive.archive)
print('Archive fingerprint: %s' % hexlify(archive.id).decode('ascii'))
print('Start time: %s' % t0.strftime('%c'))
print('End time: %s' % t.strftime('%c'))
print('Duration: %s' % format_timedelta(diff))
archive.stats.print_()
print('-' * 40)
return self.exit_code