CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Public Attributes
confdbOfflineConverter.OfflineConverter Class Reference

Public Member Functions

def __init__ (self, version='v2', database='offline', url=None, verbose=False)
 
def query (self, args)
 

Static Public Member Functions

def CheckTempDirectory (dir)
 

Public Attributes

 baseDir
 
 baseUrl
 
 connect
 
 jars
 
 javaCmd
 
 verbose
 
 version
 
 workDir
 

Detailed Description

Definition at line 10 of file confdbOfflineConverter.py.

Constructor & Destructor Documentation

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

Definition at line 52 of file confdbOfflineConverter.py.

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

Member Function Documentation

def confdbOfflineConverter.OfflineConverter.CheckTempDirectory (   dir)
static

Definition at line 42 of file confdbOfflineConverter.py.

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

Definition at line 118 of file confdbOfflineConverter.py.

References confdbOfflineConverter.OfflineConverter.connect, DDTOBRodAlgo.connect, confdbOfflineConverter.OfflineConverter.javaCmd, join(), VisualizationOptions.verbose, L1TdeStage2EMTF.verbose, L1TStage2uGMTMuon.verbose, DQMGenericTnPClient.verbose, L1TStage2EMTF.verbose, dqmTnP::AbstractFitter.verbose, L1TStage2uGMT.verbose, L1TStage2MuonComp.verbose, L1TStage2RegionalMuonCandComp.verbose, confdbOfflineConverter.OfflineConverter.verbose, ElectronStudy.verbose, L1TStage2OMTF.verbose, MuonMillepedeAlgorithm.verbose, DeviationsFromFileSensor2D.verbose, L1TStage2BMTF.verbose, L1TCaloLayer1RawToDigi.verbose, HIPAlignmentAlgorithm.verbose, o2olib.O2OJobMgr.verbose, L1TStage2uGTCaloLayer2Comp.verbose, OpticalObject.verbose, and L1TdeStage2CaloLayer2.verbose.

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

118  def query(self, *args):
119  args = self.javaCmd + self.connect + args
120  if self.verbose:
121  sys.stderr.write("\n" + ' '.join(args) + "\n\n" )
122  sub = subprocess.Popen(
123  args,
124  stdin = None,
125  stdout = subprocess.PIPE,
126  stderr = subprocess.PIPE,
127  shell = False,
128  universal_newlines = True )
129  return sub.communicate()
130 
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(), o2o_db_cfgmap.DbManagerDAQ.update_hashmap(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController.updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController.updateViewMenu().

confdbOfflineConverter.OfflineConverter.jars

Definition at line 57 of file confdbOfflineConverter.py.

confdbOfflineConverter.OfflineConverter.javaCmd
confdbOfflineConverter.OfflineConverter.verbose
confdbOfflineConverter.OfflineConverter.version
confdbOfflineConverter.OfflineConverter.workDir

Definition at line 58 of file confdbOfflineConverter.py.