Misc. Utilities

This module contains functions that don’t have a rightful home elsewhere, or are of general use.

Configuration Access

These functions are used to read a config off the filesystem, for use elsewhere in dput.

dput.util.get_configs(cls)

Get all valid config targets for class cls.

dput.util.load_config(config_class, config_name, default=None, configs=None, config_cleanup=True)

Load any dput configuration given a config_class (such as hooks), and a config_name (such as lintian or tweet).

Optional kwargs:

default is a default to return, in case the config file isn’t found. If this isn’t provided, this function will raise a dput.exceptions.NoSuchConfigError.

configs is a list of config files to check. When this isn’t provided, we check dput.core.CONFIG_LOCATIONS.

Object Loaders

These functions aid in loading a defined, dynamically imported “plugin”.

dput.util.get_obj(cls, checker_method)

Get an object by plugin def (checker_method) in class cls (such as hooks).

dput.util.load_obj(obj_path)

Dynamically load an object (class, method, etc) by name (such as dput.core.ClassName), and return that object to work with. This is useful for loading modules on the fly, without them being all loaded at once, or even in the same package.

Call this routine with at least one dot in it – it attempts to load the module (such as dput.core) and use getattr to load the thing - similar to how from works.

Invocation

These functions aid in running things.

dput.util.run_command(command, env=None)

Run a synchronized command. The argument must be a list of arguments. Returns a triple (stdout, stderr, exit_status)

If there was a problem to start the supplied command, (None, None, -1) is returned

dput.util.run_func_by_name(cls, name, changes, profile)

Run a function, defined by name, filed in class cls, with a dput.changes.Changes (changes), and profile profile.

This is used to run the hooks, internally.