From 54e2161e2948b9d30ad216c926f11f96246ed1c4 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Wed, 30 Sep 2020 09:56:35 +0000 Subject: Tweaked the import logic so that the Imported() class returns the actual module imported when executing the import, rather than returning itself. Also fixed awesome so that it loads and looks for _prep_function() with a safe and correct namespace --- archinstall/lib/profiles.py | 2 +- examples/guided.py | 2 +- profiles/awesome.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index 6d7a8b42..47e6dd36 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -47,7 +47,7 @@ class Imported(): def __enter__(self, *args, **kwargs): self.spec.loader.exec_module(self.imported) - return self + return self.imported def __exit__(self, *args, **kwargs): # TODO: https://stackoverflow.com/questions/28157929/how-to-safely-handle-an-exception-inside-a-context-manager diff --git a/examples/guided.py b/examples/guided.py index 0447df26..dcc8279c 100644 --- a/examples/guided.py +++ b/examples/guided.py @@ -94,7 +94,7 @@ while 1: while 1: profile = archinstall.select_profile(archinstall.list_profiles()) - if profile != str: # Got a imported profile + if type(profile) != str: # Got a imported profile if not profile[1]._prep_function(): archinstall.log(' * Profile\'s preperation requirements was not fulfilled.', bg='black', fg='red') continue diff --git a/profiles/awesome.py b/profiles/awesome.py index a0267156..9b831394 100644 --- a/profiles/awesome.py +++ b/profiles/awesome.py @@ -11,7 +11,7 @@ def _prep_function(*args, **kwargs): """ profile = archinstall.Profile(None, 'xorg') - with profile.load_instructions() as imported: + with profile.load_instructions(namespace='xorg.py') as imported: if hasattr(imported, '_prep_function'): return imported._prep_function() else: -- cgit v1.2.3-70-g09d2