mirror of
https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git
synced 2025-07-13 03:19:47 +03:00
core: introduce global context (MR 2252)
We can't totally escape the need for some runtime state defined by args. To make the migration easier, introduce a global "Context" class and move some of the read-only global options there. Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
b82c4eb167
commit
2a7c769e14
6 changed files with 56 additions and 11 deletions
|
@ -114,9 +114,23 @@ def init(args: PmbArgs) -> PmbArgs:
|
|||
pmb.config.merge_with_args(args)
|
||||
replace_placeholders(args)
|
||||
|
||||
# Configure runtime context
|
||||
context = pmb.core.get_context()
|
||||
context.command_timeout = args.timeout
|
||||
context.details_to_stdout = args.details_to_stdout
|
||||
context.sudo_timer = args.sudo_timer
|
||||
context.quiet = args.quiet
|
||||
|
||||
# Initialize logs (we could raise errors below)
|
||||
pmb.helpers.logging.init(args)
|
||||
|
||||
# Remove attributes from args so they don't get used by mistake
|
||||
delattr(args, "timeout")
|
||||
delattr(args, "details_to_stdout")
|
||||
delattr(args, "sudo_timer")
|
||||
delattr(args, "log")
|
||||
delattr(args, "quiet")
|
||||
|
||||
# Initialization code which may raise errors
|
||||
check_pmaports_path(args)
|
||||
if args.action not in ["init", "checksum", "config", "bootimg_analyze", "log",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue