Package qb :: Package utils :: Module files :: Class WorkerConfigFile
[hide private]
[frames] | no frames]

Class WorkerConfigFile

source code



A class to read and write the qbwrk.conf file on the supervisor; this file contains blocks
herein referred to as "stanzas" for each template or host definition.

An example qbwrk.conf that has 3 stanzas looks like:
    [default]
    worker_cpus = 0
    
    [test]:
    worker_description = 'this is a test host'

    [some-host-name] : test
    worker_resources = host.foo=4
    worker_path_map = {
        "/Users/sam" = "S:"
        "/Users/test" = "T:"
    }

@ivar cfg: a dict of dicts to hold all the stanzas
    
    The top-level key is the stanza name, the string that appears between the square brackets.

    For each stanza dict, there will be a key for each parameter in the stanza, as well as the
    following reserved-word keys:
        - inherits: the list of templates that occurs after the ":" in the stanza definition
          line

        - index: the zero-based index which indicates the ordering of the stanzas in the cfgFile

    Any of the *_map type multi-line hash-like values are stored as lists of tuples, since the
    values are always C{src = target}
    

Instance Methods [hide private]
 
__init__(self, cfgFile=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
read(self)
Parse the cfgFile, turn it into a dictionary of dictionaries
source code
 
mergeConfigs(self, newCfg) source code
 
write(self) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  RGX_STANZA_DEF = re.compile(r'^\[([a-zA-Z0-9_\.\[\]-]+)\]\s*:?...
  RGX_BLANK_LINE = re.compile(r'^\s*$')
  RGX_PARAM = re.compile(r'^(\w+)\s*=\s*(.*)#?.*$')
  RGX_MAPPING_PARAM = re.compile(r'^(\w+map)\s*=\s*\{(.*)\}?$')
  RGX_PATH_MAPPING_DEF = re.compile(r'^\s*(.*)\s*=\s*(.*)\s*$')
  RGX_DRIVE_MAPPING_DEF = re.compile(r'^\s*([A-Z]{1}:|.*)\s*$')
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, cfgFile=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • cfgFile (str) - file path to the central worker config file
Overrides: object.__init__

mergeConfigs(self, newCfg)

source code 
Parameters:
  • newCfg (dict) - a dictionary containing all the config file parameters to update, keyed by hostname

Class Variable Details [hide private]

RGX_STANZA_DEF

Value:
re.compile(r'^\[([a-zA-Z0-9_\.\[\]-]+)\]\s*:?\s*([^#]*)#?.*$')