index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Anton Hvornum <anton.feeds+github@gmail.com> | 2020-08-04 14:30:15 +0200 |
---|---|---|
committer | Anton Hvornum <anton.feeds+github@gmail.com> | 2020-08-04 14:30:15 +0200 |
commit | 9d7962f39c1d8d8321da9c3653ca7e8d1def5c9b (patch) | |
tree | 60ab462f6a11a7476ada8e77c9f833f1fd06dc4e /archinstall | |
parent | 2dea2426b2426a284d5789770c136356ded69aa7 (diff) |
-rw-r--r-- | archinstall/lib/profiles.py | 39 |
diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index c1e2f8a9..f0de62d3 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -14,6 +14,16 @@ def grab_url_data(path): response = urllib.request.urlopen(safe_path, context=ssl_context) return response.read() +def list_profiles(base='./profiles/'): + # TODO: Grab from github page as well, not just local static files + cache = {} + for root, folders, files in os.walk(base): + for file in files: + if os.path.splitext(file)[1] == '.py': + cache[file] = os.path.join(root, file) + break + return cache + class Imported(): def __init__(self, spec, imported): self.spec = spec @@ -44,8 +54,6 @@ class Profile(): return os.path.abspath(f'{self.name}') for path in ['./profiles', '/etc/archinstall', '/etc/archinstall/profiles', os.path.abspath(f'{os.path.dirname(__file__)}/../profiles')]: # Step out of /lib - if os.path.isfile(f'{path}/{self.name}.json'): - return os.path.abspath(f'{path}/{self.name}.json') elif os.path.isfile(f'{path}/{self.name}.py'): return os.path.abspath(f'{path}/{self.name}.py') @@ -55,18 +63,6 @@ class Profile(): return f'{UPSTREAM_URL}/{self.name}.py' except urllib.error.HTTPError: pass - try: - if (cache := grab_url_data(f'{UPSTREAM_URL}/{self.name}.json')): - self._cache = cache - return f'{UPSTREAM_URL}/{self.name}.json' - except urllib.error.HTTPError: - pass - try: - if (cache := grab_url_data(f'{UPSTREAM_URL}/{self.name}.json')): - self._cache = cache - return f'{UPSTREAM_URL}/{self.name}.json' - except urllib.error.HTTPError: - pass return None @@ -80,11 +76,8 @@ class Profile(): imported = importlib.util.module_from_spec(spec) sys.modules[os.path.basename(absolute_path)] = imported return Imported(spec, imported) - elif absolute_path[:4] == 'http': - return json.loads(self._cache) - - with open(absolute_path, 'r') as fh: - return json.load(fh) + else: + raise ProfileError(f'Extension {os.path.splitext(absolute_path)[1]} is not a supported profile model. Only .py is supported.') raise ProfileError(f'No such profile ({self.name}) was found either locally or in {UPSTREAM_URL}') @@ -190,8 +183,6 @@ class Application(Profile): for path in ['./applications', './profiles/applications', '/etc/archinstall/applications', '/etc/archinstall/profiles/applications', os.path.abspath(f'{os.path.dirname(__file__)}/../profiles/applications')]: if os.path.isfile(f'{path}/{self.name}.py'): return os.path.abspath(f'{path}/{self.name}.py') - elif os.path.isfile(f'{path}/{self.name}.json'): - return os.path.abspath(f'{path}/{self.name}.json') try: if (cache := grab_url_data(f'{UPSTREAM_URL}/applications/{self.name}.py')): @@ -199,11 +190,5 @@ class Application(Profile): return f'{UPSTREAM_URL}/applications/{self.name}.py' except urllib.error.HTTPError: pass - try: - if (cache := grab_url_data(f'{UPSTREAM_URL}/applications/{self.name}.json')): - self._cache = cache - return f'{UPSTREAM_URL}/applications/{self.name}.json' - except urllib.error.HTTPError: - pass return None
\ No newline at end of file |