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 2020-06-24 14:41:24 -07:00 committed by James Valleroy
parent a145742ebc
commit 5d3c010b2e
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 9 additions and 4 deletions

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)

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