From ceaeac43f72c0ca69b37d1c5e286ca70ec95b6f7 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Tue, 8 Jul 2025 15:47:34 +1200 Subject: [PATCH] Use tasknames in --statuscsv Also fix fallbacks for property statuses without a `task_property_status` entry. --- sbysrc/sby.py | 2 +- sbysrc/sby_status.py | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sbysrc/sby.py b/sbysrc/sby.py index 827b7cd..997e134 100644 --- a/sbysrc/sby.py +++ b/sbysrc/sby.py @@ -97,7 +97,7 @@ if status_show or status_reset or status_show_csv: status_db.print_status_summary() if status_show_csv: - status_db.print_status_summary_csv() + status_db.print_status_summary_csv(tasknames) status_db.db.close() diff --git a/sbysrc/sby_status.py b/sbysrc/sby_status.py index 587b61a..a6fff5f 100644 --- a/sbysrc/sby_status.py +++ b/sbysrc/sby_status.py @@ -413,7 +413,7 @@ class SbyStatusDb: return {row["id"]: parse_status_data_row(row) for row in rows} - def print_status_summary_csv(self): + def print_status_summary_csv(self, tasknames): # get all statuses all_properties = self.all_status_data_joined() @@ -424,6 +424,8 @@ class SbyStatusDb: # find summary for each task/property combo prop_map: dict[(str, str), dict[str, (int, int)]] = {} for row, prop_status in all_properties.items(): + if tasknames and prop_status['task_name'] not in tasknames: + continue status = prop_status['status'] this_depth = prop_status['data'].get('step') this_kind = prop_status['trace_kind'] @@ -471,7 +473,7 @@ def combine_statuses(statuses): def parse_status_data_row(raw: sqlite3.Row): row_dict = dict(raw) row_dict["name"] = json.loads(row_dict.get("name", "null")) - row_dict["data"] = json.loads(row_dict.get("data", "null")) + row_dict["data"] = json.loads(row_dict.get("data") or "{}") return row_dict def format_status_data_csvline(row: dict|None) -> str: @@ -490,8 +492,11 @@ def format_status_data_csvline(row: dict|None) -> str: ] return ','.join(csv_header) else: - engine = row['data'].get('engine', row['data']['source']) - time = row['status_created'] - row['created'] + engine = row['data'].get('engine', row['data'].get('source')) + try: + time = row['status_created'] - row['created'] + except TypeError: + time = 0 name = row['hdlname'] depth = row['data'].get('step') try: @@ -507,7 +512,7 @@ def format_status_data_csvline(row: dict|None) -> str: name or pretty_path(row['name']), row['location'], row['kind'], - row['status'], + row['status'] or "UNKNOWN", trace_path, depth, ]