Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds+github@gmail.com>2019-11-29 13:21:39 +0100
committerAnton Hvornum <anton.feeds+github@gmail.com>2019-11-29 13:21:39 +0100
commita83b21ec016e4302fb1e767e338527865beefba3 (patch)
tree95478ccd2b71a18d61f3da6b9697d1b9ffd2d4c6 /archinstall.py
parentd89bacdf9f187c1737439ccdef53254fc84749c5 (diff)
Fixing offline deployment a bit
Diffstat (limited to 'archinstall.py')
-rw-r--r--archinstall.py48
1 files changed, 28 insertions, 20 deletions
diff --git a/archinstall.py b/archinstall.py
index 268787ec..2a51a35e 100644
--- a/archinstall.py
+++ b/archinstall.py
@@ -696,29 +696,37 @@ def get_application_instructions(target):
return instructions
+def get_local_instructions(target):
+ instructions = oDict()
+ local_path = './deployments' if os.path.isfile('./archinstall.py') else './archinstall/deployments' # Dangerous assumption
+ if os.path.isfile(f'{local_path}/{target}.json'):
+ with open(f'{local_path}/{target}.json', 'r') as fh:
+ instructions = fh.read()
+
+ print('[N] Found local instructions called: {}'.format(target))
+ else:
+ print('[N] No instructions found called: {}'.format(target))
+ return instructions
+
def get_instructions(target, *positionals, **kwargs):
instructions = oDict()
- try:
- instructions = grab_url_data('{}/{}.json'.format(args['profiles-path'], target)).decode('UTF-8')
- print('[N] Found net-deploy instructions called: {}'.format(target))
- except urllib.error.HTTPError:
- print('[N] Could not find remote instructions. Trying local instructions under ./deployments')
- local_path = './deployments' if os.path.isfile('./archinstall.py') else './archinstall/deployments' # Dangerous assumption
- if os.path.isfile(f'{local_path}/{target}.json'):
- with open(f'{local_path}/{target}.json', 'r') as fh:
- instructions = fh.read()
+ if get_default_gateway_linux():
+ try:
+ instructions = grab_url_data('{}/{}.json'.format(args['profiles-path'], target)).decode('UTF-8')
+ print('[N] Found net-deploy instructions called: {}'.format(target))
+ except urllib.error.HTTPError:
+ print('[N] Could not find remote instructions. Trying local instructions under ./deployments')
+ isntructions = get_local_instructions(target, *positionals)
+ else:
+ isntructions = get_local_instructions(target, *positionals)
- print('[N] Found local instructions called: {}'.format(target))
- else:
- print('[N] No instructions found called: {}'.format(target))
- return instructions
-
- try:
- instructions = json.loads(instructions, object_pairs_hook=oDict)
- except:
- print('[E] JSON syntax error in {}'.format('{}/{}.json'.format(args['profiles-path'], target)))
- traceback.print_exc()
- exit(1)
+ if type(instructions) in (dict, oDict):
+ try:
+ instructions = json.loads(instructions, object_pairs_hook=oDict)
+ except:
+ print('[E] JSON syntax error in {}'.format('{}/{}.json'.format(args['profiles-path'], target)))
+ traceback.print_exc()
+ exit(1)
return instructions