pibootctl.main¶
The pibootctl.main
module defines the Application
class, and an
instance of this called main
. Instances of Application
are
callable and thus main
is the entry-point for the pibootctl script.
From an API perspective, this module is primarily useful for providing an
instance of the Store
class:
from pibootctl.main import main
from pibootctl.store import Store, Current, Default
store = main.store
store[Current] = store['foo']
-
pibootctl.main.
main
¶ The instance of
Application
which is the entry-point for the pibootctl script.
-
class
pibootctl.main.
Application
[source]¶ An instance of this class (
main
) is the entry point for the application. The instance is callable, accepting the command line arguments as its single (optional) argument. The arguments will be derived fromsys.argv
if not provided:>>> from pibootctl.main import main >>> try: ... main(['-h']) ... except SystemExit: ... pass usage: [-h] [--version] {help,?,status,dump,get,set,save,load,diff,show,cat,list,ls,remove,rm,rename,mv} ...
Warning
Calling
main
will raiseSystemExit
in several cases (usually when requesting help output). It will also replace the system exception hook (sys.excepthook()
).This is intended and by design. If you wish to use pibootctl as an API, you are better off investigating the
Store
class, or treating pibootctl as a self-contained script and calling it withsubprocess
.-
backup_if_needed
()[source]¶ Tests whether the active boot configuration is also present in the store (by checking for the calculated hash). If it isn’t, constructs a unique filename (backup-<timestamp>) and saves a copy of the active boot configuration under it.
-
static
invalid_config
(*exc)[source]¶ Generates the error message for unhandled
InvalidConfiguration
exceptions. These are caused when a configuration fails to validate, and have anerrors
attribute listing all the exceptions that occurred during validation.
-
mark_reboot_required
()[source]¶ Writes the necessary files to indicate that the system requires a reboot.
-
static
overridden_config
(*exc)[source]¶ Generates the error message for unhandled
IneffectiveConfiguration
exceptions. These are caused when a boot configuration is split across multiple files; the application is permitted to modify a file before the final one, but a later file overrides a value the application has tried to set in the file it is permitted to modify.
-
static
permission_error
(*exc)[source]¶ Generates the error message for unhandled
PermissionError
exceptions. As these are very likely to be caused by non-root execution, this is customzied to warn about this in the event that the effective UID is not 0.
-
commands
¶ A dictionary mapping command names to their sub-parser.
-
config
¶ Returns the script’s configuration as derived from the files in the three pre-defined locations (see pibootctl for more information). Returns a
Namespace
containing the parsed configuration.
-