pychroot.utils module

Various chroot-related utilities mostly dealing with bind mounting.

pychroot.utils.bind(src, dest, chroot, create=False, log=None, readonly=False, recursive=False, **_kwargs)[source]

Set up a bind mount.

Parameters
  • src (str) – The source location to mount.

  • dest (str) – The destination to mount on.

  • chroot (str) – The chroot base path.

  • create (bool) – Whether to create the destination.

  • log (logging.Logger) – A logger to use for logging.

  • readonly (bool) – Whether to remount read-only.

  • recursive (bool) – Whether to use a recursive bind mount.

pychroot.utils.dictbool(dct, key)[source]

Check if a key exists and is True in a dictionary.

Parameters
  • dct (dict) – The dictionary to check.

  • key (any) – The key to check

pychroot.utils.getlogger(log, name)[source]

Gets a logger given a logger and a package.

Will return the given logger if the name is not generated from the current package, otherwise generate a logger based on __name__.

Parameters
  • log (logging.Logger) – Logger to start with.

  • name (str) – The __name__ of the caller.