From 666557172d7b1bc28e8d9ba14b57122734876867 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Wed, 28 Aug 2024 17:19:52 +0900 Subject: [PATCH] Add opt to show "install" pkgs state when SIGUSR1 --- example_config.toml | 2 ++ update.py | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/example_config.toml b/example_config.toml index b00f56d..abae3c2 100644 --- a/example_config.toml +++ b/example_config.toml @@ -24,6 +24,8 @@ error_on_limit = false datetime_in_local_time = true # If true, all builds will be done in a tmpfs. Recommended to have a lot of RAM and/or swap. tmpfs = false +# If true, only packages to be built will be printed when USR1 is signaled. +print_state_info_only_building_sigusr1 = true ########## END OF MANDATORY VARIABLES # Each [[entry]] needs a "name". diff --git a/update.py b/update.py index 87b2691..7046043 100755 --- a/update.py +++ b/update.py @@ -1758,12 +1758,26 @@ def print_state_info_and_get_update_list( name_space = " " * (max_name_len - len(pkg_name)) if "state" in pkg_dict: state_str = '"' + pkg_dict["state"] + '"' - log_print( - f" {pkg_name}{name_space}: pre_state is {state_str: <13}, build_state is \"{pkg_dict['build_status']}\"", - other_state=other_state, - ) - if pkg_dict["state"] == "install": - to_update.append(pkg_name) + if ("print_state_SIGUSR1" in other_state + and type(other_state["print_state_SIGUSR1"]) is bool + and other_state["print_state_SIGUSR1"] + and "print_state_info_only_building_sigusr1" in other_state + and type(other_state["print_state_info_only_building_sigusr1"]) is bool + and other_state["print_state_info_only_building_sigusr1"]): + if state_str == '"install"': + log_print( + f" {pkg_name}{name_space}: pre_state is {state_str: <13}, build_state is \"{pkg_dict['build_status']}\"", + other_state=other_state, + ) + if pkg_dict["state"] == "install": + to_update.append(pkg_name) + else: + log_print( + f" {pkg_name}{name_space}: pre_state is {state_str: <13}, build_state is \"{pkg_dict['build_status']}\"", + other_state=other_state, + ) + if pkg_dict["state"] == "install": + to_update.append(pkg_name) else: log_print( f" {pkg_name}{name_space}: not reached", @@ -1893,7 +1907,9 @@ def signal_handler(sig, frame): """Handle SIGINT and SIGUSR1.""" global OTHER_STATE, PKG_STATE if OTHER_STATE is not None and PKG_STATE is not None: + OTHER_STATE["print_state_SIGUSR1"] = signal.Signals(sig) is signal.SIGUSR1 print_state_info_and_get_update_list(OTHER_STATE, PKG_STATE) + OTHER_STATE["print_state_SIGUSR1"] = False if signal.Signals(sig) is not signal.SIGINT: return OTHER_STATE["stop_building"] = True @@ -2158,6 +2174,8 @@ def main(): other_state["logs_dir"] = None other_state["log_limit"] = 1024 * 1024 * 1024 other_state["error_on_limit"] = False + other_state["print_state_SIGUSR1"] = False + other_state["print_state_info_only_building_sigusr1"] = True if args.pkg and not args.config: for pkg in args.pkg: pkg_state[pkg] = {} @@ -2338,6 +2356,13 @@ def main(): other_state["tmpfs"] = True else: other_state["tmpfs"] = False + if ("print_state_info_only_building_sigusr1" in d + and type(d["print_state_info_only_building_sigusr1"]) is bool): + other_state["print_state_info_only_building_sigusr1"] = \ + d["print_state_info_only_building_sigusr1"] + print("State info print on SIGUSR1 is set to: \"{}\"".format( + other_state["print_state_info_only_building_sigusr1"] + )) else: log_print( 'ERROR: At least "--config" or "--pkg" must be specified',