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

Module utils

source code

Classes [hide private]
  PFXSimpleTimer
A convenience class containing some simple timer-type methods
Functions [hide private]
 
addToSysPath(path, insert=False)
Add a path to the python module search path.
source code
bool
getDevBoolean(job)
Work around the various ways that objects get cast to strings in the qube job object.
source code
bool
getJobBoolean(job_attr)
Work around the various ways that objects get cast to strings in the qube job object.
source code
bool
getJobPackageBoolean(val)
Work around the various ways that objects get cast to strings in the qube job object.
source code
str
getModulePath()
Get the path to the module that called this instance
source code
 
getClassFromJobData(data)
Import an abritrary module, and return a class object (not an instance) from that module.
source code
 
pyVerAsFloat() source code
 
formatExc(limit=5) source code
 
flushPrint(msg='', fhList=None) source code
 
bannerPrint(msg='', timeFormat=None, fhList=None)
Print a nicely-formatted message with a timestamp, easily readable in a job's stdout/stderr logs
source code
 
configLogging(level) source code
 
scanConfForPaths(confPath, blockName)
scan a job.conf for a multi-line block the is bound by [...], with the closing bracket at the beginning of a new line.
source code
 
getJobLogPaths(redirectingStdErr=False) source code
 
translateAppPath(cmd, appVersion) source code
Variables [hide private]
  HOSTNAME = 'jburk-15-mbPro'
  RGX_APP_TOKEN = re.compile(r'__([A-Z1-9]+)__')
  __package__ = 'qb.backend'
Function Details [hide private]

addToSysPath(path, insert=False)

source code 

Add a path to the python module search path.

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

getDevBoolean(job)

source code 

Work around the various ways that objects get cast to strings in the qube job object.

Add a package dict to the job if one is not found; this can occur when an empty dict is used as a mock job during unittesting.

Parameters:
  • job (dict or qb.Job) - The job to run
Returns: bool
Return a boolean value of the value the job package's 'dev' key; this can be either a string, int, or NoneType

getJobBoolean(job_attr)

source code 

Work around the various ways that objects get cast to strings in the qube job object.

Add a package dict to the job if one is not found; this can occur when an empty dict is used as a mock job during unittesting.

Parameters:
  • job_attr (str) - The job attribute to check
Returns: bool
Return a boolean value of the value; this can be either a string, int, or NoneType

getJobPackageBoolean(val)

source code 

Work around the various ways that objects get cast to strings in the qube job object.

Parameters:
  • val (str or int or bool) - the val to test for T/F
Returns: bool
Return a boolean value of the value

getModulePath()

source code 

Get the path to the module that called this instance

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

getClassFromJobData(data)

source code 

Import an abritrary module, and return a class object (not an instance) from that module.

Parameters:
  • data (dict) - A dictionary describing the class object, must contain the following keys: libPath, modulePath, className

bannerPrint(msg='', timeFormat=None, fhList=None)

source code 

Print a nicely-formatted message with a timestamp, easily readable in a job's stdout/stderr logs

>>> bannerPrint( 'Finished work' )
================================================================================
 13:05:31        Finished work                                        render023
================================================================================
Parameters:
  • msg (string) - The message to be printed
  • timeFormat (string) - a format string suitable for time.strftime()
  • fhList (list) - A list of file objects to print to. Optionally supports being passed a single file object; eg. 'fhList=sys.stderr'.

scanConfForPaths(confPath, blockName)

source code 

scan a job.conf for a multi-line block the is bound by [...], with the closing bracket at the beginning of a new line.

valid OS names acting as keys in the job.conf are those returned by sys.platform

example:

HFS_PATHS = [ darwin:"/Library/NotFoundHere/Houdini.framework/Versions/0.0.0/Resources" darwin: "/Library/Frameworks/Houdini.framework/Versions/0.0.0/Resources" linux2:"/opt/hfs0.0.0" win32: "C:/Program Files/Side Effect Software/Houdini 0.0.0" ]

return a dictionary, keyed of sys.platform names, values are a list of paths