Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds+github@gmail.com>2020-12-06 11:37:09 +0100
committerAnton Hvornum <anton.feeds+github@gmail.com>2020-12-06 11:37:09 +0100
commitbef89260041d76d43cda74fc408d583aa900c12d (patch)
tree778a2e004d8b967a2aa7292c7eb026f93758742e /archinstall/lib
parent0e8aee0b5411565e85857ad338249f7f0e774af9 (diff)
Update profiles.py
Diffstat (limited to 'archinstall/lib')
-rw-r--r--archinstall/lib/profiles.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py
index 3e40e1f8..f51db66d 100644
--- a/archinstall/lib/profiles.py
+++ b/archinstall/lib/profiles.py
@@ -76,6 +76,15 @@ class Script():
self.spec = None
self.namespace = os.path.splitext(os.path.basename(self.path))[0]
+ def __enter__(self, *args, **kwargs):
+ self.execute()
+ return sys.modules[self.namespace]
+
+ def __exit__(self, *args, **kwargs):
+ # TODO: https://stackoverflow.com/questions/28157929/how-to-safely-handle-an-exception-inside-a-context-manager
+ if len(args) >= 2 and args[1]:
+ raise args[1]
+
def localize_path(self, profile_path):
if (url := urllib.parse.urlparse(profile_path)).scheme and url.scheme in ('https', 'http'):
if not self.converted_path:
@@ -130,7 +139,7 @@ class Script():
__builtins__['installation'] = self.installer # TODO: Replace this with a import archinstall.session instead
self.spec.loader.exec_module(sys.modules[self.namespace])
- return True
+ return sys.modules[self.namespace]
class Profile(Script):
def __init__(self, installer, path, args={}):