cli

Command line interface yum class and related.

cli.sigquit(signum, frame)

SIGQUIT handler for the yum cli. This function will print an error message and exit the program.

Parameters:
  • signum – unused
  • frame – unused

CliError

class cli.CliError(args='')

Bases: yum.Errors.YumBaseError

Command line interface related Exception.

YumBaseCli

class cli.YumBaseCli

Bases: yum.YumBase, output.YumOutput

This is the base class for yum cli.

cleanCli(userlist)

Remove data from the yum cache directory. What data is removed depends on the options supplied by the user.

Parameters:userlist

a list of options. The following are valid options:

expire-cache = Eliminate the local data saying when the
  metadata and mirror lists were downloaded for each
  repository.
packages = Eliminate any cached packages
headers = Eliminate the header files, which old versions
  of yum used for dependency resolution
metadata = Eliminate all of the files which yum uses to
  determine the remote availability of packages
dbcache = Eliminate the sqlite cache used for faster
  access to metadata
rpmdb = Eliminate any cached datat from the local rpmdb
plugins = Tell any enabled plugins to eliminate their
  cached data
all = do all of the above
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
deplist(args)

Print out a formatted list of dependencies for a list of packages. This is a cli wrapper method for yum.YumBase.findDeps.

Parameters:args – a list of names or wildcards specifying packages that should have their dependenices printed
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
distroSyncPkgs(userlist)

Upgrade or downgrade packages to match the latest versions available in the enabled repositories.

Parameters:userlist – list of names or wildcards specifying packages to synchronize with the repositories. If the first string in userlist is “full”, packages will also be reinstalled if their checksums do not match the checksums in the repositories. If userlist is an empty list or only contains “full”, every installed package will be synchronized
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
doCommands()
Call the base command, and pass it the extended commands or
arguments.
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
doRepoSetup(thisrepo=None, dosack=1)

Grab the repomd.xml for each enabled and set up the basics of the repository.

Parameters:
  • thisrepo – the repository to set up
  • dosack – whether to get the repo sack
doShell()

Run a shell-like interface for yum commands.

Returns:a tuple containing the shell result number, and the shell result messages
doTransaction()

Take care of package downloading, checking, user confirmation and actually running the transaction.

Returns:a numeric return code, and optionally a list of errors. A negative return code indicates that errors occurred in the pre-transaction checks
downgradePkgs(userlist)

Attempt to take the user specified list of packages or wildcards and downgrade them. If a complete version number if specified, attempt to downgrade them to the specified version

Parameters:userlist – a list of names or wildcards specifying packages to downgrade
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
erasePkgs(userlist)

Take user commands and populate a transaction wrapper with packages to be erased.

Parameters:userlist – a list of names or wildcards specifying packages to erase
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
errorSummary(errstring)

Parse the error string for ‘interesting’ errors which can be grouped, such as disk space issues.

Parameters:errstring – the error string
Returns:a string containing a summary of the errors
getOptionsConfig(args)

Parse command line arguments, and set up self.conf and self.cmds, as well as logger objects in base instance.

Parameters:args – a list of command line arguments
gpgsigcheck(pkgs)

Perform GPG signature verification on the given packages, installing keys if possible.

Parameters:pkgs – a list of package objects to verify the GPG signatures of
Returns:non-zero if execution should stop due to an error
Raises :Will raise YumBaseError if there’s a problem
installGroups(grouplist)

Mark the packages in the given groups for installation.

Parameters:grouplist – a list of names or wildcards specifying groups to be installed
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
installPkgs(userlist)

Attempt to take the user specified list of packages or wildcards and install them, or if they are installed, update them to a newer version. If a complete version number is specified, attempt to upgrade (or downgrade if they have been removed) them to the specified version.

Parameters:userlist – a list of names or wildcards specifying packages to install
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
localInstall(filelist, updateonly=0)

Install or update rpms provided on the file system in a local directory (i.e. not from a repository).

Parameters:filelist – a list of names specifying local rpms
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
parseCommands()

Read self.cmds and parse them out to make sure that the requested base command and argument makes any sense at all. This function will also set self.basecmd and self.extcmds.

provides(args)

Print out a list of packages that provide the given file or feature. This a cli wrapper to the provides methods in the rpmdb and pkgsack.

