From 6b1b61f98813a58286e099d92767e01c2d40bc18 Mon Sep 17 00:00:00 2001 From: LMBishop <13875753+LMBishop@users.noreply.github.com> Date: Sun, 20 Nov 2022 20:33:13 +0000 Subject: Redo deploy script --- util/runners.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 util/runners.py (limited to 'util/runners.py') diff --git a/util/runners.py b/util/runners.py new file mode 100644 index 0000000..9252d86 --- /dev/null +++ b/util/runners.py @@ -0,0 +1,29 @@ +import os +import re +from util.exceptions import StepFailedError + +HOME = os.getenv("HOME") + + +def run_step(step): + step_type = step["=="] + + if step_type == "run": + do_run(step["command"]) + elif step_type == "link": + do_link(step["from"], step["to"]) + + +def do_run(command): + print(f"! {command}") + if not os.system(command) == 0: + raise StepFailedError("Non-zero return code") + + +def do_link(source, destination): + destination = re.sub(r"^~/", HOME + "/", destination) + print(f"Linking {source} -> {destination}") + try: + os.link(source, destination) + except Exception as e: + raise StepFailedError("Link raised exeption: " + str(e)) from e -- cgit v1.2.3-70-g09d2