Package qb :: Package utils
[hide private]
[frames] | no frames]

Package utils

source code

A package for convenience functions and classes

Submodules [hide private]

Functions [hide private]
 
addToSysPath(path, append=False)
Add a path to the python module search path.
source code
str
getModulePath()
Get the path to the module that called this instance
source code
 
pyVerAsFloat() source code
 
formatExc(limit=5) source code
str
translateQbConvertPathStrings(cmd)
Returns: the cmd with any paths translated as necessary
source code
str
sudoCopy(src, dst)
Attempt to perform an authenticated copy.
source code
str
sudoWrite(data, dst, concat=False)
Attempt to perform a file write that is expected to require authentication.
source code
 
getTimestampedFileName(fName)
Generate a time-stamped backup file name: qb.conf -> qb.20121231_235959.conf
source code
Variables [hide private]
  __package__ = 'qb.utils'
Function Details [hide private]

addToSysPath(path, append=False)

source code 

Add a path to the python module search path.

Parameters:
  • path (str) - The file path to add.
  • append (bool default: False) - Either insert the path at the head of sys.path, or append to the end.

getModulePath()

source code 

Get the path to the module that called this instance

Returns: str
The file path to the backend's class module

translateQbConvertPathStrings(cmd)

source code 
Parameters:
  • cmd (str) - a python command to perform path translation on, according to the worker's worker_path_map. The cmd is scanned for any string wrapped in QB_CONVERT_PATH()
Returns: str
the cmd with any paths translated as necessary

sudoCopy(src, dst)

source code 

Attempt to perform an authenticated copy. An existing destination file will be overwritten.

Prompt for authentication on OS X, otherwise just return an error message on other OS's upon failure.

Parameters:
  • src (str) - copy source file
  • dst - copy destination file
Returns: str
Return an error message; a null-string indicates success

sudoWrite(data, dst, concat=False)

source code 

Attempt to perform a file write that is expected to require authentication.

Parameters:
  • data (str) - data to write to the destination file
  • dst (str) - destination file
  • concat (boolean) - if true, concat the data to the destination, otherwise overwrite destination
Returns: str
Return an error message; a null-string indicates success

getTimestampedFileName(fName)

source code 

Generate a time-stamped backup file name:
    qb.conf -> qb.20121231_235959.conf

@param fName: A file name
@type fName: C{str}

@return: A filename with a timestamp embedded in front of the file extension
@rtype: C{str}