pyanaconda package

Subpackages

Submodules

pyanaconda.addons module

class pyanaconda.addons.AddonSection(*args, **kwargs)

Bases: pykickstart.sections.Section

finalize()

Let addon know no additional data will come.

handleHeader(lineno, args)

Process the arguments to the %addon header.

handleLine(line)
sectionOpen = '%addon'
class pyanaconda.addons.AddonRegistry(dictionary)

Bases: object

This class represents the ksdata.addons object and maintains the ids and data structures for loaded addons.

It acts as a proxy during kickstart save.

execute(storage, ksdata, instClass, users)

This method calls execute on all the registered addons.

setup(storage, ksdata, instClass)

This method calls setup on all the registered addons.

class pyanaconda.addons.AddonData(name)

Bases: object

This is a common parent class for loading and storing 3rd party data to kickstart. It is instantiated by kickstart parser and stored as ksdata.addons.<name> to be used in the user interfaces.

The mandatory method handle_line receives all lines from the corresponding addon section in kickstart and the mandatory __str__ implementation is responsible for returning the proper kickstart text (to be placed into the %addon section) back.

There is also a mandatory method execute, which should make all the described changes to the installed system.

execute(storage, ksdata, instClass, users)

Make the changes to the underlying system.

This method is called only once in the post-install setup phase.

finalize()

No additional data will come.

Addon should check if all mandatory attributes were populated.

handle_header(lineno, args)

Process additional arguments to the %addon line.

This function receives any arguments on the %addon line after the addon ID. For example, for the line:

%addon com_example_foo –argument=’example’

This function would be called with args=[“–argument=’example’”].

By default AddonData.handle_header just preserves the passed arguments by storing them and adding them to the __str__ output.

handle_line(line)

Process one kickstart line.

setup(storage, ksdata, instClass)

Make the changes to the install system.

This method is called before the installation is started and directly from spokes. It must be possible to call it multiple times without breaking the environment.

pyanaconda.addons.collect_addon_paths(toplevel_addon_paths, ui_subdir='gui')

This method looks into the directories present in toplevel_addon_paths and registers each subdirectory as a new addon identified by that subdirectory name.

It then registers spokes, categories and data (ks) paths for the application to use. By default is looks for spokes and categories in <addon>/gui/ subdirectory but that can be changed using the ui_subdir argument.

pyanaconda.anaconda module

pyanaconda.anaconda_argparse module

class pyanaconda.anaconda_argparse.AnacondaArgumentParser(*args, **kwargs)

Bases: argparse.ArgumentParser

Subclass of ArgumentParser that also examines boot arguments.

If the “bootarg_prefix” keyword argument is set, it’s assumed that all bootargs will start with that prefix.

“require_prefix” is a bool:
False: accept the argument with or without the prefix. True: ignore the argument without the prefix. (default)
add_argument(*args, **kwargs)

Add a new option - like ArgumentParser.add_argument.

The long options will be added to the list of boot args, unless the keyword argument ‘bootarg’ is set to False.

Positional arguments that don’t start with ‘-‘ are considered extra boot args to look for.

NOTE: conflict_handler is currently ignored for boot args - they will always raise ArgumentError if they conflict.

parse_args(args=None, boot_cmdline=None)

Like ArgumentParser.parse_args(), but also parses the boot cmdline. (see parse_boot_cmdline for details on that process.) Program cmdline arguments will override boot cmdline arguments.

Parameters:
  • args (string or None) – program command line arguments
  • boot_cmdline (string, dict or None) – the Anaconda boot command line arguments
Returns:

an argparse Namespace instance

Return type:

Namespace

parse_boot_cmdline(boot_cmdline)

Parse the boot cmdline and create an appropriate Namespace instance according to the option definitions set by add_argument.

boot_cmdline can be given as a string (to be parsed by BootArgs), or a dict (or any object with .items()) of {bootarg:value} pairs.

If boot_cmdline is None, the boot_cmdline data will be whatever BootArgs reads by default (/proc/cmdline, /run/initramfs/etc/cmdline, /etc/cmdline).

