Sunil Mohan Adapa 75f6abac1e
*: Make setup method part of App class for all apps
- Primary purpose is to complete the App API and allow for multiple apps to be
present in a module without a single clashing setup() method. Secondary
objective is to get rid of SetupHelper instance simple use App instance instead.

- This brings us closer to not needing to implement setup() method for some of
the typical apps.

- Remove default value None for old_version parameter.

  - A valid integer value is always passed to this call.

  - The value of None is undefined.

  - Simplifies the App API slightly.

- Drop setting 'pre', 'post' values to indicate the stage of setup for the App.

  - Simplifies the setup methods significantly. Eliminates a class of
  bugs (some of them seen earlier).

  - The UI can show a simple 'installing...' or progress spinner instead of
  individual stages.

  - There are currently many inconsistencies where many operations are not
  wrapped in helper.call() calls.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-08-15 10:36:16 -04:00

81 lines
2.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# SPDX-License-Identifier: AGPL-3.0-or-later
"""
FreedomBox app for System Monitoring (cockpit-pcp) in System.
"""
from django.utils.translation import gettext_lazy as _
from plinth import app as app_module
from plinth import menu
from plinth.daemon import Daemon
from plinth.modules.backups.components import BackupRestore
from plinth.package import Packages
from . import manifest
name = _('Performance')
_description = [
_('Performance app allows you to collect, store and view information '
'about utilization of the hardware. This can give you basic insights '
'into usage patterns and whether the hardware is overloaded by users '
'and services.'),
_('Performance metrics are collected by Performance Co-Pilot and can be '
'viewed using the Cockpit app.'),
]
app = None
class PerformanceApp(app_module.App):
"""FreedomBox app for Performance."""
app_id = 'performance'
_version = 1
def __init__(self):
"""Create components for the app."""
super().__init__()
info = app_module.Info(app_id=self.app_id, version=self._version,
name=_('Performance'), icon='fa-bar-chart',
short_description=_('System Monitoring'),
description=_description,
manual_page='Performance',
clients=manifest.clients)
self.add(info)
menu_item = menu.Menu('menu-performance', info.name,
info.short_description, info.icon,
'performance:index', parent_url_name='system')
self.add(menu_item)
packages = Packages('packages-performance', ['cockpit-pcp'])
self.add(packages)
backup_restore = BackupRestore('backup-restore-performance',
**manifest.backup)
self.add(backup_restore)
daemon_0 = Daemon('daemon-performance-0', 'pmcd.service',
listen_ports=None)
self.add(daemon_0)
daemon_1 = Daemon('daemon-performance-1', 'pmie.service',
listen_ports=None)
self.add(daemon_1)
daemon_2 = Daemon('daemon-performance-2', 'pmlogger.service',
listen_ports=None)
self.add(daemon_2)
daemon_3 = Daemon('daemon-performance-3', 'pmproxy.service',
listen_ports=None)
self.add(daemon_3)
def setup(self, old_version):
"""Install and configure the app."""
super().setup(old_version)
self.enable()