From 5d3c010b2ed29a30769d2ffa51a27dd446d9cfc9 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 24 Jun 2020 14:41:24 -0700 Subject: [PATCH] main: List dependencies without writing to disk - Don't run the second phase of web framework initialization. This avoids writing to the DB file. - Set log level to ERROR so that no messages get printed even to stderr while listing dependencies. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/__main__.py | 8 +++++--- plinth/setup.py | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plinth/__main__.py b/plinth/__main__.py index 84978bf0f..c8fdbce75 100644 --- a/plinth/__main__.py +++ b/plinth/__main__.py @@ -129,6 +129,11 @@ def main(): adapt_config(arguments) + if arguments.list_dependencies is not False: + log.default_level = 'ERROR' + web_framework.init(read_only=True) + list_dependencies(arguments.list_dependencies) + log.init() web_framework.init() @@ -152,9 +157,6 @@ def main(): if arguments.setup_no_install is not False: run_setup_and_exit(arguments.setup_no_install, allow_install=False) - if arguments.list_dependencies is not False: - list_dependencies(arguments.list_dependencies) - if arguments.list_modules is not False: list_modules(arguments.list_modules) diff --git a/plinth/setup.py b/plinth/setup.py index e96486f52..7809215c0 100644 --- a/plinth/setup.py +++ b/plinth/setup.py @@ -3,6 +3,7 @@ Utilities for performing application setup operations. """ +import importlib import logging import os import threading @@ -207,7 +208,9 @@ def setup_modules(module_list=None, essential=False, allow_install=True): def list_dependencies(module_list=None, essential=False): """Print list of packages required by selected or essential modules.""" - for module_name, module in plinth.module_loader.loaded_modules.items(): + 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): continue