import threading
from pathlib import Path
from typing import Any, Union
+import signal
# SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
SUDO_PROC = False
IS_DIGIT_REGEX = re.compile("^[0-9]+$")
STRFTIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
STRFTIME_LOCAL_FORMAT = "%Y-%m-%dT%H:%M:%S"
+PKG_STATE = None
+OTHER_STATE = None
class ArchPkgVersion:
continue
-def print_state_info_and_get_update_list(pkg_state: dict[str, Any]):
+def print_state_info_and_get_update_list(
+ other_state: dict[str, Any], pkg_state: dict[str, Any]
+):
"""Prints the current "checked" state of all pkgs in the config."""
to_update = []
clones_dir_path.mkdir(parents=True)
+def signal_handler(sig, frame):
+ """Handle SIGINT"""
+ global OTHER_STATE, PKG_STATE
+ if OTHER_STATE is not None and PKG_STATE is not None:
+ print_state_info_and_get_update_list(OTHER_STATE, PKG_STATE)
+ sys.exit(0)
+ sys.exit(1)
+
+
if __name__ == "__main__":
+ signal.signal(signal.SIGINT, signal_handler)
editor = None
parser = argparse.ArgumentParser(description="Update AUR pkgs")
parser.add_argument(
pkg_state = {}
other_state = {}
+ PKG_STATE = pkg_state
+ OTHER_STATE = other_state
other_state["logs_dir"] = None
other_state["log_limit"] = 1024 * 1024 * 1024
other_state["error_on_limit"] = False
if i > furthest_checked:
furthest_checked = i
if not ensure_pkg_dir_exists(pkg_list[i], pkg_state, other_state):
- print_state_info_and_get_update_list(pkg_state)
+ print_state_info_and_get_update_list(other_state, pkg_state)
sys.exit(1)
if (
"repo_path" not in pkg_state[pkg_list[i]]
pkg_list[i],
other_state=other_state,
)
- print_state_info_and_get_update_list(pkg_state)
+ print_state_info_and_get_update_list(other_state, pkg_state)
sys.exit(1)
if skip_on_same_ver and i >= furthest_checked:
check_pkg_version_result = check_pkg_version(
i -= 1
continue
else: # check_pkg_build_result == "abort":
- print_state_info_and_get_update_list(pkg_state)
+ print_state_info_and_get_update_list(other_state, pkg_state)
sys.exit(1)
while True:
if (
going_back = True
break
else: # confirm_result_result == "abort"
- print_state_info_and_get_update_list(pkg_state)
+ print_state_info_and_get_update_list(other_state, pkg_state)
sys.exit(1)
if going_back:
going_back = False
i += 1
log_print("Showing current actions:", other_state=other_state)
- pkgs_to_update = print_state_info_and_get_update_list(pkg_state)
+ pkgs_to_update = print_state_info_and_get_update_list(
+ other_state, pkg_state
+ )
if len(pkgs_to_update) > 0:
log_print("Continue? [Y/n]", other_state=other_state)
user_input = sys.stdin.buffer.readline().decode().strip().lower()