utils

Various utility functions, and a utility class.

utils.suppress_keyboard_interrupt_message()

Change settings so that nothing will be printed to the terminal after an uncaught exceptions.KeyboardInterrupt.

utils.jiffies_to_seconds(jiffies)

Convert a number of jiffies to seconds, using the convention that 100 jiffies = 1 second.

Parameters:jiffies – a number of jiffies
Returns:the equivalent number of seconds
utils.seconds_to_ui_time(seconds)

Return a human-readable string representation of the length of a time interval given in seconds.

Parameters:seconds – the length of the time interval in seconds
Returns:a human-readable string representation of the length of

the time interval

utils.get_process_info(pid)

Return information about a process taken from /proc/pid/status, /proc/stat/, and /proc/pid/stat.

Parameters:pid – the process id number
Returns:a dictionary containing information about the process
utils.show_lock_owner(pid, logger)

Output information about another process that is holding the yum lock.

Parameters:
  • pid – the process id number of the process holding the yum lock
  • logger – the logger to output the information to
Returns:

a dictionary containing information about the process. This is the same as the dictionary returned by get_process_info().

YumUtilBase

class utils.YumUtilBase(name, ver, usage)

Bases: cli.YumBaseCli

A class to extend the yum cli for utilities.

doUtilBuildTransaction(unfinished_transactions_check=True)

Build the transaction.

Parameters:unfinished_transactions_check – whether to check if an unfinished transaction has been saved
doUtilConfigSetup(args=['-b', 'html', '-d', '_build/doctrees', '.', '_build/html'], pluginsTypes=(0,))

Parse command line options, and perform configuration.

Parameters:
  • args – list of arguments to use for configuration
  • pluginsTypes – a sequence specifying the types of plugins to load
Returns:

a dictionary containing the values of command line options

doUtilTransaction()

Perform the transaction.

doUtilYumSetup()

Do a default setup for all the normal or necessary yum components; this method is mostly just a used for testing.

exFatal(e)

Output a message stating that a fatal error has occurred.

Parameters:e – the exception
Returns:the exit code
exIOError(e)

Output a message stating that the program is exiting due to an IO exception.

Parameters:e – the IO exception
Returns:the exit code
exPluginExit(e)
Called when a plugin raises
yum.plugins.PluginYumExit. Log the plugin’s exit message if one was supplied.
Parameters:e – the exception
Returns:the exit code
exUserCancel()

Output a message stating that the operation was cancelled by the user.

Returns:the exit code
getOptionGroup()

Return an option group to add non inherited options.

Returns:a optparse.OptionGroup for adding options that are not inherited from YumBaseCli.
getOptionParser()

Return the cli.YumOptionParser for this object.

Returns:the cli.YumOptionParser for this object
unlock()

Release the yum lock.

Returns:the exit code
waitForLock()

Establish the yum lock. If another process is already holding the yum lock, by default this method will keep trying to establish the lock until it is successful. However, if self.conf.exit_on_lock is set to True, it will raise a Errors.YumBaseError.

utils.main()

Table Of Contents

Previous topic

transactiontests

Next topic

yum.Errors

This Page