diff --git a/HLTrigger/Configuration/python/Tools/confdb.py b/HLTrigger/Configuration/python/Tools/confdb.py index efb5e31651f84..62bc7aa87ac60 100755 --- a/HLTrigger/Configuration/python/Tools/confdb.py +++ b/HLTrigger/Configuration/python/Tools/confdb.py @@ -55,7 +55,7 @@ def __init__(self, configuration): # get the configuration from ConfdB from confdbOfflineConverter import OfflineConverter - self.converter = OfflineConverter(database = self.config.menu.db) + self.converter = OfflineConverter(version = self.config.menu.version, database = self.config.menu.database) self.buildPathList() self.buildOptions() self.getRawConfigurationFromDB() @@ -74,10 +74,8 @@ def getRawConfigurationFromDB(self): data, err = self.converter.query( *args ) if 'ERROR' in err or 'Exhausted Resultset' in err or 'CONFIG_NOT_FOUND' in err: - print "%s: error while retriving the HLT menu" % os.path.basename(sys.argv[0]) - print - print err - print + sys.stderr.write("%s: error while retrieving the HLT menu\n\n" % os.path.basename(sys.argv[0])) + sys.stderr.write(err + "\n\n") sys.exit(1) self.data = data @@ -98,10 +96,8 @@ def getPathList(self): data, err = self.converter.query( *args ) if 'ERROR' in err or 'Exhausted Resultset' in err or 'CONFIG_NOT_FOUND' in err: - print "%s: error while retriving the list of paths from the HLT menu" % os.path.basename(sys.argv[0]) - print - print err - print + sys.stderr.write("%s: error while retrieving the list of paths from the HLT menu\n\n" % os.path.basename(sys.argv[0])) + sys.stderr.write(err + "\n\n") sys.exit(1) filter = re.compile(r' *= *cms.(End)?Path.*') paths = [ filter.sub('', line) for line in data.splitlines() if filter.search(line) ] diff --git a/HLTrigger/Configuration/python/Tools/options.py b/HLTrigger/Configuration/python/Tools/options.py index 000aa57c90975..e7fa96aa68f12 100644 --- a/HLTrigger/Configuration/python/Tools/options.py +++ b/HLTrigger/Configuration/python/Tools/options.py @@ -50,28 +50,64 @@ def __init__(self, value): # type used to store a reference to an HLT configuration class ConnectionHLTMenu(object): + valid_versions = 'v1', 'v2' + valid_databases = 'online', 'offline', 'adg' + compatibility = { 'hltdev': ('v1', 'offline'), 'orcoff': ('v2', 'adg') } + def __init__(self, value): - self.value = value - self.db = None - self.name = None - self.run = None + self.version = None + self.database = None + self.name = None + self.run = None - # extract the database and configuration name - if value: - if ':' in self.value: - (db, name) = self.value.split(':') - if db == 'run': - self.db = 'orcoff' - self.run = name - elif db in ('hltdev', 'orcoff'): - self.db = db - self.name = name - else: - raise Exception('Unknown ConfDB database "%s", valid values are "hltdev" (default) and "orcoff")' % db) - else: - self.db = 'hltdev' - self.name = self.value + if not value: + return + if not ':' in value: + # default to 'v1/offline' + self.version = 'v1' + self.database = 'offline' + self.name = value + return + + # extract the version, database and configuration name + tokens = value.split(':') + if len(tokens) != 2: + raise Exception('Invalid HLT menu specification "%s"' % value) + (db, name) = tokens + # check if the menu should be automatically determined based on the run number + if db == 'run': + self.version = 'v1' + self.database = 'adg' + self.run = name + # check for backward compatibility names + elif db in self.compatibility: + self.version, self.database = self.compatibility[db] + self.name = name + else: + if '/' in db: + # extract the version and database + tokens = db.split('/') + if len(tokens) != 2: + raise Exception('Invalid HLT menu specification "%s"' % value) + (v, db) = tokens + if v not in self.valid_versions: + raise Exception('Invalid HLT database version "%s", valid values are "%s"' % (v, '", "'.join(self.valid_versions))) + if db not in self.valid_databases: + raise Exception('Invalid HLT database "%s", valid values are "%s"' % (db, '", "'.join(self.valid_databases))) + self.version = v + self.database = db + self.name = name + else: + # use the default version for the given database + if db not in self.valid_databases: + raise Exception('Invalid HLT database "%s", valid values are "%s"' % (db, '", "'.join(self.valid_databases))) + self.database = db + if db == 'offline' : + self.version = 'v1' + else: + self.version = 'v2' + self.name = name # options marked with a (*) only apply when creating a whole process configuration class HLTProcessOptions(object):