actions/service: Drop unused list action

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2021-12-04 16:35:11 -05:00
1 parent e3e3042da4
commit 5b5249873d
1 file changed
-34
-34
View File
@@ -5,9 +5,7 @@ Wrapper to list and handle system services
"""
import argparse
import json
import os
import subprocess
from importlib import import_module
from plinth import action_utils, cfg
@@ -39,8 +37,6 @@ def parse_arguments():
add_service_action(subparsers, 'mask', 'unmask a service')
add_service_action(subparsers, 'unmask', 'unmask a service')
subparsers.add_parser('list', help='List of running system services')
subparsers.required = True
return parser.parse_args()
@@ -89,36 +85,6 @@ def subcommand_is_running(arguments):
print(action_utils.service_is_running(arguments.service))
def subcommand_list(_):
"""Get list of plinth-managed services with their status.
Status may be either running or not.
"""
managed_services = _get_managed_services()
services = dict.fromkeys(managed_services, {'running': False})
output = subprocess.check_output(['systemctl', 'list-units'])
for line in output.decode().strip().split('\n'):
if line.startswith('UNIT'):
continue
# Stop parsing on empty line after the service list
if not len(line):
break
try:
unit, load, active, sub = line.split()[:4]
except ValueError:
continue
suffix = '.service'
if unit.endswith(suffix):
name = unit[:-len(suffix)]
if name in services:
services[name] = {'running': (sub == 'running')}
print(json.dumps(services))
def _get_managed_services_of_module(modulepath):
"""Import a module and return content of its 'managed_services' variable"""
try: