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='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
 

Static Public Attributes

 databases
 

Detailed Description

Definition at line 10 of file confdbOfflineConverter.py.

Constructor & Destructor Documentation

◆ __init__()

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 

Member Function Documentation

◆ CheckTempDirectory()

def confdbOfflineConverter.OfflineConverter.CheckTempDirectory (   dir)
static

Definition at line 42 of file confdbOfflineConverter.py.

42  def CheckTempDirectory(dir):
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 

◆ query()

def confdbOfflineConverter.OfflineConverter.query (   self,
args 
)

Member Data Documentation

◆ baseDir

confdbOfflineConverter.OfflineConverter.baseDir

Definition at line 55 of file confdbOfflineConverter.py.

◆ baseUrl

confdbOfflineConverter.OfflineConverter.baseUrl

Definition at line 56 of file confdbOfflineConverter.py.

◆ connect

confdbOfflineConverter.OfflineConverter.connect

◆ databases

confdbOfflineConverter.OfflineConverter.databases
static

Definition at line 28 of file confdbOfflineConverter.py.

◆ jars

confdbOfflineConverter.OfflineConverter.jars

Definition at line 57 of file confdbOfflineConverter.py.

◆ javaCmd

confdbOfflineConverter.OfflineConverter.javaCmd

◆ verbose

confdbOfflineConverter.OfflineConverter.verbose

◆ version

confdbOfflineConverter.OfflineConverter.version

◆ workDir

confdbOfflineConverter.OfflineConverter.workDir

Definition at line 58 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:26
contentValuesFiles.query
query
Definition: contentValuesFiles.py:38