more
This commit is contained in:
parent
27314d1f7e
commit
d2fdab9ab7
3 changed files with 51 additions and 13 deletions
|
|
@ -97,6 +97,7 @@ def _download_subscriptions_from_yaml_files(
|
||||||
subscriptions += Subscription.from_file_path(config=config, subscription_path=path)
|
subscriptions += Subscription.from_file_path(config=config, subscription_path=path)
|
||||||
|
|
||||||
for subscription in subscriptions:
|
for subscription in subscriptions:
|
||||||
|
with subscription.exception_handling():
|
||||||
logger.info(
|
logger.info(
|
||||||
"Beginning subscription %s for %s",
|
"Beginning subscription %s for %s",
|
||||||
("dry run" if dry_run else "download"),
|
("dry run" if dry_run else "download"),
|
||||||
|
|
@ -104,7 +105,6 @@ def _download_subscriptions_from_yaml_files(
|
||||||
)
|
)
|
||||||
logger.debug("Subscription full yaml:\n%s", subscription.as_yaml())
|
logger.debug("Subscription full yaml:\n%s", subscription.as_yaml())
|
||||||
|
|
||||||
with subscription.exception_handling():
|
|
||||||
if update_with_info_json:
|
if update_with_info_json:
|
||||||
subscription.update_with_info_json(dry_run=dry_run)
|
subscription.update_with_info_json(dry_run=dry_run)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ def _color_int(value: int) -> str:
|
||||||
return _no_color(str_int)
|
return _no_color(str_int)
|
||||||
|
|
||||||
|
|
||||||
def output_summary(subscriptions: List[Subscription]) -> str:
|
def output_summary(subscriptions: List[Subscription]) -> None:
|
||||||
"""
|
"""
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
|
|
@ -48,6 +48,14 @@ def output_summary(subscriptions: List[Subscription]) -> str:
|
||||||
"""
|
"""
|
||||||
summary: List[str] = []
|
summary: List[str] = []
|
||||||
|
|
||||||
|
# Initialize totals to 0
|
||||||
|
total_subs: int = 0
|
||||||
|
total_added: int = 0
|
||||||
|
total_modified: int = 0
|
||||||
|
total_removed: int = 0
|
||||||
|
total_entries: int = 0
|
||||||
|
total_errors: int = 0
|
||||||
|
|
||||||
# Initialize widths to 0
|
# Initialize widths to 0
|
||||||
width_sub_name: int = 0
|
width_sub_name: int = 0
|
||||||
width_num_entries_added: int = 0
|
width_num_entries_added: int = 0
|
||||||
|
|
@ -90,5 +98,35 @@ def output_summary(subscriptions: List[Subscription]) -> str:
|
||||||
f"{status}"
|
f"{status}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add total
|
||||||
|
total_subs += 1
|
||||||
|
total_added += subscription.num_entries_added
|
||||||
|
total_modified += subscription.num_entries_modified
|
||||||
|
total_removed -= subscription.num_entries_removed
|
||||||
|
total_entries += subscription.num_entries
|
||||||
|
total_errors += int(subscription.exception is not None)
|
||||||
|
|
||||||
|
total_subs_str = f"Total: {total_subs} Subscriptions"
|
||||||
|
total_errors_str = (
|
||||||
|
_green("All Successful")
|
||||||
|
if total_errors == 0
|
||||||
|
else _red(f"{total_errors} Error{'s' if total_errors > 1 else ''}")
|
||||||
|
)
|
||||||
|
|
||||||
|
summary.append("") # new line
|
||||||
|
summary.append(
|
||||||
|
f"{total_subs_str:<{width_sub_name}} "
|
||||||
|
f"{_color_int(total_added):>{width_num_entries_added}} "
|
||||||
|
f"{_color_int(total_modified):>{width_num_entries_modified}} "
|
||||||
|
f"{_color_int(total_removed):>{width_num_entries_removed}} "
|
||||||
|
f"{str(total_entries):>{width_num_entries}} "
|
||||||
|
f"{total_errors_str}"
|
||||||
|
)
|
||||||
|
|
||||||
|
if total_errors > 0:
|
||||||
|
summary.append("")
|
||||||
|
summary.append(f"See `{Logger.debug_log_filename()}` for details on errors.")
|
||||||
|
summary.append("Consider making a GitHub issue including the uploaded log file.")
|
||||||
|
|
||||||
# Hack to always show download summary, even if logs are set to quiet
|
# Hack to always show download summary, even if logs are set to quiet
|
||||||
logger.warning("Download Summary:\n%s", "\n".join(summary))
|
logger.warning("Download Summary:\n%s", "\n".join(summary))
|
||||||
|
|
|
||||||
|
|
@ -260,11 +260,11 @@ def test_transaction_log_to_logger(
|
||||||
|
|
||||||
|
|
||||||
def test_output_summary():
|
def test_output_summary():
|
||||||
subscription_values: List[Tuple[str, int, int, int, int, bool]] = [
|
subscription_values: List[Tuple[str, int, int, int, int, Optional[bool]]] = [
|
||||||
("long_name_but_lil_values", 0, 0, 0, 6, False),
|
("long_name_but_lil_values", 0, 0, 0, 6, None),
|
||||||
("john_smith", 1, 0, 0, 52, False),
|
("john_smith", 1, 0, 0, 52, None),
|
||||||
("david_gore", 0, 0, 0, 4, False),
|
("david_gore", 0, 0, 0, 4, None),
|
||||||
("christopher_snoop", 50, 0, 3, 518, False),
|
("christopher_snoop", 50, 0, 3, 518, None),
|
||||||
("beyond funk", 0, 0, 0, 176, True),
|
("beyond funk", 0, 0, 0, 176, True),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue