1
0
Fork 0
mirror of synced 2024-06-08 13:34:48 +12:00

show run duration after each archived link in cli output

This commit is contained in:
Nick Sweeting 2021-04-10 07:52:01 -04:00
parent 6053f4e415
commit 62078a77f8
2 changed files with 6 additions and 3 deletions

View file

@ -96,6 +96,7 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s
log_link_archiving_started(link, out_dir, is_new)
link = link.overwrite(updated=datetime.now(timezone.utc))
stats = {'skipped': 0, 'succeeded': 0, 'failed': 0}
start_ts = datetime.now(timezone.utc)
for method_name, should_run, method_function in ARCHIVE_METHODS:
try:
@ -142,7 +143,7 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s
write_link_details(link, out_dir=out_dir, skip_sql_index=False)
log_link_archiving_finished(link, link.link_dir, is_new, stats)
log_link_archiving_finished(link, link.link_dir, is_new, stats, start_ts)
except KeyboardInterrupt:
try:

View file

@ -379,7 +379,7 @@ def log_link_archiving_started(link: "Link", link_dir: str, is_new: bool):
pretty_path(link_dir),
))
def log_link_archiving_finished(link: "Link", link_dir: str, is_new: bool, stats: dict):
def log_link_archiving_finished(link: "Link", link_dir: str, is_new: bool, stats: dict, start_ts: datetime):
total = sum(stats.values())
if stats['failed'] > 0 :
@ -390,7 +390,9 @@ def log_link_archiving_finished(link: "Link", link_dir: str, is_new: bool, stats
_LAST_RUN_STATS.succeeded += 1
size = get_dir_size(link_dir)
print(' {black}{} files ({}){reset}'.format(size[2], printable_filesize(size[0]), **ANSI))
end_ts = datetime.now(timezone.utc)
duration = str(end_ts - start_ts).split('.')[0]
print(' {black}{} files ({}) in {}s {reset}'.format(size[2], printable_filesize(size[0]), duration, **ANSI))
def log_archive_method_started(method: str):