Storing original namespace of profiles as they were during initation. Namespaces now get reverted back to the original state just before .install() is called. This ensures any temporary namespace changes made during prep-checks etc doesn't stick around when we try to install.

This commit is contained in:
Anton Hvornum 2021-03-21 15:16:41 +01:00
parent a9f177e722
commit 6081733422
No known key found for this signature in database
GPG Key ID: F1234C5BA67C59DF
1 changed files with 13 additions and 2 deletions

View File

@ -76,6 +76,7 @@ class Script():
self.spec = None
self.examples = None
self.namespace = os.path.splitext(os.path.basename(self.path))[0]
self.original_namespace = self.namespace
print(f"Script {self} loaded with namespace: {self.namespace}")
def __enter__(self, *args, **kwargs):
@ -149,7 +150,6 @@ class Script():
class Profile(Script):
def __init__(self, installer, path, args={}):
super(Profile, self).__init__(path, installer)
self._cache = None
def __dump__(self, *args, **kwargs):
return {'path' : self.path}
@ -158,6 +158,10 @@ class Profile(Script):
return f'Profile({os.path.basename(self.profile)})'
def install(self):
# Before installing, revert any temporary changes to the namespace.
# This ensures that the namespace during installation is the original initation namespace.
# (For instance awesome instead of aweosme.py or app-awesome.py)
self.namespace = self.original_namespace
return self.execute()
def has_prep_function(self):
@ -206,4 +210,11 @@ class Application(Profile):
elif parsed_url.scheme in ('https', 'http'):
return self.localize_path(self.profile)
else:
raise ProfileNotFound(f"Application cannot handle scheme {parsed_url.scheme}")
raise ProfileNotFound(f"Application cannot handle scheme {parsed_url.scheme}")
def install(self):
# Before installing, revert any temporary changes to the namespace.
# This ensures that the namespace during installation is the original initation namespace.
# (For instance awesome instead of aweosme.py or app-awesome.py)
self.namespace = self.original_namespace
return self.execute()