CMS 3D CMS Logo

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__ (self, version='v3', database='run3', 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
 

Static Public Attributes

 databases
 
 dbparams
 

Detailed Description

Definition at line 11 of file confdbOfflineConverter.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 62 of file confdbOfflineConverter.py.

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

Member Function Documentation

◆ CheckTempDirectory()

def confdbOfflineConverter.OfflineConverter.CheckTempDirectory (   dir)
static

Definition at line 52 of file confdbOfflineConverter.py.

52  def CheckTempDirectory(dir):
53  dir = os.path.realpath(dir)
54  if not os.path.isdir(dir):
55  try:
56  os.makedirs(dir)
57  except:
58  return None
59  return dir
60 
61 

◆ query()

def confdbOfflineConverter.OfflineConverter.query (   self,
args 
)

Member Data Documentation

◆ baseDir

confdbOfflineConverter.OfflineConverter.baseDir

Definition at line 65 of file confdbOfflineConverter.py.

◆ baseUrl

confdbOfflineConverter.OfflineConverter.baseUrl

Definition at line 66 of file confdbOfflineConverter.py.

◆ connect

confdbOfflineConverter.OfflineConverter.connect

◆ databases

confdbOfflineConverter.OfflineConverter.databases
static

Definition at line 29 of file confdbOfflineConverter.py.

◆ dbparams

confdbOfflineConverter.OfflineConverter.dbparams
static

Definition at line 47 of file confdbOfflineConverter.py.

◆ jars

confdbOfflineConverter.OfflineConverter.jars

Definition at line 67 of file confdbOfflineConverter.py.

◆ javaCmd

confdbOfflineConverter.OfflineConverter.javaCmd

◆ verbose

confdbOfflineConverter.OfflineConverter.verbose

◆ version

confdbOfflineConverter.OfflineConverter.version

◆ workDir

confdbOfflineConverter.OfflineConverter.workDir

Definition at line 71 of file confdbOfflineConverter.py.

join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
python.cmstools.all
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
contentValuesFiles.query
query
Definition: contentValuesFiles.py:38