udot¶
This is the main module. It implements the UberDot class and a short startup script.
You can run this directly from the CLI with
python ./udot.py <arguments>
or you can import UberDot for debugging and testing purposes.
-
class
udot.
CustomParser
(**kwargs)¶ Bases:
argparse.ArgumentParser
Custom argument parser that raises an UserError instead of writing the error to stderr and exiting by itself.
-
__init__
(**kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
error
(message: string)¶ Prints a usage message incorporating the message to stderr and exits.
If you override this in a subclass, it should not return -- it should either exit or raise an exception.
-
-
class
udot.
StdoutFilter
(name='')¶ Bases:
logging.Filter
Custom logging filter that filters all error messages from a stream. Used to filter stdout, because otherwise every error would be pushed to stdout AND stderr.
-
filter
(record)¶ Returns True for all records that have a logging level of WARNING or less.
-
-
class
udot.
StoreDictKeyPair
(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)¶ Bases:
argparse.Action
Custom argparse.Action to parse an option dictionary from commandline
-
__call__
(parser, namespace, values, option_string=None)¶ Splits a commandline argument at "=" and writes the splitted values into a dictionary.
-
-
class
udot.
UberDot
¶ Bases:
object
Bundles all functionality of uberdot.
This includes things like parsing arguments, loading installed-files, printing information and executing profiles.
-
installed
¶ The installed-file that is used as a reference
Type: dict
-
profiles
¶ A list of the to be installed/updated profiles
Type: list
-
args
¶ The parsed arguments
Type: argparse
-
owd
¶ The old working directory uberdot was started from
Type: str
-
__init__
()¶ Constructor.
Initializes attributes and changes the working directory to the directory where this module is stored.
-
check_arguments
()¶ Checks if parsed arguments/settings are bad or incompatible to each other. If not, it raises an UserError.
-
dryrun
(difflog)¶ Like run() but instead of resolving it it will be just printed out
Parameters: difflog (DiffLog) -- The DiffLog that will be checked Raises: CustomError
-- Executed interpreters can and will raise all kinds ofCustomError
.
-
execute_arguments
()¶ Executes whatever was specified via commandline arguments.
-
execute_profiles
(profiles=None, options=None, directory=None)¶ Imports profiles by name and executes them.
Parameters: - profiles (list) -- A list of names of profiles that will be executed. If this is None, it will be set to what the user set via cli.
- options (dict) -- A dictionary of default options for root profiles. If this is None, it will be set to what the user set via cli.
- directory (str) -- A default path in which root profiles start. If this is None, it will be set to what the user set via cli.
-
load_installed
()¶ Reads the installed-file and parses it's content into
self.installed
.Raises: PreconditionError
-- uberdot and installed-file aren't version compatible.
-
parse_arguments
(arguments=None)¶ Parses the commandline arguments. This function can parse a custom list of arguments, instead of
sys.args
.Parameters: arguments (list) -- A list of arguments that will be parsed instead of sys.args
Raises: UserError
-- One ore more arguments are invalid or used in an invalid combination.
-
print_debuginfo
()¶ Print out internal values.
This includes search paths of configs, loaded configs, parsed commandline arguments and settings.
-
print_installed
(profile)¶ Prints a single installed profile.
Parameters: profile (dict) -- The profile that will be printed
-
print_installed_profiles
()¶ Print out the installed-file in a readable format.
Prints only the profiles specified in the commandline arguments. If none are specified it prints all profiles of the installed-file.
-
run
(difflog)¶ Performs checks on DiffLog and resolves it.
Furthermore this function handles backups, converts exceptions into UnkownErrors and might replace the entire process when uberdot was started with insufficient permissions.
Parameters: difflog (DiffLog) -- The DiffLog that will be resolved.
Raises: UnkownError
-- All exceptions that are noCustomError
and occured in the critical section will be converted to this error.CustomError
-- Executed interpreters can and will raise all kinds ofCustomError
.
-
-
udot.
run_script
(name)¶ Act like a script if this was invoked like a script. This is needed, because otherwise everything below couldn't be traced by coverage.