If an option requires a value but the boot arg doesn’t provide one, we’ll quietly not set anything in the Namespace. We also skip any boot options that were not specified by add_argument as we don’t care about them (there will usually be quite a lot of them (rd.*, etc.).

Parameters:boot_cmdline (string, dict or None) – the Anaconda boot command line arguments
Returns:an argparse Namespace instance
Return type:Namespace
class pyanaconda.anaconda_argparse.HelpTextParser(path)

Bases: object

Class to parse help text from file and make it available to option parser.

Initializer :param path: The absolute path to the help text file

help_text(option)

Returns the help text corresponding to the given command-line option. If no help text is available, returns the empty string.

Parameters:option (str) – The name of the option
Return type:str
read(lines)

Reads option, help text pairs from a text file.

Each pair is separated from the next by an empty line. The option comes first, followed by any number of lines of help text.

Parameters:lines – a sequence of lines of text
pyanaconda.anaconda_argparse.getArgumentParser(version_string, boot_cmdline=None)

Return the anaconda argument parser.

Parameters:
  • version_string (str) – The version string, e.g. 23.19.5.
  • pyanaconda.flags.BootArgs – The boot command line options
Return type:

AnacondaArgumentParser

pyanaconda.anaconda_argparse.get_help_width()

Try to detect the terminal window width size and use it to compute optimal help text width. If it can’t be detected a default values is returned.

Returns:optimal help text width in number of characters
Return type:int
pyanaconda.anaconda_argparse.name_path_pairs(image_specs)

Processes and verifies image file specifications. Generates pairs of names and paths.

Parameters:image_specs (list of str) – a list of image specifications

Each image spec in image_specs has format <path>[:<name>] where <path> is the path to a local file and <name> is an optional name used to identify the disk in UI. <name> may not contain colons or slashes.

If no name given in specification, synthesizes name from basename of path. Since two distinct paths may have the same basename, handles name collisions by synthesizing a different name for the colliding name.

Raises an exception if:
  • A path is empty
  • A path specifies a non-existant file
  • A path specifies a directory
  • Duplicate paths are specified
  • A name contains a “/”

pyanaconda.anaconda_log module

class pyanaconda.anaconda_log.AnacondaLog

Bases: object

SYSLOG_CFGFILE = '/etc/rsyslog.conf'
VIRTIO_PORT = '/dev/virtio-ports/org.fedoraproject.anaconda.log.0'
addFileHandler(dest, addToLogger, minLevel=20, fmtStr='%(asctime)s, %(msecs)03d %(levelname)s %(name)s: %(message)s', autoLevel=False)
forwardToSyslog(logr)

Forward everything that goes in the logger to the syslog daemon.

restartSyslog()
setupVirtio()

Setup virtio rsyslog logging.

setup_remotelog(host, port)
showwarning(message, category, filename, lineno, file=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>, line=None)

Make sure messages sent through python’s warnings module get logged.

The warnings mechanism is used by some libraries we use, notably pykickstart.

updateRemote(remote_syslog)

Updates the location of remote rsyslogd to forward to.

Requires updating rsyslogd config and restarting rsyslog

class pyanaconda.anaconda_log.AnacondaSocketHandler(host, port)

Bases: logging.handlers.SocketHandler

Initializes the handler with a specific host address and port.

When the attribute closeOnError is set to True - if a socket error occurs, the socket is silently closed and then reopened on the next logging call.

makePickle(record)
class pyanaconda.anaconda_log.AnacondaSyslogHandler(address=('localhost', 514), facility=1, tag='')

Bases: logging.handlers.SysLogHandler

emit(record)
levelMap = {'CRIT': 'critical', 'LOCK': 'debug', 'ERR': 'error'}
mapPriority(level)

Map the priority level to a syslog level

pyanaconda.anaconda_log.autoSetLevel(handler, value)
pyanaconda.anaconda_log.init()
pyanaconda.anaconda_log.setHandlersLevel(logr, level)

pyanaconda.bootloader module

pyanaconda.constants module

pyanaconda.constants_text module

pyanaconda.desktop module

class pyanaconda.desktop.Desktop

Bases: object

runlevel
write()

pyanaconda.errors module

exception pyanaconda.errors.InvalidImageSizeError(message, filename)

Bases: Exception

exception pyanaconda.errors.MissingImageError

Bases: Exception

exception pyanaconda.errors.MediaUnmountError(device)

Bases: Exception

exception pyanaconda.errors.MediaMountError(device)

Bases: Exception

exception pyanaconda.errors.ScriptError(lineno, details)

Bases: Exception

exception pyanaconda.errors.CmdlineError

Bases: Exception

pyanaconda.exception module

pyanaconda.flags module

class pyanaconda.flags.BootArgs(cmdline=None, files=None)

Bases: collections.OrderedDict

Hold boot arguments as an OrderedDict.

Create a BootArgs object. Reads each of the “files”, then parses “cmdline” if it was provided.

getbool(arg, default=False)

Return the value of the given arg, as a boolean. The rules are: - “arg”, “arg=val”: True - “noarg”, “noarg=val”, “arg=[0|off|no]”: False

read(filenames)

Read and parse a filename (or a list of filenames). Files that can’t be read are silently ignored. Returns a list of successfully read files. filenames can contain *, ?, and character ranges expressed with []

readstr(cmdline)
class pyanaconda.flags.Flags(read_cmdline=True)

Bases: object

get(attr, val=None)
read_cmdline()
set_cmdline_bool(flag)
pyanaconda.flags.can_touch_runtime_system(msg, touch_live=False)

Guard that should be used before doing actions that modify runtime system.

Parameters:
  • msg (str) – message to be logged in case that runtime system cannot be touched
  • touch_live (bool) – whether to allow touching liveCD installation system
Return type:

bool

pyanaconda.geoloc module

pyanaconda.i18n module

pyanaconda.i18n.N_(x)
pyanaconda.i18n.P_(x, y, z)
pyanaconda.i18n.C_(msgctxt, msgid)
pyanaconda.i18n.CN_(c, x)
pyanaconda.i18n.CP_(msgctxt, msgid, msgid_plural, n)

pyanaconda.ihelp module

Anaconda built-in help module

pyanaconda.ihelp.get_help_path(help_file, instclass)

Return the full path for the given help file name, if the help file path does not exist a fallback path is returned. There are actually two possible fallback paths that might be returned:

  • first we try to return path to the main page of the installation guide (if it exists)
  • if we can’t find the main page of the installation page, path to a “no help found” placeholder bundled with Anaconda is returned

Regarding help l10n, we try to respect the current locale as defined by the “LANG” environmental variable, but fallback to English if localized content is not available.

Parameters:
  • help_file (str or NoneType) – help file name
  • instclass – current install class instance
Return str:

full path to the help file requested or to a placeholder

pyanaconda.ihelp.kill_yelp()

Try to kill any existing yelp processes

pyanaconda.ihelp.start_yelp(help_path)

Start a new yelp process and make sure to kill any existing ones

Parameters:help_path (str or NoneType) – path to the help file yelp should load

pyanaconda.image module

pyanaconda.install module

pyanaconda.installclass module

pyanaconda.iutil module

class pyanaconda.iutil.DataHolder(**kwargs)

Bases: dict

A dict that lets you also access keys using dot notation.

kwargs are set as keys for the dict.

copy()
exception pyanaconda.iutil.ExitError

Bases: RuntimeError

class pyanaconda.iutil.ProxyString(url=None, protocol='http://', host=None, port='3128', username=None, password=None)

Bases: object

Handle a proxy url

Initialize with either url ([protocol://][username[:password]@]host[:port]) or pass host and optionally:

protocol http, https, ftp host hostname without protocol port port number (defaults to 3128) username username password password

The str() of the object is the full proxy url

ProxyString.url is the full url including username:password@ ProxyString.noauth_url is the url without username:password@

dict

return a dict of all the elements of the proxy string url, noauth_url, protocol, host, port, username, password

parse_components()

Parse the components of a proxy url into url and noauth_url

parse_url()

Parse the proxy url into its component pieces

exception pyanaconda.iutil.ProxyStringError

Bases: Exception

pyanaconda.iutil.add_po_path(directory)

Looks to see what translations are under a given path and tells the gettext module to use that path as the base dir

pyanaconda.iutil.augmentEnv()
pyanaconda.iutil.chown_dir_tree(root, uid, gid, from_uid_only=None, from_gid_only=None)

Change owner (uid and gid) of the files and directories under the given directory tree (recursively).

Parameters:
  • root (str) – root of the directory tree that should be chown’ed
  • uid (int) – UID that should be set as the owner
  • gid (int) – GID that should be set as the owner
  • from_uid_only (int or None) – if given, the owner is changed only for the files and directories owned by that UID
  • from_gid_only (int or None) – if given, the owner is changed only for the files and directories owned by that GID
pyanaconda.iutil.cmp_obj_attrs(obj1, obj2, attr_list)

Compare attributes of 2 objects for changes

Missing attrs are considered a mismatch

Parameters:
  • obj1 (Any object) – First object to compare
  • obj2 (Any object) – Second object to compare
  • attr_list (list or tuple of strings) – List of attributes to compare
Returns:

True if the attrs all match

Return type:

bool

pyanaconda.iutil.dir_tree_map(root, func, files=True, dirs=True)

Apply the given function to all files and directories in the directory tree under the given root directory.

Parameters:
  • root (str) – root of the directory tree the function should be mapped to
  • func (path -> None) – a function taking the directory/file path
  • files (bool) – whether to apply the function to the files in the dir. tree
  • dirs (bool) – whether to apply the function to the directories in the dir. tree

TODO: allow using globs and thus more trees?

pyanaconda.iutil.dracut_eject(device)

Use dracut shutdown hook to eject media after the system is shutdown. This is needed because we are running from the squashfs.img on the media so ejecting too early will crash the installer.

pyanaconda.iutil.ensure_str(str_or_bytes, keep_none=True)

Returns a str instance for given string or None if requested to keep it.

Parameters:
  • str_or_bytes (str or bytes) – string to be kept or converted to str type
  • keep_none (bool) – whether to keep None as it is or raise ValueError if None is passed
Raises ValueError:
 

if applied on an object not being of type bytes nor str (nor NoneType if keep_none is False)

pyanaconda.iutil.execConsole()
pyanaconda.iutil.execInSysroot(command, argv, stdin=None)

Run an external program in the target root. :param command: The command to run :param argv: The argument list :param stdin: The file object to read stdin from. :return: The return code of the command

pyanaconda.iutil.execReadlines(command, argv, stdin=None, root='/', env_prune=None, filter_stderr=False)

Execute an external command and return the line output of the command in real-time.

This method assumes that there is a reasonably low delay between the end of output and the process exiting. If the child process closes stdout and then keeps on truckin’ there will be problems.

NOTE/WARNING: UnicodeDecodeError will be raised if the output of the
external command can’t be decoded as UTF-8.
Parameters:
  • command – The command to run
  • argv – The argument list
  • stdin – The file object to read stdin from.
  • stdout – Optional file object to redirect stdout and stderr to.
  • root – The directory to chroot to before running command.
  • env_prune – environment variable to remove before execution
  • filter_stderr – Whether stderr should be excluded from the returned output

Output from the file is not logged to program.log This returns an iterator with the lines from the command until it has finished

pyanaconda.iutil.execWithCapture(command, argv, stdin=None, root='/', log_output=True, filter_stderr=False)

Run an external program and capture standard out and err.

Parameters:
  • command – The command to run
  • argv – The argument list
  • stdin – The file object to read stdin from.
  • root – The directory to chroot to before running command.
  • log_output – Whether to log the output of command
  • filter_stderr – Whether stderr should be excluded from the returned output
Returns:

The output of the command

pyanaconda.iutil.execWithCaptureBinary(command, argv, stdin=None, root='/', log_output=False, filter_stderr=False)

Run an external program and capture standard out and err as binary data. The binary data output is not logged by default but logging can be enabled.

Parameters:
  • command – The command to run
  • argv – The argument list
  • stdin – The file object to read stdin from.
  • root – The directory to chroot to before running command.
  • log_output – Whether to log the binary output of the command
  • filter_stderr – Whether stderr should be excluded from the returned output
Returns:

The output of the command

pyanaconda.iutil.execWithRedirect(command, argv, stdin=None, stdout=None, root='/', env_prune=None, log_output=True, binary_output=False)

Run an external program and redirect the output to a file.

Parameters:
  • command – The command to run
  • argv – The argument list
  • stdin – The file object to read stdin from.
  • stdout – Optional file object to redirect stdout and stderr to.
  • root – The directory to chroot to before running command.
  • env_prune – environment variable to remove before execution
  • log_output – whether to log the output of command
  • binary_output – whether to treat the output of command as binary data
Returns:

The return code of the command

pyanaconda.iutil.getDirSize(directory)

Get the size of a directory and all its subdirectories.

Parameters:dir – The name of the directory to find the size of.
Returns:The size of the directory in kilobytes.
pyanaconda.iutil.getSysroot()

Returns the path to the target OS installation.

For ordinary package-based installations, this is the same as the target root.

pyanaconda.iutil.getTargetPhysicalRoot()

Returns the path to the “physical” storage root, traditionally /mnt/sysimage.

This may be distinct from the sysroot, which could be a chroot-type subdirectory of the physical root. This is used for example by all OSTree-based installations.

pyanaconda.iutil.get_active_console(dev='console')

Find the active console device.

Some tty devices (/dev/console, /dev/tty0) aren’t actual devices; they just redirect input and output to the real console device(s).

These ‘fake’ ttys have an ‘active’ sysfs attribute, which lists the real console device(s). (If there’s more than one, the last one in the list is the primary console.)

pyanaconda.iutil.get_mount_paths(devnode)

given a device node, return a list of all active mountpoints.

pyanaconda.iutil.get_platform_groupid()

Return a platform group id string

This runs systemd-detect-virt and if the result is not ‘none’ it prefixes the lower case result with “platform-” for use as a group id.

Returns:Empty string or a group id for the detected platform
Return type:str
pyanaconda.iutil.getdeepattr(obj, name)

This behaves as the standard getattr, but supports composite (containing dots) attribute names.

As an example:

>>> import os
>>> from os.path import split
>>> getdeepattr(os, "path.split") == split
True
pyanaconda.iutil.have_word_match(str1, str2)

Tells if all words from str1 exist in str2 or not.

pyanaconda.iutil.id_generator()

Id numbers generator. Generating numbers from 0 to X and increments after every call.

Returns:Generator which gives you unique numbers.
pyanaconda.iutil.ipmi_report(event)
pyanaconda.iutil.isConsoleOnVirtualTerminal(dev='console')
pyanaconda.iutil.is_unsupported_hw()

Check to see if the hardware is supported or not.

Returns:True if this is unsupported hardware, False otherwise
Return type:bool
pyanaconda.iutil.lowerASCII(s)

Convert a string to lowercase using only ASCII character definitions.

The returned string will contain only ASCII characters. This function is locale-independent.

pyanaconda.iutil.mkdirChain(directory)

Make a directory and all of its parents. Don’t fail if part or of it already exists.

Parameters:directory (str) – The directory path to create
pyanaconda.iutil.open_with_perm(path, mode='r', perm=511, **kwargs)

Open a file with the given permission bits.

This is more or less the same as using os.open(path, flags, perm), but with the builtin open() semantics and return type instead of a file descriptor.

Parameters:
  • path (str) – The path of the file to be opened
  • mode (str) – The same thing as the mode argument to open()
  • perm (int) – What permission bits to use if creating a new file
pyanaconda.iutil.parent_dir(directory)

Return the parent’s path

pyanaconda.iutil.parseNfsUrl(nfsurl)
pyanaconda.iutil.persistent_root_image()
Returns:whether we are running from a persistent (not in RAM) root.img
pyanaconda.iutil.reIPL(ipldev)
pyanaconda.iutil.requests_session()

Return a requests.Session object with file and ftp support.

pyanaconda.iutil.resetRpmDb()
pyanaconda.iutil.restart_service(service)
pyanaconda.iutil.save_screenshots()

Save screenshots to the installed system

pyanaconda.iutil.service_running(service)
pyanaconda.iutil.setSysroot(path)
Change the OS root path.
param path:The new OS root path

This should only be used by Payload subclasses which install operating systems to non-default roots.

pyanaconda.iutil.setTargetPhysicalRoot(path)

Change the physical root path

Parameters:path (string) – Path to use instead of /mnt/sysimage/
pyanaconda.iutil.setdeepattr(obj, name, value)

This behaves as the standard setattr, but supports composite (containing dots) attribute names.

As an example:

>>> class O:
>>>   pass
>>> a = O()
>>> a.b = O()
>>> a.b.c = O()
>>> setdeepattr(a, "b.c.d", True)
>>> a.b.c.d
True
pyanaconda.iutil.setenv(name, value)

Set an environment variable to be used by child processes.

This method does not modify os.environ for the running process, which is not thread-safe. If setenv has already been called for a particular variable name, the old value is overwritten.

Parameters:
  • name (str) – The name of the environment variable
  • value (str) – The value of the environment variable
pyanaconda.iutil.setup_translations()
pyanaconda.iutil.startProgram(argv, root='/', stdin=None, stdout=-1, stderr=-2, env_prune=None, env_add=None, reset_handlers=True, reset_lang=True, **kwargs)

Start an external program and return the Popen object.

The root and reset_handlers arguments are handled by passing a preexec_fn argument to subprocess.Popen, but an additional preexec_fn can still be specified and will be run. The user preexec_fn will be run last.

Parameters:
  • argv – The command to run and argument
  • root – The directory to chroot to before running command.
  • stdin – The file object to read stdin from.
  • stdout – The file object to write stdout to.
  • stderr – The file object to write stderr to.
  • env_prune – environment variables to remove before execution
  • env_add – environment variables to add before execution
  • reset_handlers – whether to reset to SIG_DFL any signal handlers set to SIG_IGN
  • reset_lang – whether to set the locale of the child process to C
  • kwargs – Additional parameters to pass to subprocess.Popen
Returns:

A Popen object for the running command.

pyanaconda.iutil.startX(argv, output_redirect=None)

Start X and return once X is ready to accept connections.

X11, if SIGUSR1 is set to SIG_IGN, will send SIGUSR1 to the parent process once it is ready to accept client connections. This method sets that up and waits for the signal or bombs out if nothing happens for a minute. The process will also be added to the list of watched processes.

Parameters:
  • argv – The command line to run, as a list
  • output_redirect – file or file descriptor to redirect stdout and stderr to
pyanaconda.iutil.start_service(service)
pyanaconda.iutil.stop_service(service)
pyanaconda.iutil.strip_accents(s)

This function takes arbitrary unicode string and returns it with all the diacritics removed.

Parameters:s (str) – arbitrary string
Returns:s with diacritics removed
Return type:str
pyanaconda.iutil.sysroot_path(path)

Make the given relative or absolute path “sysrooted” :param str path: path to be sysrooted :returns: sysrooted path :rtype: str

pyanaconda.iutil.touch(file_path)

Create an empty file.

pyanaconda.iutil.unwatchAllProcesses()

Clear the watched process list.

pyanaconda.iutil.unwatchProcess(proc)

Unwatch a process watched by watchProcess.

Parameters:proc – The Popen object for the process.
pyanaconda.iutil.upcase_first_letter(text)

Helper function that upcases the first letter of the string. Python’s standard string.capitalize() not only upcases the first letter but also lowercases all the others. string.title() capitalizes all words in the string.

Returns:the given text with the first letter upcased
Return type:str
pyanaconda.iutil.upperASCII(s)

Convert a string to uppercase using only ASCII character definitions.

The returned string will contain only ASCII characters. This function is locale-independent.

pyanaconda.iutil.vtActivate(num)

Try to switch to tty number $num.

Returns:whether the switch was successful or not
Return type:bool
pyanaconda.iutil.watchProcess(proc, name)

Watch for a process exit, and raise a ExitError when it does.

This method installs a SIGCHLD signal handler and thus interferes the child_watch_add methods in GLib. Use watchProcessGLib to convert to GLib mode if using a GLib main loop.

Since the SIGCHLD handler calls wait() on the watched process, this call cannot be combined with Popen.wait() or Popen.communicate, and also doing so wouldn’t make a whole lot of sense.

Parameters:
  • proc – The Popen object for the process
  • name – The name of the process
pyanaconda.iutil.watchProcessGLib()

Convert process watching to GLib mode.

This allows anaconda modes that use GLib main loops to use GLib.child_watch_add and continue to watch processes started before the main loop.

pyanaconda.kexec module

exception pyanaconda.kexec.GrubbyInfoError

Bases: Exception

pyanaconda.kexec.run_grubby(args=None)

Run grubby and retrieve the kernel, initrd and boot arguments

Parameters:args (list) – Arguments to pass to grubby.
Returns:kernel path, initrd path, root device, kernel cmdline args.
Return type:namedtuple
Raises:some error on failure
The returned namedtuple contains the following attributes:
kernel, initrd, root, args
pyanaconda.kexec.setup_kexec(extra_args=None)

Setup kexec to use the new kernel and default bootloader entry

Parameters:extra_args (list) – Extra arguments to pass to kexec

This uses grubby to determine the bootloader arguments from the default entry, and then sets up kexec so that reboot will use the new kernel and initrd instead of doing a full reboot.

Note

Once kexec is called there is nothing else to do, the reboot code already handles having kexec setup.

pyanaconda.keyboard module

This module provides functions for dealing with keyboard layouts/keymaps in Anaconda and the LocaledWrapper class with methods for setting, getting and mutually converting X layouts and VConsole keymaps.

exception pyanaconda.keyboard.InvalidLayoutVariantSpec

Bases: Exception

Exception class for errors related to parsing layout and variant specification strings.

exception pyanaconda.keyboard.KeyboardConfigError

Bases: Exception

Exception class for keyboard configuration related problems

class pyanaconda.keyboard.LocaledWrapper

Bases: object

Class wrapping systemd-localed daemon functionality. By using safe_dbus module it tries to prevent failures related to threads and main loops.

convert_keymap(keymap)

Method that returns X11 layouts and variants that (systemd-localed thinks) match given keymap best.

Parameters:keymap (str) – VConsole keymap
Returns:X11 layouts and variants that (systemd-localed thinks) match given keymap best
Return type:str
convert_layout(layout_variant)

Method that returns VConsole keymap that (systemd-localed thinks) matches given layout and variant best.

Parameters:layout_variant (str) – ‘layout (variant)’ or ‘layout’ specification
Returns:a keymap matching layout and variant best
Return type:string
keymap
layouts_variants
options
set_and_convert_keymap(keymap)

Method that sets VConsole keymap and returns X11 layouts and variants that (systemd-localed thinks) match given keymap best.

Returns:string containing comma-separated “layout (variant)” or “layout” layout specifications
Return type:string
set_and_convert_layout(layout_variant)

Method that sets X11 layout and variant (for later X sessions) and returns VConsole keymap that (systemd-localed thinks) matches given layout and variant best.

Returns:a keymap matching layout and variant best
Return type:string
set_keymap(keymap, convert=False)

Method that sets VConsole keymap via systemd-localed’s DBus API.

Parameters:
  • keymap (str) – VConsole keymap that should be set
  • convert (bool) – whether the keymap should be converted to a X11 layout (see set_and_convert_keymap)
set_layouts(layouts_variants, options=None, convert=False)

Method that sets X11 layouts and variants (for later X sessions) via systemd-localed’s DBus API.

Parameters:
  • layout_variant (list of strings) – list of ‘layout (variant)’ or ‘layout’ specifications of layouts and variants
  • options (list of strings) – list of X11 options that should be set
  • convert (bool) – whether the keymap should be converted to a X11 layout (see set_and_convert_keymap)
exception pyanaconda.keyboard.LocaledWrapperError

Bases: pyanaconda.keyboard.KeyboardConfigError

Exception class for reporting Localed-related problems

pyanaconda.keyboard.activate_keyboard(keyboard)

Try to setup VConsole keymap and X11 layouts as specified in kickstart.

Parameters:keyboard (ksdata.keyboard object) – ksdata.keyboard object
pyanaconda.keyboard.join_layout_variant(layout, variant='')

Join layout and variant to form the commonly used ‘layout (variant)’ or ‘layout’ (if variant is missing) format.

Returns:‘layout (variant)’ or ‘layout’ string
Return type:string
pyanaconda.keyboard.normalize_layout_variant(layout_str)

Normalize keyboard layout and variant specification given as a single string. E.g. for a ‘layout(variant) string missing the space between the left parenthesis return ‘layout (variant)’ which is a proper layout and variant specification we use.

Parameters:layout_str (string) – a string specifying keyboard layout and its variant
pyanaconda.keyboard.parse_layout_variant(layout_variant_str)

Parse layout and variant from the string that may look like ‘layout’ or ‘layout (variant)’.

Parameters:layout_variant_str (str) – keyboard layout and variant string specification
Returns:the (layout, variant) pair, where variant can be “”
Return type:tuple
Raises InvalidLayoutVariantSpec:
 if the given string isn’t a valid layout and variant specification string
pyanaconda.keyboard.populate_missing_items(keyboard)

Function that populates keyboard.vc_keymap and keyboard.x_layouts if they are missing. By invoking LocaledWrapper’s methods this function READS AND WRITES CONFIGURATION FILES (but tries to keep their content unchanged).

pyanaconda.keyboard.write_keyboard_config(keyboard, root, convert=True)

Function that writes files with layouts configuration to $root/etc/X11/xorg.conf.d/01-anaconda-layouts.conf and $root/etc/vconsole.conf.

Parameters:
  • keyboard – ksdata.keyboard object
  • root – path to the root of the installed system
  • convert – whether to convert specified values to get the missing ones
  • weight – weight (prefix) of the xorg.conf file written out

pyanaconda.kickstart module

pyanaconda.localization module

exception pyanaconda.localization.InvalidLocaleSpec

Bases: pyanaconda.localization.LocalizationConfigError

Exception class for the errors related to invalid locale specs

exception pyanaconda.localization.LocalizationConfigError

Bases: Exception

Exception class for localization configuration related problems

pyanaconda.localization.find_best_locale_match(locale, langcodes)

Find the best match for the locale in a list of langcodes. This is useful when e.g. pt_BR is a locale and there are possibilities to choose an item (e.g. rnote) for a list containing both pt and pt_BR or even also pt_PT.

Parameters:
  • locale (str) – a valid locale (e.g. en_US.UTF-8 or sr_RS.UTF-8@latin, etc.)
  • langcodes (list(str) or generator(str)) – a list or generator of langcodes (e.g. en, en_US, en_US@latin, etc.)
Returns:

the best matching langcode from the list of None if none matches

Return type:

str or None

pyanaconda.localization.get_available_translations(localedir=None)

Method that generates (i.e. returns a generator) available translations for the installer in the given localedir.

Returns:generator yielding available translations (languages)
Return type:generator yielding strings
pyanaconda.localization.get_english_name(locale)

Function returning english name for the given locale.

Parameters:locale (str) – locale to return english name for
Returns:english name for the locale or empty string if unknown
Return type:st
Raises InvalidLocaleSpec:
 if an invalid locale is given (see LANGCODE_RE)
pyanaconda.localization.get_firmware_language(text_mode=False)

Procedure that returns the firmware language information (if any).

Parameters:text_mode (boot) – if the locale is being setup for text mode
Returns:the firmware language translated into a locale string, or None
Return type:str
pyanaconda.localization.get_language_locales(lang)

Function returning all locales available for the given language.

Parameters:lang (str) – language to get available locales for
Returns:a list of available locales
Return type:list of strings
Raises InvalidLocaleSpec:
 if an invalid locale is given (see LANGCODE_RE)
pyanaconda.localization.get_locale_console_fonts(locale)

Function returning preferred console fonts for the given locale.

Parameters:locale (str) – locale string (see LANGCODE_RE)
Returns:list of preferred console fonts
Return type:list of strings
Raises InvalidLocaleSpec:
 if an invalid locale is given (see LANGCODE_RE)
pyanaconda.localization.get_locale_keyboards(locale)

Function returning preferred keyboard layouts for the given locale.

Parameters:locale (str) – locale string (see LANGCODE_RE)
Returns:list of preferred keyboard layouts
Return type:list of strings
Raises InvalidLocaleSpec:
 if an invalid locale is given (see LANGCODE_RE)
pyanaconda.localization.get_locale_scripts(locale)

Function returning preferred scripts (writing systems) for the given locale.

Parameters:locale (str) – locale string (see LANGCODE_RE)
Returns:list of preferred scripts
Return type:list of strings
Raises InvalidLocaleSpec:
 if an invalid locale is given (see LANGCODE_RE)
pyanaconda.localization.get_locale_territory(locale)

Function returning locale’s territory.

Parameters:locale (str) – locale string (see LANGCODE_RE)
Returns:territory or None
Return type:str or None
Raises InvalidLocaleSpec:
 if an invalid locale is given (see LANGCODE_RE)
pyanaconda.localization.get_locale_timezones(locale)

Function returning preferred timezones for the given locale.

Parameters:locale (str) – locale string (see LANGCODE_RE)
Returns:list of preferred timezones
Return type:list of strings
Raises InvalidLocaleSpec:
 if an invalid locale is given (see LANGCODE_RE)
pyanaconda.localization.get_native_name(locale)

Function returning native name for the given locale.

Parameters:locale (str) – locale to return native name for
Returns:english name for the locale or empty string if unknown
Return type:st
Raises InvalidLocaleSpec:
 if an invalid locale is given (see LANGCODE_RE)
pyanaconda.localization.get_territory_locales(territory)

Function returning list of locales for the given territory. The list is sorted from the most probable locale to the least probable one (based on langtable’s ranking.

Parameters:territory (str) – territory to return locales for
Returns:list of locales
Return type:list of strings
pyanaconda.localization.get_xlated_timezone(tz_spec_part)

Function returning translated name of a region, city or complete timezone name according to the current value of the $LANG variable.

Parameters:tz_spec_part (str) – a region, city or complete timezone name
Returns:translated name of the given region, city or timezone
Return type:str
pyanaconda.localization.is_supported_locale(locale)

Function that tells if the given locale is supported by the Anaconda or not. We consider locales supported by the langtable as supported by the Anaconda.

Parameters:locale (str) – locale to test
Returns:whether the given locale is supported or not
Return type:bool
Raises InvalidLocaleSpec:
 if an invalid locale is given (see LANGCODE_RE)
pyanaconda.localization.langcode_matches_locale(langcode, locale)

Function that tells if the given langcode matches the given locale. I.e. if all parts of appearing in the langcode (language, territory, script and encoding) are the same as the matching parts of the locale.

Parameters:
Returns:

whether the given langcode matches the given locale or not

Return type:

bool

pyanaconda.localization.locale_supported_in_console(locale)

Function that tells if the given locale can be displayed by the Linux console.

The Linux console can display Latin, Cyrillic and Greek characters reliably, but others such as Japanese, can’t be correctly installed.

Parameters:locale (str) – locale to test
Returns:whether the given locale is supported by the console or not
Return type:bool
Raises InvalidLocaleSpec:
 if an invalid locale is given (see LANGCODE_RE)
pyanaconda.localization.parse_langcode(langcode)

For a given langcode (e.g. 'SR_RS.UTF-8@latin‘) returns a dictionary with the following keys and example values:

‘language’ : ‘SR’ ‘territory’ : ‘RS’ ‘encoding’ : ‘UTF-8’ ‘script’ : ‘latin’

or None if the given string doesn’t match the LANGCODE_RE.

pyanaconda.localization.resolve_date_format(year, month, day, fail_safe=True)

Puts the year, month and day objects in the right order according to the currently set locale and provides format specification for each of the fields.

Parameters:
  • year (any) – any object or value representing year
  • month (any) – any object or value representing month
  • day (any) – any object or value representing day
  • fail_safe (bool) – whether to fall back to default in case of invalid format or raise exception instead
Returns:

a pair where the first field contains a tuple with the year, month and day objects/values put in the right order and where the second field contains a tuple with three _DateFieldSpec objects specifying formats respectively to the first (year, month, day) field, e.g. ((year, month, day), (y_fmt, m_fmt, d_fmt))

Return type:

tuple

Raises ValueError:
 

in case currently set locale has unsupported date format and fail_safe is set to False

pyanaconda.localization.set_console_font(font)

Try to set console font to the given value.

Parameters:font (str) – console font name
Returns:True on success, False on failure
Return type:Bool
pyanaconda.localization.setup_locale(locale, lang=None, text_mode=False)

Procedure setting the system to use the given locale and store it in to the ksdata.lang object (if given). DOES NOT PERFORM ANY CHECKS OF THE GIVEN LOCALE.

$LANG must be set by the caller in order to set the language used by gettext. Doing this in a thread-safe way is up to the caller.

We also try to set a proper console font for the locale in text mode. If the font for the locale can’t be displayed in the Linux console, we fall back to the English locale.

This function returns the locale that was used in the setlocale call, which, depending on what the environment and interface is able to support, may be different from the locale requested.

Parameters:
  • locale (str) – locale to setup
  • lang – ksdata.lang object or None
  • text_mode (bool) – if the locale is being setup for text mode
Returns:

the locale that was actually set

Return type:

str

pyanaconda.localization.setup_locale_environment(locale=None, text_mode=False, prefer_environment=False)

Clean and configure the local environment variables.

This function will attempt to determine the desired locale and configure the process environment (os.environ) in the least surprising way. If a locale argument is provided, it will be attempted first. After that, this function will attempt to use the language environment variables in a manner similar to gettext(3) (in order, $LANGUAGE, $LC_ALL, $LC_MESSAGES, $LANG), followed by the UEFI PlatformLang, followed by a default.

When this function returns, $LANG will be set, and $LANGUAGE, $LC_ALL, and $LC_MESSAGES will not be set, because they get in the way when changing the language after startup.

This function must be run before any threads are started. This function modifies the process environment, which is not thread-safe.

Parameters:
  • locale (str) – locale to setup if provided
  • text_mode (bool) – if the locale is being setup for text mode
  • prefer_environment (bool) – whether the process environment, if available, overrides the locale parameter
Returns:

None

Return type:

None

pyanaconda.localization.write_language_configuration(lang, root)

Write language configuration to the $root/etc/locale.conf file.

Parameters:
  • lang – ksdata.lang object
  • root – path to the root of the installed system

pyanaconda.network module

pyanaconda.nm module

exception pyanaconda.nm.AddConnectionError

Bases: Exception

Connection is not available for the device

exception pyanaconda.nm.BondOptionsError

Bases: pyanaconda.nm.AddConnectionError

exception pyanaconda.nm.DeviceNotActiveError

Bases: Exception

Device of specified name is not active

exception pyanaconda.nm.PropertyNotFoundError

Bases: ValueError

Property of NM object was not found

exception pyanaconda.nm.SettingsNotFoundError

Bases: ValueError

Settings NMRemoteConnection object was not found

exception pyanaconda.nm.UnknownConnectionError

Bases: Exception

Connection is not available for the device

exception pyanaconda.nm.UnknownDeviceError

Bases: ValueError

Device of specified name was not found by NM

exception pyanaconda.nm.UnknownMethodGetError

Bases: Exception

Object does not have Get, most probably being invalid

exception pyanaconda.nm.UnmanagedDeviceError

Bases: Exception

Device of specified name is not managed by NM or unavailable

pyanaconda.nm.nm_activate_device_connection(dev_name, con_uuid)

Activate device with specified connection.

Parameters:
  • dev_name (str or None) – name of device or None for virtual devices
  • con_uuid (str) – uuid of connection to be activated on device
Raises:
  • UnknownDeviceError – if device is not found
  • UnmanagedDeviceError – if device is not managed by NM or unavailable
  • SettingsNotFoundError – if conneciton with given uuid was not found
  • UnknownConnectionError – if connection is not available for the device
pyanaconda.nm.nm_activated_devices()

Return names of activated network devices.

Returns:names of activated network devices
Return type:list of strings
pyanaconda.nm.nm_add_connection(values)

Add new connection specified by values.

Parameters:values
list of settings with new values and its types
[[key1, key2, value, type_str], ...]
key1: first-level key of setting (eg “connection”)
key2: second-level key of setting (eg “uuid”)
value: new value
type_str: dbus type of new value (eg “ay”)
pyanaconda.nm.nm_dbus_ay_to_ipv6(bytelist)

Convert ipv6 address from list of bytes (dbus ‘ay’) to string.

Parameters:address (list of bytes - dbus ‘ay’) – IPv6 address as list of bytes returned by dbus (‘ay’)
Returns:IPv6 address
Return type:str
pyanaconda.nm.nm_dbus_int_to_ipv4(address)

Convert ipv4 address from dus int ‘u’ (switched endianess) to string.

Parameters:address (integer - dbus ‘u’) – IPv4 address as integer returned by dbus (‘u’)
Returns:IPv6 address
Return type:str
pyanaconda.nm.nm_device_active_con_uuid(name)

Return uuid of device’s active connection

Exceptions: UnknownDeviceError if device is not found

pyanaconda.nm.nm_device_active_ssid(name)

Return ssid of device’s active access point.

Parameters:name (str) – name of device
Returns:ssid of active access point, None if device has no active AP
Return type:str
Raises UnknownDeviceError:
 if device is not found
pyanaconda.nm.nm_device_carrier(name)

Return whether physical carrier of device is found. (‘Carrier’ property)

Parameters:

name (str) – name of device

Returns:

True if physical carrier is found, False otherwise

Return type:

bool

Raises:
  • UnknownDeviceError – if device is not found
  • PropertyNotFoundError – if ‘Carrier’ property is not found
pyanaconda.nm.nm_device_hwaddress(name)

Return active hardware address of device (‘HwAddress’ property)

Parameters:

name (str) – name of device

Returns:

active hardware address of device (‘HwAddress’ property)

Return type:

str

Raises:
  • UnknownDeviceError – if device is not found
  • PropertyNotFoundError – if ‘HwAddress’ property is not found
pyanaconda.nm.nm_device_ip_addresses(name, version=4)

Return IP addresses of device in ACTIVATED state.

Parameters:
  • name (str) – name of device
  • version (int) – version of IP protocol (value 4 or 6)
Returns:

IP addresses of device, empty list if device is not in ACTIVATED state

Return type:

list of strings

Raises:
  • UnknownDeviceError – if device is not found
  • PropertyNotFoundError – if IP configuration is not found
pyanaconda.nm.nm_device_ip_config(name, version=4)

Return IP configurations of device in ACTIVATED state.

Parameters:
  • name (str) – name of device
  • version (int) – version of IP protocol (value 4 or 6)
Returns:

IP configuration of device, empty list if device is not in ACTIVATED state

Return type:

[[[address1, prefix1, gateway1], [address2, prefix2, gateway2], ...],
[nameserver1, nameserver2]]
addressX, gatewayX: string
prefixX: int

Raises:
  • UnknownDeviceError – if device is not found
  • PropertyNotFoundError – if ip configuration is not found
pyanaconda.nm.nm_device_is_slave(name)

Is the device a slave?

Exceptions: UnknownDeviceError if device is not found

pyanaconda.nm.nm_device_perm_hwaddress(name)

Return active hardware address of device (‘PermHwAddress’ property)

Parameters:

name (str) – name of device

Returns:

active hardware address of device (‘PermHwAddress’ property)

Return type:

str

Raises:
  • UnknownDeviceError – if device is not found
  • PropertyNotFoundError – if ‘PermHwAddress’ property is not found
pyanaconda.nm.nm_device_property(name, prop)

Return value of device NM property

Parameters:
  • name (str) – name of device
  • prop – property
Returns:

value of device’s property

Return type:

unpacked GDBus value

Raises:
  • UnknownDeviceError – if device is not found
  • PropertyNotFoundError – if property is not found
pyanaconda.nm.nm_device_setting_value(name, key1, key2)

Return value of device’s setting specified by key1 and key2.

Parameters:
  • name (str) – name of device
  • key1 (str) – first-level key of setting (eg “connection”)
  • key2 (str) – second-level key of setting (eg “uuid”)
Returns:

value of setting or None if the setting was not found which means it does not exist or default value is used by NM

Return type:

unpacked GDBus variant or None

Raises:
  • UnknownDeviceError – if device is not found
  • SettingsNotFoundError – if settings were not found (eg for “wlan0”)
pyanaconda.nm.nm_device_slaves(name)

Return slaves of device.

Parameters:name (str) – name of device
Returns:names of slaves of device or None if device has no ‘Slaves’ property
Return type:list of strings or None
Raises UnknownDeviceError:
 if device is not found
pyanaconda.nm.nm_device_type(name)

Return device’s type (‘DeviceType’ property).

Parameters:

name (str) – name of device

Returns:

device type

Return type:

integer

Raises:
  • UnknownDeviceError – if device is not found
  • PropertyNotFoundError – if ‘DeviceType’ property is not found
pyanaconda.nm.nm_device_type_is_bond(name)

Is the type of device bond?

Parameters:

name (str) – name of device

Returns:

True if type of device is BOND, False otherwise

Return type:

bool

Raises:
  • UnknownDeviceError – if device is not found
  • PropertyNotFoundError – if property is not found
pyanaconda.nm.nm_device_type_is_bridge(name)

Is the type of device bridge?

Parameters:

name (str) – name of device

Returns:

True if type of device is BRIDGE, False otherwise

Return type:

bool

Raises:
  • UnknownDeviceError – if device is not found
  • PropertyNotFoundError – if property is not found
pyanaconda.nm.nm_device_type_is_ethernet(name)

Is the type of device ethernet?

Parameters:

name (str) – name of device

Returns:

True if type of device is ETHERNET, False otherwise

Return type:

bool

Raises:
  • UnknownDeviceError – if device is not found
  • PropertyNotFoundError – if property is not found
pyanaconda.nm.nm_device_type_is_infiniband(name)

Is the type of device infiniband?

Exceptions: UnknownDeviceError if device is not found PropertyNotFoundError if type is not found

pyanaconda.nm.nm_device_type_is_team(name)

Is the type of device team?

Parameters:

name (str) – name of device

Returns:

True if type of device is TEAM, False otherwise

Return type:

bool

Raises:
  • UnknownDeviceError – if device is not found
  • PropertyNotFoundError – if property is not found
pyanaconda.nm.nm_device_type_is_vlan(name)

Is the type of device vlan?

Parameters:

name (str) – name of device

Returns:

True if type of device is VLAN, False otherwise

Return type:

bool

Raises:
  • UnknownDeviceError – if device is not found
  • PropertyNotFoundError – if property is not found
pyanaconda.nm.nm_device_type_is_wifi(name)

Is the type of device wifi?

Parameters:

name (str) – name of device

Returns:

True if type of device is WIFI, False otherwise

Return type:

bool

Raises:
  • UnknownDeviceError – if device is not found
  • PropertyNotFoundError – if property is not found
pyanaconda.nm.nm_device_valid_hwaddress(name)

Return valid hardware address of device depending on type of the device (‘PermHwAddress’ property for wired and wireless or ‘HwAddress’ property for others)

Parameters:

name (str) – name of device

Returns:

active hardware address of device (‘HwAddress’ or ‘PermHwAddress’ property)

Return type:

str

Raises:
  • UnknownDeviceError – if device is not found
  • PropertyNotFoundError – if property is not found
pyanaconda.nm.nm_devices()

Return names of network devices supported in installer.

Returns:names of network devices supported in installer
Return type:list of strings
pyanaconda.nm.nm_disconnect_device(name)

Disconnect the device.

Raises UnknownDeviceError:
 if device is not found
pyanaconda.nm.nm_get_all_settings()

Return all settings for logging.

pyanaconda.nm.nm_get_settings(value, key1, key2, format_value=<function <lambda>>)

Return settings having given value of key1, key2 setting

Returns list of settings(dicts) , None if settings were not found.

pyanaconda.nm.nm_hwaddr_to_device_name(hwaddr)

Return device name of interface with given hardware address.

Parameters:hwaddr (str) – hardware address
Returns:device name of interface having hwaddr
Return type:str
pyanaconda.nm.nm_ipv4_to_dbus_int(address)

Convert ipv4 address from string to int for dbus (switched endianess).

Parameters:address (str) – IPv4 address
Returns:IPv4 address as an integer ‘u’ for NM dbus setting
Return type:integer
pyanaconda.nm.nm_ipv6_to_dbus_ay(address)

Convert ipv6 address from string to list of bytes ‘ay’ for dbus

Parameters:address (str) – IPv6 address
Returns:address in format ‘ay’ for NM dbus setting
Return type:list of bytes
pyanaconda.nm.nm_is_connected()

Is NetworkManager connected?

Returns:True if NM is connected, False otherwise.
Return type:bool
pyanaconda.nm.nm_is_connecting()

Is NetworkManager connecting?

Returns:True if NM is in CONNECTING state, False otherwise.
Return type:bool
pyanaconda.nm.nm_ntp_servers_from_dhcp()

Return NTP servers obtained by DHCP.

return: NTP servers obtained by DHCP rtype: list of str

pyanaconda.nm.nm_state()

Return state of NetworkManager

Returns:state of NetworkManager
Return type:integer
pyanaconda.nm.nm_update_settings_of_device(name, new_values)

Update setting of device.

The type of value is determined from existing settings of device. If setting for key1, key2 does not exist, default_type_str is used or if None, the type is inferred from the value supplied (string and bool only).

Parameters:
  • name (str) – name of device
  • new_values
    list of settings with new values and its types
    [[key1, key2, value, default_type_str]]
    key1: first-level key of setting (eg “connection”)
    key2: second-level key of setting (eg “uuid”)
    value: new value
    default_type_str:
    dbus type of new value to be used if the setting does not already exist; if None, the type is inferred from value (string and bool only)
Raises:
  • UnknownDeviceError – if device is not found
  • SettingsNotFoundError – if settings were not found (eg for “wlan0”)
pyanaconda.nm.test()

pyanaconda.ntp module

pyanaconda.product module

pyanaconda.product.distributionText()
pyanaconda.product.translated_new_install_name()

pyanaconda.progress module

pyanaconda.progress.progress_complete()
pyanaconda.progress.progress_init(steps)
pyanaconda.progress.progress_message(message)
pyanaconda.progress.progress_report(message)
pyanaconda.progress.progress_step(message)

pyanaconda.pwpolicy module

class pyanaconda.pwpolicy.F22_PwPolicy(writePriority=0, *args, **kwargs)

Bases: pykickstart.base.KickstartCommand

Kickstart command implementing password policy.

dataList()
get_policy(name)

Get the policy by name

Parameters:name (str) – Name of the policy to return.
parse(args)
removedAttrs = []
removedKeywords = []
class pyanaconda.pwpolicy.F22_PwPolicyData(*args, **kwargs)

Bases: pykickstart.base.BaseData

Kickstart Data object to hold information about pwpolicy.

removedAttrs = []
removedKeywords = []

pyanaconda.queuefactory module

class pyanaconda.queuefactory.QueueFactory(name)

Bases: object

Constructs a new object wrapping a Queue.Queue, complete with constants and sending functions for each type of message that can be put into the queue.

Creating a new object using this class is done like so:

q = QueueFactory(“progress”)

And then adding messages to it is done like so:

q.addMessage(“init”, 0) q.addMessage(“step”, 1)

The first call will create a new constant named PROGRESS_CODE_INIT and a method named send_init that takes zero arguments. The second call will create a new constant named PROGRESS_CODE_STEP and a method named send_step that takes one argument.

Reusing names within the same class is not allowed.

addMessage(name, argc)

pyanaconda.regexes module

pyanaconda.rescue module

pyanaconda.safe_dbus module

Module providing thread-safe and mainloop-safe DBus operations.

exception pyanaconda.safe_dbus.DBusCallError

Bases: pyanaconda.safe_dbus.SafeDBusError

Class for the errors related to calling methods over DBus.

exception pyanaconda.safe_dbus.DBusPropertyError

Bases: pyanaconda.safe_dbus.DBusCallError

Class for the errors related to getting property values over DBus.

exception pyanaconda.safe_dbus.SafeDBusError

Bases: Exception

Class for exceptions defined in this module.

pyanaconda.safe_dbus.call_sync(service, obj_path, iface, method, args, connection=None)

Safely call a given method on a given object of a given service over DBus passing given arguments. If a connection is given, it is used, otherwise a new connection is established. Safely means that it is a synchronous, thread-safe call not using any main loop.

Parameters:
  • service (str) – DBus service to use
  • obj_path (str) – object path of the object to call method on
  • iface (str) – interface to use
  • method (str) – name of the method to call
  • args (GVariant) – arguments to pass to the method
  • connection (Gio.DBusConnection) – connection to use (if None, a new connection is established)
Returns:

unpacked value returned by the method

Return type:

tuple with elements that depend on the method

Raises DBusCallError:
 

if some DBus related error appears

pyanaconda.safe_dbus.get_new_session_connection()

Get a connection handle for the per-user-login-session message bus.

!!! RUN THIS EARLY !!! like, before any other threads start. Connections to the session bus must be made with the effective UID of the login user, which in live installs is not the UID of anaconda. This means we need to call seteuid in this method, and doing that after threads have started will probably do something weird.

Live installs use consolehelper to run as root, which sets the original UID in $USERHELPER_UID.

Returns:

the session connection handle

Return type:

Gio.DBusConnection

Raises:
  • DBusCallError – if some DBus related error appears
  • OSError – if unable to set the effective UID
pyanaconda.safe_dbus.get_new_system_connection()

Return a new connection to the system bus.

pyanaconda.safe_dbus.get_property_sync(service, obj_path, iface, prop_name, connection=None)

Get value of a given property of a given object provided by a given service.

Parameters:
  • service (str) – DBus service to use
  • obj_path (str) – object path
  • iface (str) – interface to use
  • prop_name (str) – name of the property
  • connection (Gio.DBusConnection) – connection to use (if None, a new connection is established)
Returns:

unpacked value of the property

Return type:

tuple with elements that depend on the type of the property

Raises:
  • DBusCallError – when the internal dbus_call_safe_sync invocation raises an exception
  • DBusPropertyError – when the given object doesn’t have the given property

pyanaconda.screensaver module

pyanaconda.screensaver.inhibit_screensaver(connection)

Inhibit the screensaver idle timer.

Parameters:connection (Gio.DBusConnection) – A handle for the session message bus
Returns:The inhibit ID or None
Return type:int or None
pyanaconda.screensaver.uninhibit_screensaver(connection, inhibit_id)

Re-enable the screensaver idle timer.

Parameters:
  • connection (Gio.DBusConnection) – A handle for the session message bus
  • inhibit_id (int) – The ID returned by the inhibit method

pyanaconda.simpleconfig module

class pyanaconda.simpleconfig.SimpleConfigFile(filename=None, read_unquote=True, write_quote=True, always_quote=False)

Bases: object

Edit values in a configuration file without changing comments. Supports KEY=VALUE lines and ignores everything else. Supports adding new keys. Supports deleting keys. Preserves comment, blank lines and comments on KEY lines Does not support duplicate key entries.

get(key)
read(filename=None)

passing filename will override the filename passed to init.

save the lines into self._lines and the key/value pairs into self.info

reset()
set(*args)
unset(*keys)
write(filename=None, use_tmp=True)

passing filename will override the filename passed to init.

pyanaconda.simpleconfig.find_comment(s)

Look for a # comment outside of a quoted string. If there are no quotes, find the last # in the string.

Parameters:s (str) – string to check for comment and quotes
Returns:index of comment or None
Return type:int or None

Handles comments inside quotes and quotes inside quotes.

pyanaconda.simpleconfig.quote(s, always=False)

If always is set it returns a quoted value

pyanaconda.simpleconfig.simple_replace(fname, keys, add=True, add_comment='# Added by Anaconda')

Replace lines in a file, optionally adding if missing.

Parameters:
  • fname (str) – Filename to operate on
  • keys (list) – List of (key, string) tuples to search and replace
  • add (bool) – When True add strings that were not replaced

This will read all the lines in a file, looking for ones that start with keys and replacing the line with the associated string. The string should be a COMPLETE replacement for the line, not just a value.

When add is True any keys that haven’t been found will be appended to the end of the file along with the add_comment.

pyanaconda.simpleconfig.unquote(s)
pyanaconda.simpleconfig.write_tmpfile(filename, data)

pyanaconda.startup_utils module

pyanaconda.startup_utils.get_anaconda_version_string()

Return a string describing current Anaconda version. If the current version can’t be determined the string “unknown” will be returned.

Returns:string describing Anaconda version
Return type:str
pyanaconda.startup_utils.module_exists(module_path)

Report is a given module exists in the current module import pth or not. Supports checking bot modules (“foo”) os submodules (“foo.bar.baz”)

Parameters:module_path (str) – (sub)module identifier
Returns:True if (sub)module exists in path, False if not
Return type:bool

pyanaconda.storage_utils module

pyanaconda.threads module

class pyanaconda.threads.AnacondaThread(*args, **kwargs)

Bases: threading.Thread

A threading.Thread subclass that exists only for a couple purposes:

  1. Make exceptions that happen in a thread invoke our exception handling code as well. Otherwise, threads will silently die and we are doing a lot of complicated code in them now.
  2. Remove themselves from the thread manager when completed.
  3. All created threads are made daemonic, which means anaconda will quit when the main process is killed.
run(*args, **kwargs)
class pyanaconda.threads.ThreadManager

Bases: object

A singleton class for managing threads and processes.

Notes: THE INSTANCE HAS TO BE CREATED IN THE MAIN THREAD!

This manager makes one assumption that contradicts python’s threading module documentation. In this class, we assume that thread names are unique and meaningful. This is an okay assumption for us to make given that anaconda is only ever going to have a handful of special purpose threads.

add(obj)

Given a Thread or Process object, add it to the list of known objects and start it. It is assumed that obj.name is unique and descriptive.

any_errors

Return True of there have been any errors in any threads

exists(name)

Determine if a thread or process exists with the given name.

get(name)

Given an object name, see if it exists and return the object. Return None if no such object exists. Additionally, this method will re-raise any uncaught exception in the thread.

get_error(name)

Get the error data for a thread using its name

in_main_thread()

Return True if it is run in the main thread.

names

Return the names of the running threads.

Returns:list of thread names
Return type:list of strings
raise_if_error(name)

If a thread has failed due to an exception, raise it into the main thread and remove it from errors.

remove(name)

Removes a thread from the list of known objects. This should only be called when a thread exits, or there will be no way to get a handle on it.

running

Return the number of running threads.

Returns:number of running threads
Return type:int
set_error(name, *exc_info)

Set the error data for a thread

The exception data is expected to be the tuple from sys.exc_info()

wait(name)

Wait for the thread to exit and if the thread exited with an error re-raise it here.

wait_all()

Wait for all threads to exit and if there was an error re-raise it.

wait_for_error_threads()

Waits for all threads that caused exceptions. In other words, waits for exception handling (possibly interactive) to be finished.

pyanaconda.threads.initThreading()

Set up threading for anaconda’s use. This method must be called before any GTK or threading code is called, or else threads will only run when an event is triggered in the GTK main loop. And IT HAS TO BE CALLED IN THE MAIN THREAD.

pyanaconda.timezone module

pyanaconda.users module

class pyanaconda.users.Users

Bases: object

checkUserExists(username, root=None)
createGroup(group_name, **kwargs)

Create a new user on the system with the given name. Optional kwargs:

Parameters:
  • gid (int) – The GID for the new user. If none is given, the next available one is used.
  • root (str) – The directory of the system to create the new user in. homedir will be interpreted relative to this. Defaults to iutil.getSysroot().
createUser(user_name, *args, **kwargs)

Create a new user on the system with the given name. Optional kwargs:

Parameters:
  • algo (str) – The password algorithm to use in case isCrypted=True. If none is given, the cryptPassword default is used.
  • gecos (str) – The GECOS information (full name, office, phone, etc.). Defaults to “”.
  • groups (list of str) – A list of group names the user should be added to. Each group name can contain an optional GID in parenthesis, such as “groupName(5000)”. Defaults to [].
  • homedir (str) – The home directory for the new user. Defaults to /home/<name>.
  • isCrypted (bool) – Is the password kwargs already encrypted? Defaults to False.
  • lock (bool) – Is the new account locked by default? Defaults to False.
  • password (str) – The password. See isCrypted for how this is interpreted. If the password is “” then the account is created with a blank password. If None or False the account will be left in its initial state (locked)
  • root (str) – The directory of the system to create the new user in. homedir will be interpreted relative to this. Defaults to iutil.getSysroot().
  • shell (str) – The shell for the new user. If none is given, the login.defs default is used.
  • uid (int) – The UID for the new user. If none is given, the next available one is used.
  • gid (int) – The GID for the new user. If none is given, the next available one is used.
setRootPassword(password, isCrypted=False, isLocked=False, algo=None, root='/')
setUserPassword(username, password, isCrypted, lock, algo=None, root='/')
setUserSshKey(username, key, **kwargs)
pyanaconda.users.cryptPassword(password, algo=None)
pyanaconda.users.getPassAlgo(authconfigStr)

Reads the auth string and returns a string indicating our desired password encoding algorithm.

pyanaconda.users.guess_username(fullname)
pyanaconda.users.validatePassword(pw, user='root', settings=None, minlen=None)

Check the quality of a password.

This function does three things: given a password and an optional username, it will tell if this password can be used at all, how strong the password is on a scale of 1-100, and, if the password is unusable, why it is unusuable.

This function uses libpwquality to check the password strength. pwquality will raise a PWQError on a weak password, which, honestly, is kind of dumb behavior. A weak password isn’t exceptional, it’s what we’re asking about! Anyway, this function does not raise PWQError. If the password fails the PWQSettings conditions, the first member of the return tuple will be False and the second member of the tuple will be 0.

Parameters:
  • pw (string) – the password to check
  • user (string) – the username for which the password is being set. If no username is provided, “root” will be used. Use user=None to disable the username check.
  • settings (pwquality.PWQSettings) – an optional PWQSettings object
  • minlen (int) – Minimum acceptable password length. If not passed, use the default length from PASSWORD_MIN_LEN
Returns:

A tuple containing (bool(valid), int(score), str(message))

Return type:

tuple

pyanaconda.vnc module

Module contents