Package conary :: Package lib :: Module util
[hide private]
[frames] | no frames]

Module util

source code

Classes [hide private]
  popen
Version of popen() that throws errors on close(), unlike os.popen()
  BraceExpander
Class encapsulating the logic required by the brace expander parser
  ObjectCache
Implements a cache of arbitrary (hashable) objects where an object can be looked up and have its cached value retrieved.
  SendableFileSet
  ExtendedFdopen
  ExtendedFile
  ExtendedStringIO
  SeekableNestedFile
  BZ2File
  PushIterator
  PeekIterator
  IterableQueue
  LineReader
  _LazyFile
  LazyFileCache
An object tracking open files.
  Flags
  FileIgnoreEpipe
  BoundedStringIO
An IO object that behaves like a StringIO.
  ProtectedString
A string that is not printed in tracebacks
  ProtectedTemplate
  XMLRPCMarshaller
Marshaller for XMLRPC data
  XMLRPCUnmarshaller
  ServerProxy
  Timer
  LZMAFile
  Tick
Functions [hide private]
 
normpath(path) source code
 
realpath(path) source code
 
isregular(path) source code
 
_mkdirs(path, mode=511)
Recursive helper to mkdirChain.
source code
 
mkdirChain(*paths)
(DEVELOPER API) Make one or more directories if they do not already exist, including any needed parent directories.
source code
 
_searchVisit(arg, dirname, names) source code
 
searchPath(file, basepath) source code
 
searchFile(file, searchdirs, error=None) source code
 
findFile(file, searchdirs) source code
 
which(filename) source code
 
recurseDirectoryList(topdir, withDirs=False)
Recursively list all files in the directory
source code
 
normurl(url) source code
 
