output

Handle actual output from the cli.

YumTextMeter

class output.YumTextMeter(fo=<open file '<stderr>', mode 'w' at 0x7fd716efa270>)

Bases: urlgrabber.progress.TextMeter

A class to display text progress bar output.

update(amount_read, now=None)

Update the status of the text progress bar

Parameters:
  • amount_read – the amount of data, in bytes, that has been read
  • now – the current time in seconds since the epoch. If now is not given, the output of time.time() will be used.

YumTerm

class output.YumTerm(term_stream=None, color='auto')

A class to provide some terminal “UI” helpers based on curses.

reinit(term_stream=None, color='auto')

Reinitializes the YumTerm.

Parameters:
  • term_stream – the terminal stream that the YumTerm should be initialized to use. If term_stream is not given, sys.stdout is used.
  • color – when to colorize output. Valid values are ‘always’, ‘auto’, and ‘never’. ‘always’ will use ANSI codes to always colorize output, ‘auto’ will decide whether do colorize depending on the terminal, and ‘never’ will never colorize.
sub(haystack, beg, end, needles, escape=None, ignore_case=False)

Search the string haystack for all occurrences of any string in the list needles. Prefix each occurrence with beg, and postfix each occurrence with end, then return the modified string. For example:

>>> yt = YumTerm()
>>> yt.sub('spam and eggs', 'x', 'z', ['and'])
'spam xandz eggs'

This is particularly useful for emphasizing certain words in output: for example, calling sub() with beg = MODE[‘bold’] and end = MODE[‘normal’] will return a string that when printed to the terminal will appear to be haystack with each occurrence of the strings in needles in bold face. Note, however, that the sub_mode(), sub_bold(), sub_fg(), and sub_bg() methods provide convenient ways to access this same emphasizing functionality.

Parameters:
  • haystack – the string to be modified
  • beg – the string to be prefixed onto matches
  • end – the string to be postfixed onto matches
  • needles – a list of strings to add the prefixes and postfixes to
  • escape – a function that accepts a string and returns the same string with problematic characters escaped. By default, re.escape() is used.
  • ignore_case – whether case should be ignored when searching for matches
Returns:

haystack with beg prefixing, and end postfixing, occurrences of the strings in needles

sub_bg(haystack, color, needles, **kwds)

Search the string haystack for all occurrences of any string in the list needles. Prefix each occurrence with self.BG_COLOR[color], and postfix each occurrence with self.MODE[‘normal’], then return the modified string. This will return a string that when printed to the terminal will appear to be haystack with each occurrence of the strings in needles highlighted in the given background color.

Parameters:
  • haystack – the string to be modified
  • color – the background color to set the matches to be in. Valid values are given by self.BG_COLOR.keys().
  • needles – a list of strings to add the prefixes and postfixes to
Returns:

haystack with self.BG_COLOR[color] prefixing, and self.MODE[‘normal’] postfixing, occurrences of the strings in needles

sub_bold(haystack, needles, **kwds)

Search the string haystack for all occurrences of any string in the list needles. Prefix each occurrence with self.MODE[‘bold’], and postfix each occurrence with self.MODE[‘normal’], then return the modified string. This will return a string that when printed to the terminal will appear to be haystack with each occurrence of the strings in needles in bold face.

Parameters:
  • haystack – the string to be modified
  • needles – a list of strings to add the prefixes and postfixes to
Returns:

haystack with self.MODE[‘bold’] prefixing, and self.MODE[‘normal’] postfixing, occurrences of the strings in needles

sub_fg(haystack, color, needles, **kwds)

Search the string haystack for all occurrences of any string in the list needles. Prefix each occurrence with self.FG_COLOR[color], and postfix each occurrence with self.MODE[‘normal’], then return the modified string. This will return a string that when printed to the terminal will appear to be haystack with each occurrence of the strings in needles in the given color.

Parameters:
  • haystack – the string to be modified
  • color – the color to set the matches to be in. Valid values are given by self.FG_COLOR.keys().
  • needles – a list of strings to add the prefixes and postfixes to
Returns:

haystack with self.FG_COLOR[color] prefixing, and self.MODE[‘normal’] postfixing, occurrences of the strings in needles

sub_mode(haystack, mode, needles, **kwds)

Search the string haystack for all occurrences of any string in the list needles. Prefix each occurrence with self.MODE[mode], and postfix each occurrence with self.MODE[‘normal’], then return the modified string. This will return a string that when printed to the terminal will appear to be haystack with each occurrence of the strings in needles in the given mode.

Parameters:
  • haystack – the string to be modified
  • mode – the mode to set the matches to be in. Valid values are given by self.MODE.keys().
  • needles – a list of strings to add the prefixes and postfixes to
Returns:

haystack with self.MODE[mode] prefixing, and self.MODE[‘normal’] postfixing, occurrences of the strings in needles

sub_norm(haystack, beg, needles, **kwds)

Search the string haystack for all occurrences of any string in the list needles. Prefix each occurrence with beg, and postfix each occurrence with self.MODE[‘normal’], then return the modified string. If beg is an ANSI escape code, such as given by self.MODE[‘bold’], this method will return haystack with the formatting given by the code only applied to the strings in needles.

Parameters:
  • haystack – the string to be modified
  • beg – the string to be prefixed onto matches
  • end – the string to be postfixed onto matches
  • needles – a list of strings to add the prefixes and postfixes to
Returns:

haystack with beg prefixing, and self.MODE[‘normal’] postfixing, occurrences of the strings in needles

YumOutput

class output.YumOutput

Main output class for the yum command line.

calcColumns(data, columns=None, remainder_column=0, total_width=None, indent='')

Dynamically calculate the widths of the columns that the fields in data should be placed into for output.

Parameters:
  • data – a list of dictionaries that represent the data to be output. Each dictionary in the list corresponds to a column of output. The keys of the dictionary are the lengths of the items to be output, and the value associated with a key is the number of items of that length.
  • columns – a list containing the minimum amount of space that must be allocated for each row. This can be used to ensure that there is space available in a column if, for example, the actual lengths of the items being output cannot be given in data
  • remainder_column – number of the column to receive a few extra spaces that may remain after other allocation has taken place
  • total_width – the total width of the output. self.term.columns is used by default
  • indent – string that will be prefixed to a line of output to create e.g. an indent
Returns:

a list of the widths of the columns that the fields in data should be placed into for output

depListOutput(results)

Format and output a list of findDeps results

Parameters:results – a list of package dependency information as returned by findDeps
displayPkgsInGroups(group)

Output information about the packages in a given group

Parameters:group – a Group object to output information about
download_callback_total_cb(remote_pkgs, remote_size, download_start_timestamp)

Outputs summary information about the download process.

Parameters:
  • remote_pkgs – a list of package objects that were downloaded
  • remote_size – the total amount of information that was downloaded, in bytes
  • download_start_timestamp – the time when the download process started, in seconds since the epoch
failureReport(errobj)

Perform failure output for failovers from urlgrabber

Parameters:errobjurlgrabber.grabber.CallbackObject containing information about the error
Raises :errobj.exception
fmtColumns(columns, msg=u'', end=u'', text_width=<function utf8_width at 0x17d9398>)

Return a row of data formatted into a string for output. Items can overflow their columns.

Parameters:
  • columns – a list of tuples containing the data to output. Each tuple contains first the item to be output, then the amount of space allocated for the column, and then optionally a type of highlighting for the item
  • msg – a string to begin the line of output with
  • end – a string to end the line of output with
  • text_width – a function to find the width of the items in the columns. This defaults to utf8 but can be changed to len() if you know it’ll be fine
Returns:

a row of data formatted into a string for output

fmtKeyValFill(key, val)

Return a key value pair in the common two column output format.

Parameters:
  • key – the key to be formatted
  • val – the value associated with key
Returns:

the key value pair formatted in two columns for output

fmtSection(name, fill='=')

Format and return a section header. The format of the header is a line with name centred, and fill repeated on either side to fill an entire line on the terminal.

Parameters:
  • name – the name of the section
  • fill – the character to repeat on either side of name to fill an entire line. fill must be a single character.
Returns:

a string formatted to be a section header

format_number(number, SI=0, space=' ')

Return a human-readable metric-like string representation of a number.

Parameters:
  • number – the number to be converted to a human-readable form
  • SI – If is 0, this function will use the convention that 1 kilobyte = 1024 bytes, otherwise, the convention that 1 kilobyte = 1000 bytes will be used
  • space – string that will be placed between the number and the SI prefix
Returns:

a human-readable metric-like string representation of number

static format_time(seconds, use_hours=0)

Return a human-readable string representation of a number of seconds. The string will show seconds, minutes, and optionally hours.

Parameters:
  • seconds – the number of seconds to convert to a human-readable form
  • use_hours – If use_hours is 0, the representation will be in minutes and seconds. Otherwise, it will be in hours, minutes, and seconds
Returns:

a human-readable string representation of seconds

historyAddonInfoCmd(extcmds)

Print addon information about transaction in history.

Parameters:extcmds – list of extra command line arguments
historyInfoCmd(extcmds)

Output information about a transaction in history

Parameters:extcmds – list of extra command line arguments
Returns:(exit_code, [errors])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
historyInfoCmdPkgsAltered(old, pats=[])

Print information about how packages are altered in a transaction.

Parameters:
  • old – the history.YumHistoryTransaction to print information about
  • pats – a list of patterns. Packages that match a patten in pats will be highlighted in the output
historyListCmd(extcmds)

Output a list of information about the history of yum transactions.

Parameters:extcmds – list of extra command line arguments
Returns:(exit_code, [errors])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
historyPackageInfoCmd(extcmds)

Print information about packages in history transactions.

Parameters:extcmds – list of extra command line arguments
historyPackageListCmd(extcmds)

Print a list of information about transactions from history that involve the given package or packages.

Parameters:extcmds – list of extra command line arguments
historySummaryCmd(extcmds)

Print a summary of transactions in history.

Parameters:extcmds – list of extra command line arguments
infoOutput(pkg, highlight=False)

Print information about the given package.

Parameters:
  • pkg – the package to print information about
  • hightlight – highlighting options for the name of the package
interrupt_callback(cbobj)

Handle CTRL-C’s during downloads. If a CTRL-C occurs a URLGrabError will be raised to push the download onto the next mirror. If two CTRL-C’s occur in quick succession then yum will exit.

Parameters:cbobjurlgrabber.grabber.CallbackObject
listPkgs(lst, description, outputType, highlight_na={}, columns=None, highlight_modes={})

Prints information about the given list of packages.

Parameters:
  • lst – a list of packages to print information about
  • description – string describing what the list of packages contains, e.g. ‘Available Packages’
  • outputType

    The type of information to be printed. Current options:

    'list' - simple pkg list
    'info' - similar to rpm -qi output
  • highlight_na – a dictionary containing information about packages that should be highlighted in the output. The dictionary keys are (name, arch) tuples for the package, and the associated values are the package objects themselves.
  • columns – a tuple containing information about how to format the columns of output. The absolute value of each number in the tuple indicates how much space has been allocated for the corresponding column. If the number is negative, the text in the column will be left justified, and if it is positive, the text will be right justified. The columns of output are the package name, version, and repository
  • highlight_modes

    dictionary containing information about to highlight the packages in highlight_na. highlight_modes should contain the following keys:

    'not_in' - highlighting used for packages not in *highlight_na*
    '=' - highlighting used when the package versions are equal
    '<' - highlighting used when the package has a lower version number
    '>' - highlighting used when the package has a higher version number
Returns:

(exit_code, [errors])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
listTransaction()

Return a string representation of the transaction in an easy-to-read format.

matchcallback(po, values, matchfor=None, verbose=None, highlight=None)

Output search/provides type callback matches.

Parameters:
  • po – the package object that matched the search
  • values – the information associated with po that matched the search
  • matchfor – a list of strings to be highlighted in the output
  • verbose – whether to output extra verbose information
  • highlight – highlighting options for the highlighted matches
matchcallback_verbose(po, values, matchfor=None)

Output search/provides type callback matches. This will output more information than matchcallback().

Parameters:
  • po – the package object that matched the search
  • values – the information associated with po that matched the search
  • matchfor – a list of strings to be highlighted in the output
postTransactionOutput()

Returns a human-readable summary of the results of the transaction.

Returns:a string containing a human-readable summary of the results of the transaction
printtime()

Return a string representing the current time in the form:

Mon dd hh:mm:ss
Returns:a string representing the current time
reportDownloadSize(packages, installonly=False)

Report the total download size for a set of packages

Parameters:
  • packages – a list of package objects
  • installonly – whether the transaction consists only of installations
reportRemoveSize(packages)

Report the total size of packages being removed.

Parameters:packages – a list of package objects
setupKeyImportCallbacks()

Set up callbacks to import and confirm gpg public keys.

setupProgessCallbacks()

This function is for API purposes only to protect the typo.

setupProgressCallbacks()

Set up the progress callbacks and various output bars based on debug level.

simpleEnvraList(pkg, ui_overflow=False, indent='', highlight=False, columns=None)

Print a package as a line, with the package itself in envra format so it can be passed to list/install/etc.

Parameters:
  • pkg – the package to be printed
  • ui_overflow – unused
  • indent – string to be prefixed onto the line to provide e.g. an indent
  • highlight – highlighting options for the name of the package
  • colums – tuple containing the space allocated for each column of output. The columns the are the package envra and repository
simpleList(pkg, ui_overflow=False, indent='', highlight=False, columns=None)

Print a package as a line.

Parameters:
  • pkg – the package to be printed
  • ui_overflow – unused
  • indent – string to be prefixed onto the line to provide e.g. an indent
  • highlight – highlighting options for the name of the package
  • colums – tuple containing the space allocated for each column of output. The columns are the package name, version, and repository
simpleProgressBar(current, total, name=None)

Output the current status to the terminal using a simple status bar.

Parameters:
  • current – a number representing the amount of work already done
  • total – a number representing the total amount of work to be done
  • name – a name to label the progress bar with
updatesObsoletesList(uotup, changetype, columns=None)

Print a simple string that explains the relationship between the members of an update or obsoletes tuple.

Parameters:
  • uotup – an update or obsoletes tuple. The first member is the new package, and the second member is the old package
  • changetype – a string indicating what the change between the packages is, e.g. ‘updates’ or ‘obsoletes’
  • columns – a tuple containing information about how to format the columns of output. The absolute value of each number in the tuple indicates how much space has been allocated for the corresponding column. If the number is negative, the text in the column will be left justified, and if it is positive, the text will be right justified. The columns of output are the package name, version, and repository
userconfirm()

Get a yes or no from the user, and default to No

Returns:True if the user selects yes, and False if the user selects no

DepSolveProgressCallBack

class output.DepSolveProgressCallBack(ayum=None)

A class to provide text output callback functions for Dependency Solver callback.

downloadHeader(name)

Output a message stating that the header for the given package is being downloaded.

Parameters:name – the name of the package
end()

Output a message stating that dependency resolution has finished.

format_missing_requires(reqPo, reqTup)

Return an error message stating that a package required to fulfill a dependency is missing.

Parameters:
  • reqPo – the package object that has a dependency that cannot be fulfilled
  • reqTup – the name, flags, and version of the package needed to fulfil the dependency
groupRemoveReq(po, hits)

