CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
o2olib.O2OJobMgr Class Reference
Inheritance diagram for o2olib.O2OJobMgr:
o2olib.O2OMgr

Public Member Functions

def __init__ (self)
 
def add (self, job_name, config_filename, int_val, en_flag)
 
def connect (self, service, args)
 
def dumpConfig (self, jname, versionIndex, configFile)
 
def listConfig (self, jname)
 
def listJobs (self)
 
def migrateConfig (self)
 
def readConfiguration (self, config_filename)
 
def runManager (self)
 
def set (self, job_name, en_flag)
 
def setConfig (self, job_name, config_filename)
 
def setInterval (self, job_name, int_val)
 
- Public Member Functions inherited from o2olib.O2OMgr
def __init__ (self)
 
def getSession (self, db_service, auth)
 
def logger (self)
 

Public Attributes

 conf_dict
 
 db_connection
 
 session
 
 verbose
 
- Public Attributes inherited from o2olib.O2OMgr
 eng
 
 logger
 

Detailed Description

Definition at line 139 of file o2olib.py.

Constructor & Destructor Documentation

def o2olib.O2OJobMgr.__init__ (   self)

Definition at line 141 of file o2olib.py.

141  def __init__( self ):
142  O2OMgr.__init__(self)
143  self.db_connection = None
144  self.conf_dict = {}
145 
146 
def __init__(self)
Definition: o2olib.py:141

Member Function Documentation

def o2olib.O2OJobMgr.add (   self,
  job_name,
  config_filename,
  int_val,
  en_flag 
)

Definition at line 175 of file o2olib.py.

References relativeConstraints.error, info(), and o2olib.O2OJobMgr.readConfiguration().

Referenced by counter.Counter.register(), SequenceTypes.Task.remove(), and SequenceTypes.Task.replace().

175  def add( self, job_name, config_filename, int_val, en_flag ):
176  res = self.session.query(O2OJob.enabled).filter_by(name=job_name)
177  enabled = None
178  for r in res:
179  enabled = r
180  if enabled:
181  O2OMgr.logger( self).error( "A job called '%s' exists already.", job_name )
182  return False
183  configJson = self.readConfiguration( config_filename )
184  if configJson == '':
185  return False
186  job = O2OJob(name=job_name,tag_name='-',enabled=en_flag,interval=int_val)
187  config = O2OJobConf( job_name=job_name, insertion_time = datetime.now(), configuration = configJson )
188  self.session.add(job)
189  self.session.add(config)
190  self.session.commit()
191  O2OMgr.logger( self).info( "New o2o job '%s' created.", job_name )
192  return True
193 
static const TGPicture * info(bool iBackgroundIsBlack)
def add(self, job_name, config_filename, int_val, en_flag)
Definition: o2olib.py:175
def readConfiguration(self, config_filename)
Definition: o2olib.py:147
def o2olib.O2OJobMgr.connect (   self,
  service,
  args 
)

Definition at line 163 of file o2olib.py.