Parameters:args – the name of a file or feature to search for
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
registerCommand(command)

Register a yumcommands.YumCommand so that it can be called by any of the names returned by its yumcommands.YumCommand.getNames() method.

Parameters:command – the yumcommands.YumCommand to register
reinstallPkgs(userlist)

Attempt to take the user specified list of packages or wildcards and reinstall them.

Parameters:userlist – a list of names or wildcards specifying packages to reinstall
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
removeGroups(grouplist)

Mark the packages in the given groups for removal.

Parameters:grouplist – a list of names or wildcards specifying groups to be removed
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
resolveDepCli(args)

Print information about a package that provides the given dependency. Only one package will be printed per dependency.

Parameters:args – a list of strings specifying dependencies to search for
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
returnGroupInfo(userlist)

Print complete information about the groups that match the given names or wildcards.

Parameters:userlist – a list of names or wildcards specifying the groups to print information about
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
returnGroupLists(userlist)

Print out a list of groups that match the given names or wildcards.

Parameters:extcmds – a list of names or wildcards specifying groups to list
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage        
returnGroupSummary(userlist)

Print a summary of the groups that match the given names or wildcards.

Parameters:userlist – a list of names or wildcards specifying the groups to summarise. If userlist is an empty list, all installed and available packages will be summarised
Returns:(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
returnPkgLists(extcmds, installed_available=False)

Return a yum.misc.GenericHolder object containing lists of package objects that match the given names or wildcards.

Parameters:
  • extcmds – a list of names or wildcards specifying packages to list
  • installed_available – whether the available package list is present as .hidden_available when doing all, available, or installed
Returns:

a yum.misc.GenericHolder instance with the following lists defined:

available = list of packageObjects
installed = list of packageObjects
updates = tuples of packageObjects (updating, installed)
extras = list of packageObjects
obsoletes = tuples of packageObjects (obsoleting, installed)
recent = list of packageObjects

search(args)

Search for simple text tags in a package object. This is a cli wrapper method for the module search function.

Parameters:args – list of names or wildcards to search for. Normally this method will begin by searching the package names and summaries, and will only search urls and descriptions if that fails. However, if the first string in args is “all”, this method will always search everything
Returns:a tuple where the first item is an exit code, and the second item is a generator if the search is a successful, and a list of error messages otherwise

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
shellUsage()

Print out an explanation of the shell usage.

updatePkgs(userlist, quiet=0, update_to=False)

Take user commands and populate transaction wrapper with packages to be updated.

Parameters:
  • userlist – a list of names or wildcards specifying packages to update. If userlist is an empty list, yum will perform a global update
  • quiet – unused
  • update_to – if update_to is True, the update will only be run if it will update the given package to the given version. For example, if the package foo-1-2 is installed, updatePkgs([“foo-1-2], update_to=False) will work identically to updatePkgs([“foo”]), but updatePkgs([“foo-1-2”], update_to=True) will do nothing
Returns:

(exit_code, [ errors ])

exit_code is:

0 = we're done, exit
1 = we've errored, exit with error string
2 = we've got work yet to do, onto the next stage
usage()

Print out an explanation of command line usage.

YumOptionParser

class cli.YumOptionParser(base, **kwargs)

Bases: optparse.OptionParser

Subclass that makes some minor tweaks to make OptionParser do things the “yum way”.

error(msg)

Output an error message, and exit the program. This method is overridden so that error output goes to the logger.

Parameters:msg – the error message to output
firstParse(args)

Parse only command line options that affect basic yum setup.

Parameters:args – a list of command line options to parse
Returns:a dictionary containing the values of command line options
getRoot(opts)

Return the root location to use for the yum operation. This location can be changed by using the –installroot option.

Parameters:opts – a dictionary containing the values of the command line options
Returns:a string representing the root location
setupYumConfig(args=None)

Parse command line options.

Parameters:args – the command line arguments entered by the user
Returns:(opts, cmds) opts is a dictionary containing the values of command line options. cmds is a list of the command line arguments that were not parsed as options. For example, if args is [“install”, “foo”, “–verbose”], cmds will be [“install”, “foo”].

Table Of Contents

Previous topic

callback

Next topic

conf

This Page