mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-12 22:25:44 -04:00
show run duration after each archived link in cli output
This commit is contained in:
parent
6053f4e415
commit
62078a77f8
2 changed files with 6 additions and 3 deletions
|
@ -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)
|
log_link_archiving_started(link, out_dir, is_new)
|
||||||
link = link.overwrite(updated=datetime.now(timezone.utc))
|
link = link.overwrite(updated=datetime.now(timezone.utc))
|
||||||
stats = {'skipped': 0, 'succeeded': 0, 'failed': 0}
|
stats = {'skipped': 0, 'succeeded': 0, 'failed': 0}
|
||||||
|
start_ts = datetime.now(timezone.utc)
|
||||||
|
|
||||||
for method_name, should_run, method_function in ARCHIVE_METHODS:
|
for method_name, should_run, method_function in ARCHIVE_METHODS:
|
||||||
try:
|
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)
|
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:
|
except KeyboardInterrupt:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -379,7 +379,7 @@ def log_link_archiving_started(link: "Link", link_dir: str, is_new: bool):
|
||||||
pretty_path(link_dir),
|
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())
|
total = sum(stats.values())
|
||||||
|
|
||||||
if stats['failed'] > 0 :
|
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
|
_LAST_RUN_STATS.succeeded += 1
|
||||||
|
|
||||||
size = get_dir_size(link_dir)
|
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):
|
def log_archive_method_started(method: str):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue