mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
*: Drop use of module level is_essential flag
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
6f791d8806
commit
cf36a9d385
@ -16,14 +16,6 @@ are part of the :class:`~plinth.app.Info` component. Need for this attribute at
|
||||
the module level will be removed in the future.
|
||||
|
||||
|
||||
<app-module>.is_essential
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Optional. If an app must be installed and configured by FreedomBox without user
|
||||
intervention, this attribute must be set to True. This attribute is part of the
|
||||
:class:`~plinth.app.Info` component. Need for this attribute at the module level
|
||||
will be removed in the future.
|
||||
|
||||
<app-module>.version
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
@ -72,10 +72,10 @@ def list_dependencies(module_list):
|
||||
def list_modules(modules_type):
|
||||
"""List all/essential/optional modules and exit."""
|
||||
for module_name, module in module_loader.loaded_modules.items():
|
||||
module_is_essential = getattr(module, 'is_essential', False)
|
||||
if 'essential' in modules_type and not module_is_essential:
|
||||
is_essential = module.app.info.is_essential
|
||||
if 'essential' in modules_type and not is_essential:
|
||||
continue
|
||||
elif 'optional' in modules_type and module_is_essential:
|
||||
elif 'optional' in modules_type and is_essential:
|
||||
continue
|
||||
print('{module_name}'.format(module_name=module_name))
|
||||
sys.exit()
|
||||
|
||||
@ -33,7 +33,7 @@ def _collect_setup_result(request, module):
|
||||
|
||||
exception = module.setup_helper.collect_result()
|
||||
if not exception:
|
||||
if not setup._is_module_essential(module):
|
||||
if not module.setup_helper.app.info.is_essential:
|
||||
messages.success(request, _('Application installed.'))
|
||||
else:
|
||||
if isinstance(exception, PackageException):
|
||||
|
||||
@ -28,11 +28,6 @@ def include_urls():
|
||||
_include_module_urls(module_import_path, module_name)
|
||||
|
||||
|
||||
def _is_module_essential(module):
|
||||
"""Return if a module is an essential module."""
|
||||
return getattr(module, 'is_essential', False)
|
||||
|
||||
|
||||
def load_modules():
|
||||
"""
|
||||
Read names of enabled modules in modules/enabled directory and
|
||||
@ -54,7 +49,7 @@ def load_modules():
|
||||
remaining_modules = dict(modules) # Make a copy
|
||||
# Place all essential modules ahead of others in module load order
|
||||
sorted_modules = sorted(
|
||||
modules, key=lambda module: not _is_module_essential(modules[module]))
|
||||
modules, key=lambda module: not modules[module].app.info.is_essential)
|
||||
for module_name in sorted_modules:
|
||||
if module_name not in remaining_modules:
|
||||
continue
|
||||
|
||||
@ -17,8 +17,6 @@ from plinth.utils import format_lazy, is_valid_user_name
|
||||
|
||||
version = 9
|
||||
|
||||
is_essential = True
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
@ -32,8 +30,7 @@ class ApacheApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential,
|
||||
name=_('Apache HTTP Server'))
|
||||
is_essential=True, name=_('Apache HTTP Server'))
|
||||
self.add(info)
|
||||
|
||||
packages = Packages('packages-apache', [
|
||||
|
||||
@ -23,8 +23,6 @@ from . import manifest
|
||||
|
||||
version = 1
|
||||
|
||||
is_essential = True
|
||||
|
||||
depends = ['names']
|
||||
|
||||
_description = [
|
||||
@ -51,8 +49,8 @@ class AvahiApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
name=_('Service Discovery'), icon='fa-compass',
|
||||
description=_description,
|
||||
is_essential=True, name=_('Service Discovery'),
|
||||
icon='fa-compass', description=_description,
|
||||
manual_page='ServiceDiscovery')
|
||||
self.add(info)
|
||||
|
||||
|
||||
@ -25,8 +25,6 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
version = 3
|
||||
|
||||
is_essential = True
|
||||
|
||||
depends = ['storage']
|
||||
|
||||
_description = [
|
||||
@ -50,9 +48,9 @@ class BackupsApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(
|
||||
app_id=self.app_id, version=version, depends=depends,
|
||||
name=_('Backups'), icon='fa-files-o', description=_description,
|
||||
manual_page='Backups',
|
||||
app_id=self.app_id, version=version, is_essential=True,
|
||||
depends=depends, name=_('Backups'), icon='fa-files-o',
|
||||
description=_description, manual_page='Backups',
|
||||
donation_url='https://www.borgbackup.org/support/fund.html')
|
||||
self.add(info)
|
||||
|
||||
|
||||
@ -22,8 +22,6 @@ from . import manifest, utils
|
||||
|
||||
version = 1
|
||||
|
||||
is_essential = True
|
||||
|
||||
_description = [
|
||||
format_lazy(
|
||||
_('Cockpit is a server manager that makes it easy to administer '
|
||||
@ -61,7 +59,7 @@ class CockpitApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential, name=_('Cockpit'),
|
||||
is_essential=True, name=_('Cockpit'),
|
||||
icon='fa-wrench', icon_filename='cockpit',
|
||||
short_description=_('Server Administration'),
|
||||
description=_description, manual_page='Cockpit',
|
||||
|
||||
@ -21,8 +21,6 @@ from plinth.signals import domain_added
|
||||
|
||||
version = 3
|
||||
|
||||
is_essential = True
|
||||
|
||||
_description = [
|
||||
_('Here you can set some general configuration options '
|
||||
'like hostname, domain name, webserver home page etc.')
|
||||
@ -52,7 +50,7 @@ class ConfigApp(app_module.App):
|
||||
"""Create components for the app."""
|
||||
super().__init__()
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential, depends=depends,
|
||||
is_essential=True, depends=depends,
|
||||
name=_('General Configuration'), icon='fa-cog',
|
||||
description=_description,
|
||||
manual_page='Configure')
|
||||
|
||||
@ -16,8 +16,6 @@ from . import manifest
|
||||
|
||||
version = 2
|
||||
|
||||
is_essential = True
|
||||
|
||||
_description = [
|
||||
_('Network time server is a program that maintains the system time '
|
||||
'in synchronization with servers on the Internet.')
|
||||
@ -63,9 +61,8 @@ class DateTimeApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential,
|
||||
name=_('Date & Time'), icon='fa-clock-o',
|
||||
description=_description,
|
||||
is_essential=True, name=_('Date & Time'),
|
||||
icon='fa-clock-o', description=_description,
|
||||
manual_page='DateTime')
|
||||
self.add(info)
|
||||
|
||||
|
||||
@ -21,8 +21,6 @@ from . import manifest
|
||||
|
||||
version = 1
|
||||
|
||||
is_essential = True
|
||||
|
||||
_description = [
|
||||
_('The system diagnostic test will run a number of checks on your '
|
||||
'system to confirm that applications and services are working as '
|
||||
@ -49,9 +47,8 @@ class DiagnosticsApp(app_module.App):
|
||||
"""Create components for the app."""
|
||||
super().__init__()
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential,
|
||||
name=_('Diagnostics'), icon='fa-heartbeat',
|
||||
description=_description,
|
||||
is_essential=True, name=_('Diagnostics'),
|
||||
icon='fa-heartbeat', description=_description,
|
||||
manual_page='Diagnostics')
|
||||
self.add(info)
|
||||
|
||||
|
||||
@ -19,8 +19,6 @@ from . import manifest
|
||||
|
||||
version = 1
|
||||
|
||||
is_essential = True
|
||||
|
||||
depends = ['names']
|
||||
|
||||
_description = [
|
||||
@ -52,7 +50,7 @@ class DynamicDNSApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential, depends=depends,
|
||||
is_essential=True, depends=depends,
|
||||
name=_('Dynamic DNS Client'), icon='fa-refresh',
|
||||
description=_description,
|
||||
manual_page='DynamicDNS')
|
||||
|
||||
@ -23,8 +23,6 @@ glib = import_from_gi('GLib', '2.0')
|
||||
|
||||
version = 2
|
||||
|
||||
is_essential = True
|
||||
|
||||
_description = [
|
||||
format_lazy(
|
||||
_('Firewall is a security system that controls the incoming and '
|
||||
@ -61,7 +59,7 @@ class FirewallApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential, name=_('Firewall'),
|
||||
is_essential=True, name=_('Firewall'),
|
||||
icon='fa-shield', description=_description,
|
||||
manual_page='Firewall')
|
||||
self.add(info)
|
||||
|
||||
@ -13,8 +13,6 @@ from plinth.signals import post_setup
|
||||
|
||||
version = 1
|
||||
|
||||
is_essential = True
|
||||
|
||||
first_boot_steps = [
|
||||
{
|
||||
'id': 'firstboot_welcome',
|
||||
@ -42,6 +40,12 @@ class FirstBootApp(app.App):
|
||||
def __init__(self):
|
||||
"""Create components for the app."""
|
||||
super().__init__()
|
||||
|
||||
info = app.Info(app_id=self.app_id, version=version, is_essential=True)
|
||||
self.add(info)
|
||||
|
||||
def post_init(self):
|
||||
"""Perform post initialization operations."""
|
||||
post_setup.connect(_clear_first_boot_steps)
|
||||
|
||||
|
||||
|
||||
@ -13,7 +13,6 @@ from plinth import cfg, menu, web_server
|
||||
|
||||
version = 1
|
||||
|
||||
is_essential = True
|
||||
app = None
|
||||
|
||||
|
||||
@ -27,7 +26,7 @@ class HelpApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential)
|
||||
is_essential=True)
|
||||
self.add(info)
|
||||
|
||||
menu_item = menu.Menu('menu-help', _('Documentation'), None, 'fa-book',
|
||||
|
||||
@ -25,8 +25,6 @@ from . import components, manifest
|
||||
|
||||
version = 3
|
||||
|
||||
is_essential = True
|
||||
|
||||
depends = ['names']
|
||||
|
||||
_description = [
|
||||
@ -61,7 +59,7 @@ class LetsEncryptApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential, depends=depends,
|
||||
is_essential=True, depends=depends,
|
||||
name=_('Let\'s Encrypt'), icon='fa-lock',
|
||||
short_description=_('Certificates'),
|
||||
description=_description,
|
||||
|
||||
@ -17,8 +17,6 @@ from . import components, manifest
|
||||
|
||||
version = 1
|
||||
|
||||
is_essential = True
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
_description = [
|
||||
@ -42,9 +40,8 @@ class NamesApp(app_module.App):
|
||||
"""Create components for the app."""
|
||||
super().__init__()
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential,
|
||||
name=_('Name Services'), icon='fa-tags',
|
||||
description=_description,
|
||||
is_essential=True, name=_('Name Services'),
|
||||
icon='fa-tags', description=_description,
|
||||
manual_page='NameServices')
|
||||
self.add(info)
|
||||
|
||||
|
||||
@ -16,8 +16,6 @@ from plinth.package import Packages
|
||||
|
||||
version = 1
|
||||
|
||||
is_essential = True
|
||||
|
||||
first_boot_steps = [
|
||||
{
|
||||
'id': 'network_topology_wizard',
|
||||
@ -58,7 +56,7 @@ class NetworksApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential, name=_('Networks'),
|
||||
is_essential=True, name=_('Networks'),
|
||||
icon='fa-signal', description=_description,
|
||||
manual_page='Networks')
|
||||
self.add(info)
|
||||
|
||||
@ -12,8 +12,6 @@ from . import manifest
|
||||
|
||||
version = 1
|
||||
|
||||
is_essential = True
|
||||
|
||||
_description = [_('Restart or shut down the system.')]
|
||||
|
||||
app = None
|
||||
@ -29,7 +27,7 @@ class PowerApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential, name=_('Power'),
|
||||
is_essential=True, name=_('Power'),
|
||||
description=_description, manual_page='Power')
|
||||
self.add(info)
|
||||
|
||||
|
||||
@ -21,8 +21,6 @@ from . import manifest
|
||||
|
||||
version = 1
|
||||
|
||||
is_essential = False
|
||||
|
||||
_description = [
|
||||
_('Privoxy is a non-caching web proxy with advanced filtering '
|
||||
'capabilities for enhancing privacy, modifying web page data and '
|
||||
|
||||
@ -20,8 +20,6 @@ from . import manifest
|
||||
|
||||
version = 7
|
||||
|
||||
is_essential = True
|
||||
|
||||
ACCESS_CONF_FILE = '/etc/security/access.d/50freedombox.conf'
|
||||
ACCESS_CONF_FILE_OLD = '/etc/security/access.conf'
|
||||
ACCESS_CONF_SNIPPET = '-:ALL EXCEPT root fbx plinth (admin) (sudo):ALL'
|
||||
@ -41,7 +39,7 @@ class SecurityApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential, name=_('Security'),
|
||||
is_essential=True, name=_('Security'),
|
||||
icon='fa-lock', manual_page='Security')
|
||||
self.add(info)
|
||||
|
||||
|
||||
@ -20,8 +20,6 @@ from . import manifest
|
||||
|
||||
version = 4
|
||||
|
||||
is_essential = True
|
||||
|
||||
_description = [
|
||||
_('Snapshots allows creating and managing btrfs file system snapshots. '
|
||||
'These can be used to roll back the system to a previously known '
|
||||
@ -53,8 +51,8 @@ class SnapshotApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
name=_('Storage Snapshots'), icon='fa-film',
|
||||
description=_description,
|
||||
is_essential=True, name=_('Storage Snapshots'),
|
||||
icon='fa-film', description=_description,
|
||||
manual_page='Snapshots')
|
||||
self.add(info)
|
||||
|
||||
|
||||
@ -21,8 +21,6 @@ from . import manifest
|
||||
|
||||
version = 1
|
||||
|
||||
is_essential = True
|
||||
|
||||
_description = [
|
||||
_('A Secure Shell server uses the secure shell protocol to accept '
|
||||
'connections from remote computers. An authorized remote computer '
|
||||
@ -43,7 +41,7 @@ class SSHApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential,
|
||||
is_essential=True,
|
||||
name=_('Secure Shell (SSH) Server'),
|
||||
icon='fa-terminal', description=_description)
|
||||
self.add(info)
|
||||
|
||||
@ -11,8 +11,6 @@ from plinth.package import Packages
|
||||
|
||||
version = 1
|
||||
|
||||
is_essential = True
|
||||
|
||||
depends = ['security', 'apache']
|
||||
|
||||
app = None
|
||||
@ -27,7 +25,7 @@ class SSOApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential, depends=depends,
|
||||
is_essential=True, depends=depends,
|
||||
name=_('Single Sign On'))
|
||||
self.add(info)
|
||||
|
||||
|
||||
@ -33,8 +33,6 @@ _description = [
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
is_essential = True
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
@ -50,7 +48,7 @@ class StorageApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential, name=_('Storage'),
|
||||
is_essential=True, name=_('Storage'),
|
||||
icon='fa-hdd-o', description=_description,
|
||||
manual_page='Storage')
|
||||
self.add(info)
|
||||
|
||||
@ -24,8 +24,6 @@ from . import manifest
|
||||
|
||||
version = 9
|
||||
|
||||
is_essential = True
|
||||
|
||||
first_boot_steps = [
|
||||
{
|
||||
'id': 'backports_wizard',
|
||||
@ -73,7 +71,7 @@ class UpgradesApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential, name=_('Update'),
|
||||
is_essential=True, name=_('Update'),
|
||||
icon='fa-refresh', description=_description,
|
||||
manual_page='Upgrades')
|
||||
self.add(info)
|
||||
|
||||
@ -19,8 +19,6 @@ from .components import UsersAndGroups
|
||||
|
||||
version = 3
|
||||
|
||||
is_essential = True
|
||||
|
||||
first_boot_steps = [
|
||||
{
|
||||
'id': 'users_firstboot',
|
||||
@ -56,9 +54,9 @@ class UsersApp(app_module.App):
|
||||
super().__init__()
|
||||
|
||||
info = app_module.Info(app_id=self.app_id, version=version,
|
||||
is_essential=is_essential,
|
||||
name=_('Users and Groups'), icon='fa-users',
|
||||
description=_description, manual_page='Users')
|
||||
is_essential=True, name=_('Users and Groups'),
|
||||
icon='fa-users', description=_description,
|
||||
manual_page='Users')
|
||||
self.add(info)
|
||||
|
||||
menu_item = menu.Menu('menu-users', info.name, None, info.icon,
|
||||
|
||||
@ -145,7 +145,7 @@ def setup_modules(module_list=None, essential=False, allow_install=True):
|
||||
'Running setup for modules, essential - %s, '
|
||||
'selected modules - %s', essential, module_list)
|
||||
for module_name, module in plinth.module_loader.loaded_modules.items():
|
||||
if essential and not _is_module_essential(module):
|
||||
if essential and not module.app.info.is_essential:
|
||||
continue
|
||||
|
||||
if module_list and module_name not in module_list:
|
||||
@ -159,7 +159,7 @@ def list_dependencies(module_list=None, essential=False):
|
||||
for module_import_path in plinth.module_loader.get_modules_to_load():
|
||||
module_name = module_import_path.split('.')[-1]
|
||||
module = importlib.import_module(module_import_path)
|
||||
if essential and not _is_module_essential(module):
|
||||
if essential and not module.app.info.is_essential:
|
||||
continue
|
||||
|
||||
if module_list and module_name not in module_list and \
|
||||
@ -227,7 +227,7 @@ def _get_modules_for_regular_setup():
|
||||
1. essential modules that are not up-to-date
|
||||
2. non-essential modules that are installed and need updates
|
||||
"""
|
||||
if (_is_module_essential(module) and module.app.get_setup_state() !=
|
||||
if (module.app.info.is_essential and module.app.get_setup_state() !=
|
||||
app_module.App.SetupState.UP_TO_DATE):
|
||||
return True
|
||||
|
||||
@ -240,18 +240,13 @@ def _get_modules_for_regular_setup():
|
||||
return [name for name, module in all_modules if is_setup_required(module)]
|
||||
|
||||
|
||||
def _is_module_essential(module):
|
||||
"""Return if a module is an essential module."""
|
||||
return getattr(module, 'is_essential', False)
|
||||
|
||||
|
||||
def _set_is_first_setup():
|
||||
"""Set whether all essential modules have been setup at least once."""
|
||||
global _is_first_setup
|
||||
modules = plinth.module_loader.loaded_modules.values()
|
||||
_is_first_setup = any(
|
||||
(module for module in modules
|
||||
if _is_module_essential(module) and module.app.needs_setup()))
|
||||
if module.app.info.is_essential and module.app.needs_setup()))
|
||||
|
||||
|
||||
def run_setup_on_modules(module_list, allow_install=True):
|
||||
|
||||
@ -129,7 +129,6 @@ class TestSetupMiddleware:
|
||||
"""Test that module installation result is collected properly."""
|
||||
resolve.return_value.namespaces = ['mockapp']
|
||||
module = Mock()
|
||||
module.is_essential = False
|
||||
module.setup_helper.is_finished = True
|
||||
module.setup_helper.collect_result.return_value = None
|
||||
module.app.get_setup_state.return_value = \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user