Output a message stating that the given package will not be removed. This method is used during leaf-only group remove commands to indicate that the package will be kept.

Parameters:
pkgAdded(pkgtup, mode)

Print information about a package being added to the transaction set.

Parameters:
  • pkgtup – tuple containing the package name, arch, version, and repository
  • mode – a short string indicating why the package is being added to the transaction set.

Valid current values for mode are:

i = the package will be installed
u = the package will be an update
e = the package will be erased
r = the package will be reinstalled
d = the package will be a downgrade
o = the package will be obsoleting another package
ud = the package will be updated
od = the package will be obsoleted
procConflict(name, confname)

Print a message stating that two packages in the transaction conflict.

Parameters:
  • name – the name of the first package involved in the conflict
  • confname – the name of the second package involved in the conflict
procConflictPo(po, confname)

Print a message stating that two packages in the transaction conflict.

Parameters:
  • name – the first package object involved in the conflict
  • confname – the second package object involved in the conflict
procReq(name, formatted_req)

Output a message stating that the package formatted_req is being processed as a dependency for the package name.

Parameters:
  • name – the name of the package that formatted_req is a dependency of
  • formatted_req – a string representing the package that is being processed as a dependency of name
procReqPo(po, formatted_req)

Output a message stating that the package formatted_req is being processed as a dependency for the package po.

Parameters:
  • po – the package object that formatted_req is a dependency of
  • formatted_req – a string representing the package that is being processed as a dependency of po
restartLoop()

Output a message stating that dependency resolution is restarting.

start()

Perform setup at the beginning of the dependency solving process.

transactionPopulation()

Output a message stating that the transaction set is being populated.

tscheck()

Output a message stating that a transaction check is beginning.

unresolved(msg)

Output a message stating that there is an unresolved dependency.

Parameters:msg – string giving information about the unresolved

dependency

CacheProgressCallback

class output.CacheProgressCallback

A class to handle text output callbacks during metadata cache updates.

errorlog(level, message)

Output an errorlog message.

Parameters:
  • level – the logging level for the message
  • message – the message
filelog(level, message)

Output a file log message.

Parameters:
  • level – the logging level for the message
  • message – the message
log(level, message)

Output a log message.

Parameters:
  • level – the logging level for the message
  • message – the message
progressbar(current, total, name=None)

Output the current status to the terminal using a progress status bar.

Parameters:
  • current – a number representing the amount of work already done
  • total – a number representing the total amount of work to be done
  • name – a name to label the progress bar with

YumCliRPMCallBack

class output.YumCliRPMCallBack(ayum=None)

Bases: yum.rpmtrans.RPMBaseCallback

A Yum specific callback class for RPM operations.

event(package, action, te_current, te_total, ts_current, ts_total)

Output information about an rpm operation. This may include a text progress bar.

Parameters:
  • package – the package involved in the event
  • action – the type of action that is taking place. Valid values are given by rpmtrans.RPMBaseCallback.action.keys()
  • te_current – a number representing the amount of work already done in the current transaction
  • te_total – a number representing the total amount of work to be done in the current transaction
  • ts_current – the number of the current transaction in transaction set
  • ts_total – the total number of transactions in the transaction set
pkgname_ui(pkgname, ts_states=('e', 'od', 'ud', None))

Return more information on a simple pkgname, if possible.

Parameters:
  • pkgname – the name of the package to find information about
  • ts_states – a tuple containing the states where the package might be found
scriptout(package, msgs)

Print messages originating from a package script.

Parameters:
  • package – unused
  • msgs – the messages coming from the script
output.progressbar(current, total, name=None)

Output the current status to the terminal using a simple text progress bar consisting of 50 # marks.

Parameters:
  • current – a number representing the amount of work already done
  • total – a number representing the total amount of work to be done
  • name – a name to label the progress bar with

Table Of Contents

Previous topic

rstgenerator

Next topic

pygettext

This Page