Package yum :: Module misc
[hide private]
[frames] | no frames]

Module misc

source code

Assorted utility functions for yum.

Classes [hide private]
  Checksums
Generate checksum(s), on given pieces of data.
  AutoFileChecksums
Generate checksum(s), on given file/fileobject.
  GenericHolder
Generic Holder class used to hold other objects of known types It exists purely to be able to do object.somestuff, object.someotherstuff or object[key] and pass object to another function that will understand it
Functions [hide private]
 
share_data(value)
Take a value and use the same value from the store, if the value isn't in the store this one becomes the shared version.
source code
 
unshare_data() source code
 
re_glob(s)
Tests if a string is a shell wildcard.
source code
 
re_filename(s)
Tests if a string could be a filename.
source code
 
re_primary_filename(filename)
Tests if a filename string, can be matched against just primary.
source code
 
re_primary_dirname(dirname)
Tests if a dirname string, can be matched against just primary.
source code
 
re_full_search_needed(s)
Tests if a string needs a full nevra match, instead of just name.
source code
 
re_remote_url(s)
Tests if a string is a "remote" URL, http, https, ftp.
source code
 
unique(s)
Return a list of the elements in s, but without duplicates.
source code
 
checksum(sumtype, file, CHUNK=65536, datasize=None)
takes filename, hand back Checksum of it sumtype = md5 or sha/sha1/sha256/sha512 (note sha == sha1) filename = /path/to/file CHUNK=65536 by default
source code
 
getFileList(path, ext, filelist)
Return all files in path matching ext, store them in filelist, recurse dirs return list object
source code
 
procgpgkey(rawkey)
Convert ASCII armoured GPG key to binary
source code
 
getgpgkeyinfo(rawkey, multiple=False)
Return a dict of info for the given ASCII armoured key text
source code
 
keyIdToRPMVer(keyid)
Convert an integer representing a GPG key ID to the hex version string used by RPM
source code
 
keyInstalled(ts, keyid, timestamp)
Return if the GPG key described by the given keyid and timestamp are installed in the rpmdb.
source code
 
import_key_to_pubring(rawkey, keyid, cachedir=None, gpgdir=None) source code
 
return_keyids_from_pubring(gpgdir) source code
 
valid_detached_sig(sig_file, signed_file, gpghome=None)
takes signature , file that was signed and an optional gpghomedir
source code
 
getCacheDir(tmpdir='/var/tmp', reuse=True)
return a path to a valid and safe cachedir - only used when not running as root or when --tempcache is set
source code
 
sortPkgObj(pkg1, pkg2)
sorts a list of yum package objects by name
source code
 
newestInList(pkgs)
Return the newest in the list of packages.
source code
 
version_tuple_to_string(evrTuple)
Convert a tuple representing a package version to a string.
source code
 
prco_tuple_to_string(prcoTuple)
returns a text string of the prco from the tuple format
source code
 
string_to_prco_tuple(prcoString)
returns a prco tuple (name, flags, (e, v, r)) for a string
source code
 
refineSearchPattern(arg)
Takes a search string from the cli for Search or Provides and cleans it up so it doesn't make us vomit
source code
 
bunzipFile(source, dest)
Extract the bzipped contents of source to dest.
source code
 
get_running_kernel_pkgtup(ts)
This takes the output of uname and figures out the pkgtup of the running kernel (name, arch, epoch, version, release).
source code
 
get_running_kernel_version_release(ts)
This takes the output of uname and figures out the (version, release) tuple for the running kernel.
source code
 
find_unfinished_transactions(yumlibpath='/var/lib/yum')
returns a list of the timestamps from the filenames of the unfinished transactions remaining in the yumlibpath specified.
source code
 
find_ts_remaining(timestamp, yumlibpath='/var/lib/yum')
this function takes the timestamp of the transaction to look at and the path to the yum lib dir (defaults to /var/lib/yum) returns a list of tuples(action, pkgspec) for the unfinished transaction elements.
source code
 
