CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes
confdbOfflineConverter.OfflineConverter Class Reference

Public Member Functions

def __init__
 
def query
 

Static Public Member Functions

def CheckTempDirectory
 

Public Attributes

 baseDir
 
 baseUrl
 
 connect
 
 jars
 
 javaCmd
 
 verbose
 
 version
 
 workDir
 

Static Public Attributes

dictionary databases = {}
 

Detailed Description

Definition at line 10 of file confdbOfflineConverter.py.

Constructor & Destructor Documentation

def confdbOfflineConverter.OfflineConverter.__init__ (   self,
  version = 'v1',
  database = 'hltdev',
  url = None,
  verbose = False 
)

Definition at line 52 of file confdbOfflineConverter.py.

52 
53  def __init__(self, version = 'v1', database = 'hltdev', url = None, verbose = False):
54  self.verbose = verbose
55  self.version = version
56  self.baseDir = '/afs/cern.ch/user/c/confdb/www/%s/lib' % version
57  self.baseUrl = 'http://confdb.web.cern.ch/confdb/%s/lib' % version
58  self.jars = ( 'ojdbc6.jar', 'cmssw-evf-confdb-converter.jar' )
59  self.workDir = ''
60 
61  # check the schema version
62  if version not in self.databases:
63  # unsupported database version
64  sys.stderr.write( "ERROR: unsupported database version \"%s\"\n" % version)
65 
66  # check the database
67  if database in self.databases[version]:
68  # load the connection parameters for the given database
69  self.connect = self.databases[version][database]
70  else:
71  # unsupported database
72  sys.stderr.write( "ERROR: unknown database \"%s\" for version \"%s\"\n" % (database, version))
73  sys.exit(1)
74 
75  # check for a custom base URL
76  if url is not None:
77  self.baseUrl = url
78 
79  # try to read the .jar files from AFS, or download them
80  if os.path.isdir(self.baseDir) and all(os.path.isfile(self.baseDir + '/' + jar) for jar in self.jars):
81  # read the .jar fles from AFS
82  self.workDir = self.baseDir
83  else:
84  # try to use $CMSSW_BASE/tmp
85  self.workDir = OfflineConverter.CheckTempDirectory(os.environ['CMSSW_BASE'] + '/tmp/confdb')
86  if not self.workDir:
87  # try to use $TMP
88  self.workDir = OfflineConverter.CheckTempDirectory(os.environ['TMP'] + '/confdb')
89  if not self.workDir:
90  # create a new temporary directory, and install a cleanup callback
91  self.workDir = tempfile.mkdtemp()
92  atexit.register(shutil.rmtree, self.workDir)
93  # download the .jar files
94  for jar in self.jars:
95  # check if the file is already present
96  if os.path.exists(self.workDir + '/' + jar):
97  continue
98  # download to a temporay name and use an atomic rename (in case an other istance is downloading the same file
99  handle, temp = tempfile.mkstemp(dir = self.workDir, prefix = jar + '.')
100  os.close(handle)
101  urllib.urlretrieve(self.baseUrl + '/' + jar, temp)
102  if not os.path.exists(self.workDir + '/' + jar):
103  os.rename(temp, self.workDir + '/' + jar)
104  else:
105  os.unlink(temp)
106 
107  # setup the java command line and CLASSPATH
108  if self.verbose:
109  sys.stderr.write("workDir = %s\n" % self.workDir)
110  # use non-blocking random number source /dev/urandom (instead of /dev/random), see:
111  # http://blockdump.blogspot.fr/2012/07/connection-problems-inbound-connection.html
112  # deal with timezone region not found
113  # http://stackoverflow.com/questions/9156379/ora-01882-timezone-region-not-found
114  # increase the thread stack size from the default of 1 MB to work around java.lang.StackOverflowError errors, see
115  # man java
116  self.javaCmd = ( 'java', '-cp', ':'.join(self.workDir + '/' + jar for jar in self.jars), '-Djava.security.egd=file:///dev/urandom', '-Doracle.jdbc.timezoneAsRegion=false', '-Xss32M', 'confdb.converter.BrowserConverter' )
117 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18

Member Function Documentation

def confdbOfflineConverter.OfflineConverter.CheckTempDirectory (   dir)
static

Definition at line 42 of file confdbOfflineConverter.py.

