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 <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2020-06-28 21:02:02 -04:00
1 parent a145742ebc
commit 5d3c010b2e
2 files changed
+9 -4

No files matched your search

+5 -3
View File
@@ -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)
+4 -1
View File
@@ -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