diff options
| author | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2023-07-20 21:19:29 +0100 |
|---|---|---|
| committer | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2023-07-20 21:20:55 +0100 |
| commit | 0a07704d6dc53bf3a35d4aadfa240586f55e9487 (patch) | |
| tree | dc7d45dfd0b74b58fa7f19d09c61b4981cd7dc25 /util | |
| parent | 961c56632ba5c2e3937bced415697096ef8c8344 (diff) | |
Replace python installer
Diffstat (limited to 'util')
| -rw-r--r-- | util/exceptions.py | 2 | ||||
| -rw-r--r-- | util/helpers.py | 13 | ||||
| -rw-r--r-- | util/prompt.py | 12 | ||||
| -rw-r--r-- | util/runners.py | 41 |
4 files changed, 0 insertions, 68 deletions
diff --git a/util/exceptions.py b/util/exceptions.py deleted file mode 100644 index b14896d..0000000 --- a/util/exceptions.py +++ /dev/null @@ -1,2 +0,0 @@ -class StepFailedError(Exception): - pass diff --git a/util/helpers.py b/util/helpers.py deleted file mode 100644 index 5f970df..0000000 --- a/util/helpers.py +++ /dev/null @@ -1,13 +0,0 @@ -import os - -OS_TYPE = os.getenv("OS_TYPE") - - -# Returns True if all preconditions pass -def check_preconditions(obj): - if "preconditions" in obj: - if ("os" in obj["preconditions"] - and obj["preconditions"]["os"] != OS_TYPE): - return False - - return True diff --git a/util/prompt.py b/util/prompt.py deleted file mode 100644 index d6eb17b..0000000 --- a/util/prompt.py +++ /dev/null @@ -1,12 +0,0 @@ -import sys - - -def query_yes_no(question, default): - if default == True: - prompt = " [Y/n] " - else: - prompt = " [y/N] " - - sys.stdout.write(question + prompt) - choice = input().lower() - return True if choice == "y" else (False if choice == "n" else default) diff --git a/util/runners.py b/util/runners.py deleted file mode 100644 index dbfcf1f..0000000 --- a/util/runners.py +++ /dev/null @@ -1,41 +0,0 @@ -import os -import re -from util.exceptions import StepFailedError -from termcolor import colored - -HOME = os.getenv("HOME") -OVERWRITE_FILES = os.getenv("OVERWRITE_FILES") - - -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}") - if os.path.exists(destination): - if OVERWRITE_FILES == "1": - os.remove(destination) - print(colored(" (File overwritten)", "yellow")) - else: - print(colored(" (File already exists)", "yellow")) - return - - try: - os.link(source, destination) - except OSError as e: - raise StepFailedError("Link raised exeption: " + str(e)) from e - except Exception as e: - raise StepFailedError("Link raised exeption: " + str(e)) from e |