42 
43  def CheckTempDirectory(dir):
44  dir = os.path.realpath(dir)
45  if not os.path.isdir(dir):
46  try:
47  os.makedirs(dir)
48  except:
49  return None
50  return dir
51 
def confdbOfflineConverter.OfflineConverter.query (   self,
  args 
)

Definition at line 118 of file confdbOfflineConverter.py.

References DTDQMHarvesting.DTDQMHarvesting.connect, DTVDriftMeanTimerCalibration.DTVDriftMeanTimerCalibration.connect, DTVDriftSegmentCalibration.DTVDriftSegmentCalibration.connect, DTNoiseCalibration.DTNoiseCalibration.connect, DTDQMValidation.DTDQMValidation.connect, DTAnalysisResiduals.DTAnalysisResiduals.connect, DTResidualCalibration.DTResidualCalibration.connect, DTTTrigProd.DTTTrigProd.connect, DTTTrigValid.DTTTrigValid.connect, DTTTrigResidualCorr.DTTTrigResidualCorr.connect, confdbOfflineConverter.OfflineConverter.connect, DDTOBRodAlgo.connect, confdbOfflineConverter.OfflineConverter.javaCmd, join(), CalibratedPatElectronProducer.verbose, DQMGenericTnPClient.verbose, dqmTnP::AbstractFitter.verbose, CalibratedElectronProducer.verbose, confdbOfflineConverter.OfflineConverter.verbose, ElectronStudy.verbose, MuonMillepedeAlgorithm.verbose, L1TStage2mGMT.verbose, L1TStage2BMTF.verbose, DeviationsFromFileSensor2D.verbose, HIPAlignmentAlgorithm.verbose, L1TCaloLayer1RawToDigi.verbose, and OpticalObject.verbose.

Referenced by production_tasks.BaseDataset.run(), and edmIntegrityCheck.IntegrityCheck.test().

119  def query(self, *args):
120  args = self.javaCmd + self.connect + args
121  if self.verbose:
122  sys.stderr.write("\n" + ' '.join(args) + "\n\n" )
123  sub = subprocess.Popen(
124  args,
125  stdin = None,
126  stdout = subprocess.PIPE,
127  stderr = subprocess.PIPE,
128  shell = False,
129  universal_newlines = True )
130  return sub.communicate()
static std::string join(char **cmd)
Definition: RemoteFile.cc:18

Member Data Documentation

confdbOfflineConverter.OfflineConverter.baseDir

Definition at line 55 of file confdbOfflineConverter.py.

confdbOfflineConverter.OfflineConverter.baseUrl

Definition at line 56 of file confdbOfflineConverter.py.

confdbOfflineConverter.OfflineConverter.connect

Definition at line 68 of file confdbOfflineConverter.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(), confdbOfflineConverter.OfflineConverter.query(), 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(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController.updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController.updateViewMenu().

dictionary confdbOfflineConverter.OfflineConverter.databases = {}
static

Definition at line 28 of file confdbOfflineConverter.py.

confdbOfflineConverter.OfflineConverter.jars

Definition at line 57 of file confdbOfflineConverter.py.

confdbOfflineConverter.OfflineConverter.javaCmd

Definition at line 115 of file confdbOfflineConverter.py.

Referenced by confdbOfflineConverter.OfflineConverter.query().

confdbOfflineConverter.OfflineConverter.verbose

Definition at line 53 of file confdbOfflineConverter.py.

Referenced by python.diff_provenance.difference.list_diff(), python.diffProv.difference.list_diff(), python.diff_provenance.difference.module_diff(), python.diffProv.difference.module_diff(), python.diff_provenance.difference.onefilemodules(), python.diffProv.difference.onefilemodules(), core.TriggerMatchAnalyzer.TriggerMatchAnalyzer.process(), objects.VertexAnalyzer.VertexAnalyzer.process(), and confdbOfflineConverter.OfflineConverter.query().

confdbOfflineConverter.OfflineConverter.version

Definition at line 54 of file confdbOfflineConverter.py.

Referenced by python.rootplot.argparse._VersionAction.__call__(), validation.Sample.datasetpattern(), validation.Sample.filename(), argparse.ArgumentParser.format_version(), and python.rootplot.argparse.ArgumentParser.format_version().

confdbOfflineConverter.OfflineConverter.workDir

Definition at line 58 of file confdbOfflineConverter.py.