Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds+github@gmail.com>2020-12-06 17:12:12 +0100
committerAnton Hvornum <anton.feeds+github@gmail.com>2020-12-06 17:12:12 +0100
commit22e1271a0b339947b2434c19d770f46947d3bfa5 (patch)
treeff77589c5ea3a64a74a9d2a7be071b8baee4850c /archinstall
parenta0c9e58c822448fe69ca7bcc1e36ecb48dfbc964 (diff)
Making list_examples() results cached
This to lock in found modules, in case paths dissapear during runtime.
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/__main__.py1
-rw-r--r--archinstall/lib/profiles.py16
2 files changed, 9 insertions, 8 deletions
diff --git a/archinstall/__main__.py b/archinstall/__main__.py
index e8843ae5..63c2f715 100644
--- a/archinstall/__main__.py
+++ b/archinstall/__main__.py
@@ -13,7 +13,6 @@ def run_as_a_module():
"""
# Add another path for finding profiles, so that list_profiles() in Script() can find guided.py, unattended.py etc.
- print('ID in module:', id(archinstall.storage), archinstall.storage)
archinstall.storage['PROFILE_PATH'].append(os.path.abspath(f'{os.path.dirname(__file__)}/examples'))
if len(sys.argv) == 1:
diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py
index 643c1e77..dc957da4 100644
--- a/archinstall/lib/profiles.py
+++ b/archinstall/lib/profiles.py
@@ -22,7 +22,6 @@ def list_profiles(filter_irrelevant_macs=True, subpath=''):
cache = {}
# Grab all local profiles found in PROFILE_PATH
- print('ID in profiles:', id(storage), storage)
for PATH_ITEM in storage['PROFILE_PATH']:
for root, folders, files in os.walk(os.path.abspath(os.path.expanduser(PATH_ITEM+subpath))):
for file in files:
@@ -75,6 +74,7 @@ class Script():
self.installer = installer
self.converted_path = None
self.spec = None
+ self.examples = None
self.namespace = os.path.splitext(os.path.basename(self.path))[0]
def __enter__(self, *args, **kwargs):
@@ -105,13 +105,14 @@ class Script():
# The Profile was not a direct match on a remote URL
if not parsed_url.scheme:
# Try to locate all local or known URL's
- examples = list_profiles()
+ if not self.examples:
+ self.examples = list_profiles()
- if f"{self.profile}" in examples:
- return self.localize_path(examples[self.profile]['path'])
+ if f"{self.profile}" in self.examples:
+ return self.localize_path(self.examples[self.profile]['path'])
# TODO: Redundant, the below block shouldnt be needed as profiles are stripped of their .py, but just in case for now:
- elif f"{self.profile}.py" in examples:
- return self.localize_path(examples[f"{self.profile}.py"]['path'])
+ elif f"{self.profile}.py" in self.examples:
+ return self.localize_path(self.examples[f"{self.profile}.py"]['path'])
# Path was not found in any known examples, check if it's an abolute path
if os.path.isfile(self.profile):
@@ -167,7 +168,8 @@ class Application(Profile):
# The Profile was not a direct match on a remote URL
if not parsed_url.scheme:
# Try to locate all local or known URL's
- examples = list_profiles(subpath='/applications')
+ if not self.examples:
+ self.examples = list_profiles(subpath='/applications')
if f"{self.profile}" in examples:
return self.localize_path(examples[self.profile]['path'])