aboutsummaryrefslogtreecommitdiff
path: root/src/common.py
diff options
context:
space:
mode:
authorame <[email protected]>2025-03-03 03:07:15 -0600
committerame <[email protected]>2025-03-03 03:07:15 -0600
commitbb96c6e30f393bb135e2f6b7ddb314027f0aee54 (patch)
tree9e26ea7d6eb41633436edc6091d01b6a3bb6b12d /src/common.py
parent73cbed952c5d2cdfdaceb5f8c2b19c77738b5186 (diff)
qol update
Diffstat (limited to 'src/common.py')
-rw-r--r--src/common.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/common.py b/src/common.py
index 416d836..f1a64bf 100644
--- a/src/common.py
+++ b/src/common.py
@@ -13,12 +13,14 @@ from typing import TypedDict
REAL_REPO = ""
REPOS_LOCATION = "/var/db/repos"
REPO_LOC = ""
+ROOT = "sudo"
try:
with open(os.path.expanduser("~/.config/gpo-steal/config.yaml"), "r") as f:
cfg = yaml.safe_load(f.read())
REAL_REPO = cfg["repo"]
REPO_LOC = cfg["repo_location"]
+ ROOT = cfg["elevation"]
except FileNotFoundError:
print("no configuration found, should be in ~/.config/gpo-steal/config.yaml")
exit(1)
@@ -36,11 +38,6 @@ class repo_pair(TypedDict):
repos = {}
tracked = {}
-root = ""
-if not shutil.which("sudo") is None:
- root = "sudo"
-if not shutil.which("doas") is None:
- root = "doas"
try:
with open(REPO_CFG_LOC, "r") as f:
repos = yaml.safe_load(f.read()) or repos
@@ -59,3 +56,8 @@ def save() -> None:
with open(TRACKED_CFG_LOC, "w") as f:
yaml.dump(tracked, f)
+
+def eexec(cmd) -> None:
+ run = f"{ROOT} sh -c '{cmd}'"
+ print(run)
+ os.system(run)