Fixed generic_select() to accept (and break on) empty selects.
This commit is contained in:
parent
abfeeb8dd0
commit
b3bcf54a2c
|
|
@ -24,7 +24,9 @@ def generic_select(options, input_text="Select one of the above by index or abso
|
|||
print(f"{index}: {option}")
|
||||
|
||||
selected_option = input(input_text)
|
||||
if selected_option.isdigit():
|
||||
if len(selected_option.strip()) <= 0:
|
||||
return None
|
||||
elif selected_option.isdigit():
|
||||
selected_option = options[int(selected_option)]
|
||||
elif selected_option in options:
|
||||
pass # We gave a correct absolute value
|
||||
|
|
|
|||
|
|
@ -184,32 +184,33 @@ while 1:
|
|||
print(e)
|
||||
|
||||
# Optionally configure one network interface.
|
||||
while 1:
|
||||
interfaces = archinstall.list_interfaces() # {MAC: Ifname}
|
||||
archinstall.storage['_guided']['network'] = None
|
||||
#while 1:
|
||||
interfaces = archinstall.list_interfaces() # {MAC: Ifname}
|
||||
archinstall.storage['_guided']['network'] = None
|
||||
|
||||
nic = archinstall.generic_select(interfaces.values(), "Select one network interface to configure (leave blank to skip): ")
|
||||
if nic:
|
||||
mode = archinstall.generic_select(['DHCP (auto detect)', 'IP (static)'], f"Select which mode to configure for {nic}: ")
|
||||
if mode == 'IP (static)':
|
||||
while 1:
|
||||
ip = input(f"Enter the IP and subnet for {nic} (example: 192.168.0.5/24): ").strip()
|
||||
if ip:
|
||||
break
|
||||
else:
|
||||
ArchInstall.log(
|
||||
"You need to enter a valid IP in IP-config mode.",
|
||||
level=archinstall.LOG_LEVELS.Warning,
|
||||
bg='black',
|
||||
fg='red'
|
||||
)
|
||||
nic = archinstall.generic_select(interfaces.values(), "Select one network interface to configure (leave blank to skip): ")
|
||||
if nic:
|
||||
mode = archinstall.generic_select(['DHCP (auto detect)', 'IP (static)'], f"Select which mode to configure for {nic}: ")
|
||||
if mode == 'IP (static)':
|
||||
while 1:
|
||||
ip = input(f"Enter the IP and subnet for {nic} (example: 192.168.0.5/24): ").strip()
|
||||
if ip:
|
||||
break
|
||||
else:
|
||||
ArchInstall.log(
|
||||
"You need to enter a valid IP in IP-config mode.",
|
||||
level=archinstall.LOG_LEVELS.Warning,
|
||||
bg='black',
|
||||
fg='red'
|
||||
)
|
||||
|
||||
gateway = input('Enter your gateway (router) IP address or leave blank for none: ').strip()
|
||||
dns = input('Enter your DNS servers (space separated, blank for none): ').strip().split(' ')
|
||||
gateway = input('Enter your gateway (router) IP address or leave blank for none: ').strip()
|
||||
dns = input('Enter your DNS servers (space separated, blank for none): ').strip().split(' ')
|
||||
|
||||
archinstall.storage['_guided']['network'] = {'nic': nic, 'dhcp': False, 'ip': ip, 'gateway' : gateway, 'dns' : dns}
|
||||
else:
|
||||
archinstall.storage['_guided']['network'] = {'nic': nic}
|
||||
|
||||
archinstall.storage['_guided']['network'] = {'nic': nic, 'dhcp': False, 'ip': ip, 'gateway' : gateway, 'dns' : dns}
|
||||
else:
|
||||
archinstall.storage['_guided']['network'] = {'nic': nic}
|
||||
|
||||
print()
|
||||
print('This is your chosen configuration:')
|
||||
|
|
|
|||
Loading…
Reference in New Issue