genExcepthook(debug=True, debugCtrlC=False, prefix='conary-error-', catchSIGUSR1=True, error='\nERROR: An unexpected condition has occurred in Conary. Thi...)
genExcepthook (DEVELOPER API)
source code
 
_handle_rc(rc, cmd) source code
 
execute(cmd, destDir=None, verbose=True)
similar to os.system, but raises errors if exit code != 0 and closes stdin so processes can never block on user input
source code
 
find(s, subs, start=0) source code
 
literalRegex(s) source code
 
braceExpand(path) source code
 
braceGlob(paths)
(PUBLIC API)
source code
 
rmtree(paths, ignore_errors=False, onerror=None)
rmtree (DEVELOPER API)
source code
 
_permsVisit(arg, dirname, names) source code
 
remove(paths, quiet=False) source code
 
copyfile(sources, dest, verbose=True) source code
 
copyfileobj(source, dest, callback=None, digest=None, abortCheck=None, bufSize=131072, rateLimit=None, sizeLimit=None, total=0) source code
 
rename(sources, dest) source code
 
_copyVisit(arg, dirname, names) source code
 
copytree(sources, dest, symlinks=False, filemode=None, dirmode=None)
Copies tree(s) from sources to dest, returning a list of the filenames that it has written.
source code
 
checkPath(binary, root=None)
Examine $PATH to determine if a binary exists, returns full pathname if it exists; otherwise None.
source code
 
joinPaths(*args) source code
 
splitPathReverse(path)
Split the path at the operating system's separators.
source code
 
splitPath(path)
Split the path at the operating system's separators Empty path components are stripped out Example: 'a//b//c/d' -> ['a', 'b', 'c', 'd']
source code
 
assertIteratorAtEnd(iter) source code
 
memsize(pid=None) source code
 
memusage(pid=None)
Get the memory usage.
source code
 
createLink(src, to) source code
bool
tupleListBsearchInsert(haystack, newItem, cmpFn)
Inserts newItem into haystack, maintaining the sorted order.
source code
 
settempdir(tempdir) source code
 
mkstemp(suffix='', prefix='tmp', dir=None, text=False)
a wrapper for tempfile.mkstemp that uses a common prefix which is set through settempdir()
source code
 
lstat(path)
Return None if the path doesn't exist.
source code
 
_LazyFile_reopen(method)
Decorator to perform the housekeeping of opening/closing of fds
source code
 
stripUserPassFromUrl(url) source code
 
_FileIgnoreEpipe_ignoreEpipe(fn) source code
 
urlSplit(url, defaultPort=None)
A function to split a URL in the format <scheme>://<user>:<pass>@<host>:<port>/<path>;<params>#<fragment> into a tuple (<scheme>, <user>, <pass>, <host>, <port>, <path>, <params>, <fragment>) Any missing pieces (user/pass) will be set to None.
source code
 
urlUnsplit(urlTuple)
Recompose a split URL as returned by urlSplit into a single string
source code
 
xmlrpcGetParser() source code
 
xmlrpcDump(params, methodname=None, methodresponse=None, stream=None, encoding=None, allow_none=False) source code
 
xmlrpcLoad(stream) source code
 
copyStream(src, dest, length=None, bufferSize=16384)
Copy from one stream to another, up to a specified length
source code
 
decompressStream(src, bufferSize=8092) source code
 
compressStream(src, level=5, bufferSize=16384) source code
 
decompressString(s) source code
 
massCloseFileDescriptors(start, unusedCount)
Close all file descriptors starting with start, until we hit unusedCount consecutive file descriptors that were already closed
source code
 
nullifyFileDescriptor(fdesc)
Connects the file descriptor to /dev/null or an open file (if /dev/null does not exist)
source code
None
sendmsg(sock, dataList, fdList=[])
Sends multiple strings and an optional list of file descriptors through a unix domain socket.
source code
tuple
recvmsg(sock, dataSize, fdCount=0)
Receives data and optional file descriptors from a unix domain socket.
source code
 
countOpenFileDescriptors()
Return the number of open file descriptors for this process.
source code
 
convertPackageNameToClassName(pkgname) source code
 
rethrow(newClassOrInstance, prependClassName=True, oldTup=None)
Re-throw an exception, either from sys.exc_info() (the default) or from oldTup (when set).
source code
Variables [hide private]
  errorMessage = '\nERROR: An unexpected condition has occurred ...
  _debugAll = False
  _tempdir = '/tmp'
Function Details [hide private]

_mkdirs(path, mode=511)

source code 
Recursive helper to mkdirChain. Internal use only.

mkdirChain(*paths)

source code 
(DEVELOPER API) Make one or more directories if they do not already exist, including any needed parent directories. Similar to os.makedirs except that it does not error if the requested directory already exists, and it is more resilient to race conditions.
Decorators:
  • @api.developerApi

genExcepthook(debug=True, debugCtrlC=False, prefix='conary-error-', catchSIGUSR1=True, error='\nERROR: An unexpected condition has occurred in Conary. Thi...)

source code 
genExcepthook (DEVELOPER API)
Decorators:
  • @api.developerApi

braceGlob(paths)

source code 
(PUBLIC API)
Decorators:
  • @api.publicApi
Raises:
  • ValueError - raised if paths has unbalanced braces
  • OSError - raised in some cases where lstat on a path fails

rmtree(paths, ignore_errors=False, onerror=None)

source code 
rmtree (DEVELOPER API)
Decorators:
  • @api.developerApi

splitPathReverse(path)

source code 
Split the path at the operating system's separators. Returns a list with the path components in reverse order. Empty path components are stripped out. Example: 'a//b//c/d' -> ['d', 'c', 'b', 'a']

memusage(pid=None)

source code 
Get the memory usage.
Parameters:
  • pid - Process to analyze (None for current process)

tupleListBsearchInsert(haystack, newItem, cmpFn)

source code 
Inserts newItem into haystack, maintaining the sorted order. The cmpIdx is the item number in the list of tuples to base comparisons on. Duplicates items aren't added. Returns True if the item was added, False if it was already present.
Parameters:
  • haystack (list) - list of tuples.
  • newItem (tuple) - The item to be inserted
  • cmpFn (function) - Comparison function
Returns: bool

urlSplit(url, defaultPort=None)

source code 
A function to split a URL in the format <scheme>://<user>:<pass>@<host>:<port>/<path>;<params>#<fragment> into a tuple (<scheme>, <user>, <pass>, <host>, <port>, <path>, <params>, <fragment>) Any missing pieces (user/pass) will be set to None. If the port is missing, it will be set to defaultPort; otherwise, the port should be a numeric value.

sendmsg(sock, dataList, fdList=[])

source code 
Sends multiple strings and an optional list of file descriptors through a unix domain socket.
Parameters:
  • sock (socket) - Unix domain socket to send message through
  • dataList (list of str) - List of strings to send
  • fdList (list of int) - File descriptors to send
Returns: None

recvmsg(sock, dataSize, fdCount=0)

source code 
Receives data and optional file descriptors from a unix domain socket. Returns a (data, fdList) tuple.
Parameters:
  • sock (socket) - Unix domain socket to send message through
  • dataSize (int) - Number of bytes to try to read from the socket.
  • fdCount (int) - Exact number of file descriptors to read from the socket
Returns: tuple

rethrow(newClassOrInstance, prependClassName=True, oldTup=None)

source code 

Re-throw an exception, either from sys.exc_info() (the default) or from oldTup (when set). If newClassOrInstance is a class, the original traceback will be stringified and used as the parameter to the new exception, otherwise it should be an instance which will be thrown as-is. In either case, the original traceback will be preserved. Additionally, if it is a class and prependClassName is True (the default), the resulting exception will after stringification be prepended with the name of the original class.

Note that prependClassName should typically be set to False when re-throwing a re-thrown exception so that the intermediate class is not prepended to a value that already has the original class name in it.
Parameters:
  • newClassOrInstance - Class of the new exception to be thrown, or the exact exception instance to be thrown.
  • prependClassName (bool) - If True, prepend the original class name to the new exception
  • oldTup ((exc_class, exc_value, exc_traceback)) - Exception triple to use instead of the current exception

Variables Details [hide private]

errorMessage

Value:
'''
ERROR: An unexpected condition has occurred in Conary.  This is
most likely due to insufficient handling of erroneous input, but
may be some other bug.  In either case, please report the error at
http://issues.rpath.com/ and attach to the issue the file
%(stackfile)s

Then, for more complete information, please run the following script:
...