seq_max_split(seq, max_entries)
Given a seq, split into a list of lists of length max_entries each.
source code
 
_ugly_utf8_string_hack(item)
hands back a unicoded string
source code
 
to_xml(item, attrib=False) source code
 
unlink_f(filename)
Call os.unlink, but don't die if the file isn't there.
source code
 
getloginuid()
Get the audit-uid/login-uid, if available.
source code
 
setup_locale(override_codecs=True, override_time=False) source code
 
get_my_lang_code() source code
 
return_running_pids()
return list of running processids, excluding this one
source code
 
get_open_files(pid)
returns files open from this pid
source code
 
get_uuid(savepath)
create, store and return a uuid.
source code
 
decompress(filename)
take a filename and decompress it into the same relative location.
source code
Variables [hide private]
  _available_checksums = set(['md5', 'sha1', 'sha256', 'sha512'])
  _default_checksums = ['sha256']
  _share_data_store = {}
  _share_data_store_u = {}
  _re_compiled_glob_match = None
  _re_compiled_filename_match = None
  _re_compiled_full_match = None
  __package__ = 'yum'
Function Details [hide private]

re_filename(s)

source code 

Tests if a string could be a filename. We still get negated character classes wrong (are they supported), and ranges in character classes.

re_primary_filename(filename)

source code 

Tests if a filename string, can be matched against just primary. Note that this can produce false negatives (but not false positives).

unique(s)

source code 

Return a list of the elements in s, but without duplicates.

For example, unique([1,2,3,1,2,3]) is some permutation of [1,2,3], unique("abcabc") some permutation of ["a", "b", "c"], and unique(([1, 2], [2, 3], [1, 2])) some permutation of [[2, 3], [1, 2]].

For best speed, all sequence elements should be hashable. Then unique() will usually work in linear time.

If not possible, the sequence elements should enjoy a total ordering, and if list(s).sort() doesn't raise TypeError it's assumed that they do enjoy a total ordering. Then unique() will usually work in O(N*log2(N)) time.

If that's not possible either, the sequence elements must support equality-testing. Then unique() will usually work in quadratic time.

getgpgkeyinfo(rawkey, multiple=False)

source code 

Return a dict of info for the given ASCII armoured key text

Returned dict will have the following keys: 'userid', 'keyid', 'timestamp'

Will raise ValueError if there was a problem decoding the key.

keyInstalled(ts, keyid, timestamp)

source code 

Return if the GPG key described by the given keyid and timestamp are installed in the rpmdb.

The keyid and timestamp should both be passed as integers. The ts is an rpm transaction set object

Return values:

  • -1 key is not installed
  • 0 key with matching ID and timestamp is installed
  • 1 key with matching ID is installed but has a older timestamp
  • 2 key with matching ID is installed but has a newer timestamp

No effort is made to handle duplicates. The first matching keyid is used to calculate the return result.

version_tuple_to_string(evrTuple)

source code 

Convert a tuple representing a package version to a string.

Parameters:
  • evrTuple - A 3-tuple of epoch, version, and release.

    Return the string representation of evrTuple.

find_ts_remaining(timestamp, yumlibpath='/var/lib/yum')

source code 

this function takes the timestamp of the transaction to look at and the path to the yum lib dir (defaults to /var/lib/yum) returns a list of tuples(action, pkgspec) for the unfinished transaction elements. Returns an empty list if none.

unlink_f(filename)

source code 

Call os.unlink, but don't die if the file isn't there. This is the main difference between "rm -f" and plain "rm".

getloginuid()

source code 

Get the audit-uid/login-uid, if available. None is returned if there was a problem. Note that no caching is done here.

get_uuid(savepath)

source code 

create, store and return a uuid. If a stored one exists, report that if it cannot be stored, return a random one

decompress(filename)

source code 

take a filename and decompress it into the same relative location. if the file is not compressed just return the file