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

Source Code for Package qb.frontend

 1  #!/bin/env python 
 2  ''' 
 3  A package for easily defining various Qube front ends 
 4  ''' 
 5  #====================================== 
 6  #  $Revision: #9 $ 
 7  #  $Change: 14750 $ 
 8  #====================================== 
 9   
10  import sys 
11  import os 
12  import logging 
13   
14  try: 
15      import qb 
16  except: 
17      if 'QBDIR' in os.environ: 
18          QBDIR = os.environ['QBDIR'] 
19      else: 
20          if os.name == 'posix': 
21              if os.uname()[0] == 'Darwin': 
22                  QBDIR = '/Applications/pfx/qube' 
23              else: 
24                  QBDIR = '/usr/local/pfx/qube' 
25   
26      sys.path.append('%s/api/python' % QBDIR) 
27      import qb 
28           
29   
30 -class QubeJobError(Exception):
31 '''Base class for all exceptions raised by any of the Qube job frontends'''
32 - def __init__(self, value=''):
33 self.value = value
34 - def __str__(self):
35 return repr(self.value)
36 37
38 -class QubeJob(dict):
39 ''' 40 A base class for the frontend of any Qube job whose backend jobtype uses the qube 41 qb.backend.pythonBackEnd modules 42 '''
43 - def __init__(self, prototype='', dev=False):
44 ''' 45 @param dev: Set the 'dev' value for the Qube job, enables debug output on the farm. 46 @type dev: bool 47 ''' 48 self['prototype'] = prototype 49 self['name'] = '' 50 51 self['package'] = { 52 'dev': dev, 53 'smartAgenda': False, 54 'logParser': { 55 'className': 'LogParser', 56 'modulePath': 'qb.backend.logParser', 57 'libPath': '' 58 }, 59 'regex_errors': 'QubeBackEndError|AppVersionNotFoundError', 60 } 61 62 self['callbacks'] = []
63
64 - def setLogParser(self, className, modulePath='qb.backend.logParser', libPath=''):
65 ''' 66 Define the logParser class to use. 67 68 @param className: the class name of the LogParser to use 69 @type className: C{str} 70 71 @param modulePath: the string would normally be in the "import" line 72 @type modulePath: C{str} 73 74 @libPath: the absolute filepath to be added to PYTHONPATH (sys.path). This is not the file 75 path to the module itself, but only what needs to be added to the sys.path in order for the 76 import command with the modulePath to be effective. In the default case of the modulePath 77 being "qb.logParser", we only wish to add the parent directory of the qb module itself, so 78 that "import qb.logParser" will find and correctly load the required module. 79 80 @type libPath: C{str} 81 82 ''' 83 self['package']['logParser'] = { 84 'className': className, 85 'modulePath': modulePath, 86 'libPath': libPath 87 }
88