* Fix #1106 * flake8 * flake8 Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
This commit is contained in:
parent
48b1001734
commit
f00717ff6f
|
|
@ -8,7 +8,6 @@ from ..general import SysCommand, secret
|
||||||
from ..hardware import has_uefi
|
from ..hardware import has_uefi
|
||||||
from ..models import NetworkConfiguration
|
from ..models import NetworkConfiguration
|
||||||
from ..storage import storage
|
from ..storage import storage
|
||||||
from ..output import log
|
|
||||||
from ..profiles import is_desktop_profile
|
from ..profiles import is_desktop_profile
|
||||||
from ..disk import encrypted_partitions
|
from ..disk import encrypted_partitions
|
||||||
|
|
||||||
|
|
@ -277,11 +276,12 @@ class GlobalMenu(GeneralMenu):
|
||||||
if profile and profile.has_prep_function():
|
if profile and profile.has_prep_function():
|
||||||
namespace = f'{profile.namespace}.py'
|
namespace = f'{profile.namespace}.py'
|
||||||
with profile.load_instructions(namespace=namespace) as imported:
|
with profile.load_instructions(namespace=namespace) as imported:
|
||||||
if not imported._prep_function():
|
if imported._prep_function():
|
||||||
log(' * Profile\'s preparation requirements was not fulfilled.', fg='red')
|
return profile
|
||||||
exit(1)
|
else:
|
||||||
|
return self._select_profile()
|
||||||
|
|
||||||
return profile
|
return self._data_store.get('profile', None)
|
||||||
|
|
||||||
def _create_superuser_account(self):
|
def _create_superuser_account(self):
|
||||||
superusers = ask_for_superuser_account(str(_('Manage superuser accounts: ')))
|
superusers = ask_for_superuser_account(str(_('Manage superuser accounts: ')))
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ def select_harddrives(preset: List[str] = []) -> List[str]:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
def select_driver(options: Dict[str, Any] = AVAILABLE_GFX_DRIVERS, force_ask: bool = False) -> str:
|
def select_driver(options: Dict[str, Any] = AVAILABLE_GFX_DRIVERS) -> str:
|
||||||
"""
|
"""
|
||||||
Some what convoluted function, whose job is simple.
|
Some what convoluted function, whose job is simple.
|
||||||
Select a graphics driver from a pre-defined set of popular options.
|
Select a graphics driver from a pre-defined set of popular options.
|
||||||
|
|
@ -88,9 +88,8 @@ def select_driver(options: Dict[str, Any] = AVAILABLE_GFX_DRIVERS, force_ask: bo
|
||||||
'For the best compatibility with your Nvidia hardware, you may want to use the Nvidia proprietary driver.\n'
|
'For the best compatibility with your Nvidia hardware, you may want to use the Nvidia proprietary driver.\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
if not arguments.get('gfx_driver', None) or force_ask:
|
title += _('\n\nSelect a graphics driver or leave blank to install all open-source drivers')
|
||||||
title += _('\n\nSelect a graphics driver or leave blank to install all open-source drivers')
|
arguments['gfx_driver'] = Menu(title, drivers).run()
|
||||||
arguments['gfx_driver'] = Menu(title, drivers).run()
|
|
||||||
|
|
||||||
if arguments.get('gfx_driver', None) is None:
|
if arguments.get('gfx_driver', None) is None:
|
||||||
arguments['gfx_driver'] = _("All open-source (default)")
|
arguments['gfx_driver'] = _("All open-source (default)")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
# A desktop environment selector.
|
# A desktop environment selector.
|
||||||
import archinstall
|
import archinstall
|
||||||
|
from archinstall import log
|
||||||
|
|
||||||
is_top_level_profile = True
|
is_top_level_profile = True
|
||||||
|
|
||||||
|
|
@ -38,29 +39,33 @@ __supported__ = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def _prep_function(*args, **kwargs):
|
def _prep_function(*args, **kwargs) -> bool:
|
||||||
"""
|
"""
|
||||||
Magic function called by the importing installer
|
Magic function called by the importing installer
|
||||||
before continuing any further. It also avoids executing any
|
before continuing any further. It also avoids executing any
|
||||||
other code in this stage. So it's a safe way to ask the user
|
other code in this stage. So it's a safe way to ask the user
|
||||||
for more input before any other installer steps start.
|
for more input before any other installer steps start.
|
||||||
"""
|
"""
|
||||||
desktop = archinstall.Menu('Select your desired desktop environment', __supported__, skip=False).run()
|
desktop = archinstall.Menu('Select your desired desktop environment', __supported__).run()
|
||||||
|
|
||||||
# Temporarily store the selected desktop profile
|
if desktop:
|
||||||
# in a session-safe location, since this module will get reloaded
|
# Temporarily store the selected desktop profile
|
||||||
# the next time it gets executed.
|
# in a session-safe location, since this module will get reloaded
|
||||||
if not archinstall.storage.get('_desktop_profile', None):
|
# the next time it gets executed.
|
||||||
archinstall.storage['_desktop_profile'] = desktop
|
if not archinstall.storage.get('_desktop_profile', None):
|
||||||
if not archinstall.arguments.get('desktop-environment', None):
|
archinstall.storage['_desktop_profile'] = desktop
|
||||||
archinstall.arguments['desktop-environment'] = desktop
|
if not archinstall.arguments.get('desktop-environment', None):
|
||||||
profile = archinstall.Profile(None, desktop)
|
archinstall.arguments['desktop-environment'] = desktop
|
||||||
# Loading the instructions with a custom namespace, ensures that a __name__ comparison is never triggered.
|
profile = archinstall.Profile(None, desktop)
|
||||||
with profile.load_instructions(namespace=f"{desktop}.py") as imported:
|
# Loading the instructions with a custom namespace, ensures that a __name__ comparison is never triggered.
|
||||||
if hasattr(imported, '_prep_function'):
|
with profile.load_instructions(namespace=f"{desktop}.py") as imported:
|
||||||
return imported._prep_function()
|
if hasattr(imported, '_prep_function'):
|
||||||
else:
|
return imported._prep_function()
|
||||||
print(f"Deprecated (??): {desktop} profile has no _prep_function() anymore")
|
else:
|
||||||
|
log(f"Deprecated (??): {desktop} profile has no _prep_function() anymore")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
if __name__ == 'desktop':
|
if __name__ == 'desktop':
|
||||||
|
|
|
||||||
|
|
@ -27,20 +27,21 @@ def _prep_function(*args, **kwargs):
|
||||||
|
|
||||||
supported_configurations = ['i3-wm', 'i3-gaps']
|
supported_configurations = ['i3-wm', 'i3-gaps']
|
||||||
|
|
||||||
desktop = archinstall.Menu('Select your desired configuration', supported_configurations, skip=False).run()
|
desktop = archinstall.Menu('Select your desired configuration', supported_configurations).run()
|
||||||
|
|
||||||
# Temporarily store the selected desktop profile
|
if desktop:
|
||||||
# in a session-safe location, since this module will get reloaded
|
# Temporarily store the selected desktop profile
|
||||||
# the next time it gets executed.
|
# in a session-safe location, since this module will get reloaded
|
||||||
archinstall.storage['_i3_configuration'] = desktop
|
# the next time it gets executed.
|
||||||
|
archinstall.storage['_i3_configuration'] = desktop
|
||||||
|
|
||||||
# i3 requires a functioning Xorg installation.
|
# i3 requires a functioning Xorg installation.
|
||||||
profile = archinstall.Profile(None, 'xorg')
|
profile = archinstall.Profile(None, 'xorg')
|
||||||
with profile.load_instructions(namespace='xorg.py') as imported:
|
with profile.load_instructions(namespace='xorg.py') as imported:
|
||||||
if hasattr(imported, '_prep_function'):
|
if hasattr(imported, '_prep_function'):
|
||||||
return imported._prep_function()
|
return imported._prep_function()
|
||||||
else:
|
else:
|
||||||
print('Deprecated (??): xorg profile has no _prep_function() anymore')
|
print('Deprecated (??): xorg profile has no _prep_function() anymore')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == 'i3':
|
if __name__ == 'i3':
|
||||||
|
|
|
||||||
|
|
@ -26,15 +26,18 @@ def _prep_function(*args, **kwargs):
|
||||||
Magic function called by the importing installer
|
Magic function called by the importing installer
|
||||||
before continuing any further.
|
before continuing any further.
|
||||||
"""
|
"""
|
||||||
if not archinstall.storage.get('_selected_servers', None):
|
servers = archinstall.Menu(
|
||||||
servers = archinstall.Menu(
|
'Choose which servers to install, if none then a minimal installation wil be done',
|
||||||
'Choose which servers to install, if none then a minimal installation wil be done', available_servers,
|
available_servers,
|
||||||
multi=True
|
preset_values=archinstall.storage.get('_selected_servers', []),
|
||||||
).run()
|
multi=True
|
||||||
|
).run()
|
||||||
|
|
||||||
|
if servers:
|
||||||
archinstall.storage['_selected_servers'] = servers
|
archinstall.storage['_selected_servers'] = servers
|
||||||
|
return True
|
||||||
|
|
||||||
return True
|
return False
|
||||||
|
|
||||||
|
|
||||||
if __name__ == 'server':
|
if __name__ == 'server':
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,9 @@ __packages__ = [
|
||||||
|
|
||||||
|
|
||||||
def _check_driver() -> bool:
|
def _check_driver() -> bool:
|
||||||
if "nvidia" in archinstall.storage.get("gfx_driver_packages", None):
|
packages = archinstall.storage.get("gfx_driver_packages", [])
|
||||||
|
|
||||||
|
if packages and "nvidia" in packages:
|
||||||
prompt = 'The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues, are you okay with that?'
|
prompt = 'The proprietary Nvidia driver is not supported by Sway. It is likely that you will run into issues, are you okay with that?'
|
||||||
choice = archinstall.Menu(prompt, ['yes', 'no'], default_option='no').run()
|
choice = archinstall.Menu(prompt, ['yes', 'no'], default_option='no').run()
|
||||||
if choice == 'no':
|
if choice == 'no':
|
||||||
|
|
@ -34,11 +36,15 @@ def _prep_function(*args, **kwargs):
|
||||||
other code in this stage. So it's a safe way to ask the user
|
other code in this stage. So it's a safe way to ask the user
|
||||||
for more input before any other installer steps start.
|
for more input before any other installer steps start.
|
||||||
"""
|
"""
|
||||||
archinstall.storage["gfx_driver_packages"] = archinstall.select_driver(force_ask=True)
|
driver = archinstall.select_driver()
|
||||||
if not _check_driver():
|
|
||||||
return _prep_function(args, kwargs)
|
|
||||||
|
|
||||||
return True
|
if driver:
|
||||||
|
archinstall.storage["gfx_driver_packages"] = driver
|
||||||
|
if not _check_driver():
|
||||||
|
return _prep_function(args, kwargs)
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
# Ensures that this code only gets executed if executed
|
# Ensures that this code only gets executed if executed
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,16 @@ def _prep_function(*args, **kwargs):
|
||||||
for more input before any other installer steps start.
|
for more input before any other installer steps start.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
archinstall.storage["gfx_driver_packages"] = archinstall.select_driver()
|
driver = archinstall.select_driver()
|
||||||
|
|
||||||
|
if driver:
|
||||||
|
archinstall.storage["gfx_driver_packages"] = driver
|
||||||
|
return True
|
||||||
|
|
||||||
# TODO: Add language section and/or merge it with the locale selected
|
# TODO: Add language section and/or merge it with the locale selected
|
||||||
# earlier in for instance guided.py installer.
|
# earlier in for instance guided.py installer.
|
||||||
|
|
||||||
return True
|
return False
|
||||||
|
|
||||||
|
|
||||||
# Ensures that this code only gets executed if executed
|
# Ensures that this code only gets executed if executed
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue