Cleaned up after some debugging.

This commit is contained in:
Anton Hvornum 2021-03-21 16:35:26 +01:00
parent cbb4629849
commit 3baaefb97d
No known key found for this signature in database
GPG Key ID: F1234C5BA67C59DF
2 changed files with 2 additions and 6 deletions

View File

@ -1,7 +1,7 @@
import os, urllib.request, urllib.parse, ssl, json, re import os, urllib.request, urllib.parse, ssl, json, re
import importlib.util, sys, glob, hashlib import importlib.util, sys, glob, hashlib
from collections import OrderedDict from collections import OrderedDict
from .general import multisplit, sys_command, log from .general import multisplit, sys_command
from .exceptions import * from .exceptions import *
from .networking import * from .networking import *
from .output import log, LOG_LEVELS from .output import log, LOG_LEVELS
@ -77,7 +77,7 @@ class Script():
self.examples = None self.examples = None
self.namespace = os.path.splitext(os.path.basename(self.path))[0] self.namespace = os.path.splitext(os.path.basename(self.path))[0]
self.original_namespace = self.namespace self.original_namespace = self.namespace
print(f"Script {self} loaded with namespace: {self.namespace}") log(f"Script {self} has been loaded with namespace '{self.namespace}'")
def __enter__(self, *args, **kwargs): def __enter__(self, *args, **kwargs):
self.execute() self.execute()
@ -133,8 +133,6 @@ class Script():
self.spec = importlib.util.spec_from_file_location(self.namespace, self.path) self.spec = importlib.util.spec_from_file_location(self.namespace, self.path)
imported = importlib.util.module_from_spec(self.spec) imported = importlib.util.module_from_spec(self.spec)
sys.modules[self.namespace] = imported sys.modules[self.namespace] = imported
print(f"Imported {self} into sys.modules with namespace {self.namespace}")
return self return self
@ -175,7 +173,6 @@ class Profile(Script):
# trigger a traditional: # trigger a traditional:
# if __name__ == 'moduleName' # if __name__ == 'moduleName'
if '__name__' in source_data and '_prep_function' in source_data: if '__name__' in source_data and '_prep_function' in source_data:
print(f"Checking if {self} has _prep_function by importing with namespace {self.namespace}.py")
with self.load_instructions(namespace=f"{self.namespace}.py") as imported: with self.load_instructions(namespace=f"{self.namespace}.py") as imported:
if hasattr(imported, '_prep_function'): if hasattr(imported, '_prep_function'):
return True return True

View File

@ -169,7 +169,6 @@ def ask_user_questions():
# Check the potentially selected profiles preperations to get early checks if some additional questions are needed. # Check the potentially selected profiles preperations to get early checks if some additional questions are needed.
if archinstall.arguments['profile'] and archinstall.arguments['profile'].has_prep_function(): if archinstall.arguments['profile'] and archinstall.arguments['profile'].has_prep_function():
print(f"{archinstall.arguments['profile']} has prep-function, loading with namespace {archinstall.arguments['profile'].namespace}.py")
with archinstall.arguments['profile'].load_instructions(namespace=f"{archinstall.arguments['profile'].namespace}.py") as imported: with archinstall.arguments['profile'].load_instructions(namespace=f"{archinstall.arguments['profile'].namespace}.py") as imported:
if not imported._prep_function(): if not imported._prep_function():
archinstall.log( archinstall.log(