Referenced by Vispa.Gui.ZoomableScrollArea.ZoomableScrollArea.__init__(), Vispa.Views.PropertyView.BooleanProperty.__init__(), Vispa.Gui.FindDialog.FindDialog._addScript(), Vispa.Gui.FindDialog.FindDialog._addStringProperty(), Vispa.Main.Application.Application._connectSignals(), Vispa.Plugins.ConfigEditor.CodeTableView.CodeTableView._createItem(), Vispa.Gui.BoxContentDialog.BoxContentDialog.addButton(), Vispa.Gui.ToolBoxContainer.ToolBoxContainer.addWidget(), Vispa.Views.PropertyView.PropertyView.append(), Vispa.Views.PropertyView.PropertyView.appendAddRow(), Vispa.Main.Application.Application.createAction(), Vispa.Views.PropertyView.TextEditWithButtonProperty.createButton(), Vispa.Views.LineDecayView.LineDecayView.createLineDecayContainer(), Vispa.Views.PropertyView.TextEditWithButtonProperty.createLineEdit(), Vispa.Views.LineDecayView.LineDecayContainer.createObject(), Vispa.Views.PropertyView.TextEditWithButtonProperty.createTextEdit(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController.filterDialog(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController.find(), Vispa.Gui.PortWidget.PortWidget.mouseMoveEvent(), Vispa.Views.PropertyView.BooleanProperty.setChecked(), Vispa.Main.SplitterTab.SplitterTab.setController(), Vispa.Plugins.Browser.BrowserTab.BrowserTab.setController(), Vispa.Views.PropertyView.BooleanProperty.setReadOnly(), Vispa.Views.PropertyView.DropDownProperty.setReadOnly(), Vispa.Views.PropertyView.TextEditWithButtonProperty.setReadOnly(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController.setTab(), Vispa.Views.PropertyView.IntegerProperty.setValue(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController.switchCenterView(), o2o_db_cfgmap.DbManagerDAQ.update_hashmap(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController.updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController.updateViewMenu().

163  def connect( self, service, args ):
164  self.session = O2OMgr.getSession( self,service, args.auth )
165  self.verbose = args.verbose
166  if self.session is None:
167  return False
168  else:
169  self.db_connection = coral_tpl %(service[0],schema_name)
170  self.conf_dict['db']=self.db_connection
171  return True
def connect(self, service, args)
Definition: o2olib.py:163
def o2olib.O2OJobMgr.dumpConfig (   self,
  jname,
  versionIndex,
  configFile 
)

Definition at line 296 of file o2olib.py.

References relativeConstraints.error, createfilelist.int, edm.print(), and str.

Referenced by Types.SecSource.configValue().

296  def dumpConfig( self, jname, versionIndex, configFile ):
297  versionIndex = int(versionIndex)
298  res = self.session.query(O2OJob.enabled).filter_by(name=jname)
299  enabled = None
300  for r in res:
301  enabled = r
302  if enabled is None:
303  O2OMgr.logger( self).error( "A job called '%s' does not exist.", jname )
304  return
305  res = self.session.query( O2OJobConf.configuration, O2OJobConf.insertion_time ).filter_by(job_name=jname).order_by(O2OJobConf.insertion_time)
306  configs = []
307  for r in res:
308  configs.append((str(r[0]),r[1]))
309  ind = len(configs)
310  if versionIndex>ind or versionIndex==0:
311  O2OMgr.logger( self ).error("Configuration for job %s with index %s has not been found." %(jname,versionIndex))
312  return
313  print("Configuration #%2d for job '%s'" %(versionIndex,jname))
314  config = configs[versionIndex-1]
315  print('#%2d since %s' %(versionIndex,config[1]))
316  print(config[0])
317  if configFile is None or configFile == '':
318  configFile = '%s_%s.json' %(jname,versionIndex)
319  with open(configFile,'w') as json_file:
320  json_file.write(config[0])
321 
322 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
def dumpConfig(self, jname, versionIndex, configFile)
Definition: o2olib.py:296
#define str(s)
def o2olib.O2OJobMgr.listConfig (   self,
  jname 
)

Definition at line 274 of file o2olib.py.

References relativeConstraints.error, info(), edm.print(), and str.

274  def listConfig( self, jname ):
275  res = self.session.query(O2OJob.enabled).filter_by(name=jname)
276  enabled = None
277  for r in res:
278  enabled = r
279  if enabled is None:
280  O2OMgr.logger( self).error( "A job called '%s' does not exist.", jname )
281  return
282  res = self.session.query( O2OJobConf.configuration, O2OJobConf.insertion_time ).filter_by(job_name=jname).order_by(O2OJobConf.insertion_time)
283  configs = []
284  for r in res:
285  configs.append((str(r[0]),r[1]))
286  ind = len(configs)
287  if ind:
288  print("Configurations for job '%s'" %jname)
289  for cf in reversed(configs):
290  print('#%2d since: %s' %(ind,cf[1]))
291  print(cf[0])
292  ind -= 1
293  else:
294  O2OMgr.logger( self ).info("No configuration found for job '%s'" %jname )
295 
static const TGPicture * info(bool iBackgroundIsBlack)
def listConfig(self, jname)
Definition: o2olib.py:274
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
#define str(s)
def o2olib.O2OJobMgr.listJobs (   self)

Definition at line 253 of file o2olib.py.

References Vispa.Plugins.EdmBrowser.EdmDataAccessor.all(), o2olib.print_table(), and str.

Referenced by o2olib.O2OTool.execute().

253  def listJobs( self ):
254  runs = {}
255  res = self.session.query(O2ORun.job_name,sqlalchemy.func.max(O2ORun.start_time)).group_by(O2ORun.job_name).order_by(O2ORun.job_name)
256  for r in res:
257  runs[r[0]] = str(r[1])
258  res = self.session.query(O2OJob.name, O2OJob.interval, O2OJob.enabled).order_by(O2OJob.name).all()
259  table = []
260  for r in res:
261  row = []
262  row.append(r[0]),
263  row.append('%5d' %r[1] )
264  enabled = 'Y' if (r[2]==1) else 'N'
265  row.append('%4s' %enabled )
266  lastRun = '-'
267  if r[0] in runs.keys():
268  lastRun = runs[r[0]]
269  row.append( lastRun )
270  table.append(row)
271  headers = ['Job name','Interval','Enabled','Last run start']
272  print_table( headers, table )
273 
def listJobs(self)
Definition: o2olib.py:253
def print_table(headers, table)
Definition: o2olib.py:69
#define str(s)
def o2olib.O2OJobMgr.migrateConfig (   self)

Definition at line 239 of file o2olib.py.

References info().

239  def migrateConfig( self ):
240  res = self.session.query(O2OJob.name,O2OJob.tag_name)
241  for r in res:
242  job_name = r[0]
243  tag = r[1]
244  if tag != '-':
245  configDict = {}
246  configDict['tag']=tag
247  configJson = json.dumps( configDict )
248  config = O2OJobConf( job_name=job_name, insertion_time = datetime.now(), configuration = configJson )
249  self.session.add(config)
250  O2OMgr.logger( self).info( "Configuration for job '%s' inserted.", job_name )
251  self.session.commit()
252 
static const TGPicture * info(bool iBackgroundIsBlack)
def migrateConfig(self)
Definition: o2olib.py:239
def o2olib.O2OJobMgr.readConfiguration (   self,
  config_filename 
)

Definition at line 147 of file o2olib.py.

References relativeConstraints.error.

Referenced by o2olib.O2OJobMgr.add(), and o2olib.O2OJobMgr.setConfig().

147  def readConfiguration( self, config_filename ):
148  config = ''
149  try:
150  with open( config_filename, 'r' ) as config_file:
151  config = config_file.read()
152  if config == '':
153  O2OMgr.logger( self).error( 'The file %s contains an empty string.', config_filename )
154  else:
155  json.loads(config)
156  except IOError as e:
157  O2OMgr.logger( self).error( 'The file %s cannot be open.', config_filename )
158  except ValueError as e:
159  config = ''
160  O2OMgr.logger( self).error( 'The file %s contains an invalid json string.', config_filename )
161  return config
162 
def readConfiguration(self, config_filename)
Definition: o2olib.py:147
def o2olib.O2OJobMgr.runManager (   self)

Definition at line 172 of file o2olib.py.

References o2olib.O2OJobMgr.db_connection, querying.connection.session, and o2olib.O2OJobMgr.session.

172  def runManager( self ):
173  return O2ORunMgr( self.db_connection, self.session, O2OMgr.logger( self ) )
174 
def runManager(self)
Definition: o2olib.py:172
def o2olib.O2OJobMgr.set (   self,
  job_name,
  en_flag 
)

Definition at line 194 of file o2olib.py.

References relativeConstraints.error, and info().

194  def set( self, job_name, en_flag ):
195  res = self.session.query(O2OJob.enabled).filter_by(name=job_name)
196  enabled = None
197  for r in res:
198  enabled = r
199  if enabled is None:
200  O2OMgr.logger( self).error( "A job called '%s' does not exist.", job_name )
201  return
202  job = O2OJob(name=job_name,enabled=en_flag)
203  action = 'enabled'
204  if not en_flag:
205  action = 'disabled'
206  self.session.merge(job)
207  self.session.commit()
208  O2OMgr.logger( self).info( "Job '%s' %s." %(job_name,action) )
209 
static const TGPicture * info(bool iBackgroundIsBlack)
def set(self, job_name, en_flag)
Definition: o2olib.py:194
def o2olib.O2OJobMgr.setConfig (   self,
  job_name,
  config_filename 
)

Definition at line 210 of file o2olib.py.

References relativeConstraints.error, info(), and o2olib.O2OJobMgr.readConfiguration().

Referenced by o2olib.O2OTool.execute().

210  def setConfig( self, job_name, config_filename ):
211  res = self.session.query(O2OJob.enabled).filter_by(name=job_name)
212  enabled = None
213  for r in res:
214  enabled = r
215  if enabled is None:
216  O2OMgr.logger( self).error( "A job called '%s' does not exist.", job_name )
217  return
218  configJson = self.readConfiguration( config_filename )
219  if configJson == '':
220  return False
221  config = O2OJobConf( job_name=job_name, insertion_time = datetime.now(), configuration = configJson )
222  self.session.add(config)
223  self.session.commit()
224  O2OMgr.logger( self).info( "New configuration inserted for job '%s'", job_name )
225 
static const TGPicture * info(bool iBackgroundIsBlack)
def setConfig(self, job_name, config_filename)
Definition: o2olib.py:210
def readConfiguration(self, config_filename)
Definition: o2olib.py:147
def o2olib.O2OJobMgr.setInterval (   self,
  job_name,
  int_val 
)

Definition at line 226 of file o2olib.py.

References relativeConstraints.error, and info().

Referenced by o2olib.O2OTool.execute().

226  def setInterval( self, job_name, int_val ):
227  res = self.session.query(O2OJob.enabled).filter_by(name=job_name)
228  enabled = None
229  for r in res:
230  enabled = r
231  if enabled is None:
232  O2OMgr.logger( self).error( "A job called '%s' does not exist.", job_name )
233  return
234  job = O2OJob(name=job_name,interval=int_val)
235  self.session.merge(job)
236  self.session.commit()
237  O2OMgr.logger( self).info( "The execution interval for job '%s' has been updated.", job_name )
238 
static const TGPicture * info(bool iBackgroundIsBlack)
def setInterval(self, job_name, int_val)
Definition: o2olib.py:226

Member Data Documentation

o2olib.O2OJobMgr.conf_dict

Definition at line 144 of file o2olib.py.

Referenced by o2olib.O2ORunMgr.executeJob().

o2olib.O2OJobMgr.db_connection

Definition at line 143 of file o2olib.py.

Referenced by o2olib.O2OJobMgr.runManager().

o2olib.O2OJobMgr.session

Definition at line 164 of file o2olib.py.

Referenced by o2olib.O2OJobMgr.runManager().

o2olib.O2OJobMgr.verbose