本文整理汇总了Python中Configuration.Configuration.getConfigJSON方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.getConfigJSON方法的具体用法?Python Configuration.getConfigJSON怎么用?Python Configuration.getConfigJSON使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.getConfigJSON方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from Configuration import Configuration [as 别名]
# 或者: from Configuration.Configuration import getConfigJSON [as 别名]
def setUp(self):
"""
Check for at least one active Celery worker else skip the
test.
@param self Object reference.
"""
self.__inspection = inspect()
try:
active_nodes = self.__inspection.active()
except Exception: # pylint:disable = W0703
unittest.TestCase.skipTest(self,
"Skip - RabbitMQ seems to be down")
if (active_nodes == None):
unittest.TestCase.skipTest(self,
"Skip - No active Celery workers")
# Get the current MAUS version.
configuration = Configuration()
self.config_doc = configuration.getConfigJSON()
config_dictionary = json.loads(self.config_doc)
self.__version = config_dictionary["maus_version"]
# Reset the worker. Invoke twice in case the first attempt
# fails due to mess left by previous test.
self.reset_worker()
self.reset_worker()
if maus_cpp.globals.has_instance():
maus_cpp.globals.death()
maus_cpp.globals.birth(self.config_doc)
示例2: setUp
# 需要导入模块: from Configuration import Configuration [as 别名]
# 或者: from Configuration.Configuration import getConfigJSON [as 别名]
def setUp(self):
""" Initialiser. setUp is called before each test function is called."""
self._reducer = ReducePyScalers()
conf = Configuration()
config_doc = json.loads(conf.getConfigJSON())
key = 'output_scalers_file_name'
if ( key in config_doc ):
self._output_file_name = config_doc[key]
else:
self._output_file_name = 'scalers.dat'
# Test whether the configuration files were loaded correctly at birth
success = self._reducer.birth(conf.getConfigJSON())
if not success:
raise Exception('InitializeFail', 'Could not start worker')
示例3: test_defaults
# 需要导入模块: from Configuration import Configuration [as 别名]
# 或者: from Configuration.Configuration import getConfigJSON [as 别名]
def test_defaults(self):
"""Check that we load configuration defaults correctly"""
a_config = Configuration()
maus_config = json.loads(a_config.getConfigJSON())
## test setup
maus_root_dir = os.environ.get('MAUS_ROOT_DIR')
self.assertNotEqual(maus_root_dir, None)
config_dict = {}
default_filename = \
'%s/src/common_py/ConfigurationDefaults.py' % maus_root_dir
exec(open(default_filename,'r').read(), globals(), #pylint:disable=W0122
config_dict) #pylint:disable=W0122
# compare; note we are allowed additional entries in maus_config that
# are hard coded (e.g. version number)
exclusions = [
"maus_version", # changed at runtime, tested below
"reconstruction_geometry_filename", # changed at runtime, tested below
"os", # module needed to use environment variables
"__doc__", # docstring from ConfigurationDefaults
]
for key in config_dict.keys():
if key not in exclusions:
self.assertEqual(config_dict[key], maus_config[key])
示例4: InputCppDAQDataTestCase
# 需要导入模块: from Configuration import Configuration [as 别名]
# 或者: from Configuration.Configuration import getConfigJSON [as 别名]
class InputCppDAQDataTestCase(unittest.TestCase): # pylint: disable = R0904
"""Tests for InputCppDAQData"""
@classmethod
def setUpClass(self): # pylint: disable = C0103, C0202
"""Sets a mapper and configuration"""
if not os.environ.get("MAUS_ROOT_DIR"):
raise Exception('InitializeFail', 'MAUS_ROOT_DIR unset!')
# Set our data path & filename
# It would be nicer to test with a smaller data file!
self._datapath = '%s/src/input/InputCppDAQData' % \
os.environ.get("MAUS_ROOT_DIR")
self._datafile = '05466'
self._c = Configuration()
self._mapper = InputCppDAQData()
def test_init(self): # pylint: disable = W0201
"""Check birth with default configuration"""
self._mapper.birth( self._c.getConfigJSON() )
self._mapper.death()
return
@classmethod
def tearDownClass(self): # pylint: disable = C0103,C0202
"""Check that we can death() MapCppTOFDigits"""
pass
示例5: test_new_value
# 需要导入模块: from Configuration import Configuration [as 别名]
# 或者: from Configuration.Configuration import getConfigJSON [as 别名]
def test_new_value(self):
"""Test that we can create a configuration value from an input file"""
string_file = io.StringIO(u"test = 4")
config = Configuration()
value = config.getConfigJSON(string_file)
json_value = json.loads(value)
self.assertEqual(json_value["test"], 4)
示例6: test_overwrite_value
# 需要导入模块: from Configuration import Configuration [as 别名]
# 或者: from Configuration.Configuration import getConfigJSON [as 别名]
def test_overwrite_value(self):
"""Test that we can overwrite configuration value from an input file"""
string_file = io.StringIO\
(u"simulation_geometry_filename = 'Stage4Something.dat'")
conf = Configuration()
value = conf.getConfigJSON(string_file)
json_value = json.loads(value)
self.assertEqual(json_value["simulation_geometry_filename"],
'Stage4Something.dat')
示例7: test_get_cabling
# 需要导入模块: from Configuration import Configuration [as 别名]
# 或者: from Configuration.Configuration import getConfigJSON [as 别名]
def test_get_cabling(self): #pylint: disable = R0201
"""Test we can download cabling for proper device, date, run"""
# load the configuration and get the daq cabling date parameter
config = Configuration()
lconfig = json.loads(config.getConfigJSON())
cablingdate = lconfig['DAQ_cabling_date']
# get cabling for default config date
# check we can get cabling for valid detector
dev = "DAQ"
gdc_.GetCabling().get_cabling_for_date(dev, cablingdate)
# check we can get cabling for valid det and specified date
cablingdate = '2012-05-27 12:00:00.0'
gdc_.GetCabling().get_cabling_for_date(dev, cablingdate)
示例8: test_recon_filename
# 需要导入模块: from Configuration import Configuration [as 别名]
# 或者: from Configuration.Configuration import getConfigJSON [as 别名]
def test_recon_filename(self):
"""Check that the version is defined correctly"""
# default should have them equal if reconstruction_geometry_filename is
# empty string
config = json.loads(Configuration().getConfigJSON())
string_file = io.StringIO\
(u"reconstruction_geometry_filename = ''\n"+\
u"simulation_geometry_filename = 'Test.dat'\n")
self.assertEqual(config['simulation_geometry_filename'],
config['reconstruction_geometry_filename'])
# else should be different
string_file = io.StringIO\
(u"reconstruction_geometry_filename = 'Test.dat'")
conf = Configuration()
value = json.loads(conf.getConfigJSON(string_file))
self.assertEqual(value['reconstruction_geometry_filename'], 'Test.dat')
示例9: __init__
# 需要导入模块: from Configuration import Configuration [as 别名]
# 或者: from Configuration.Configuration import getConfigJSON [as 别名]
def __init__(self):
"""
Initialise the evaluator with math functions and units
"""
self._current_cali = {}
self.reset()
cfg = Configuration()
cfgdoc = cfg.getConfigJSON()
cfgdoc_json = json.loads(cfgdoc)
cdb_url = cfgdoc_json['cdb_download_url'] + 'calibration?wsdl'
self.cdb_server = cdb.Calibration()
self.cdb_server.set_url(cdb_url)
#print 'Server: ', self.cdb_server.get_name(), \
# self.cdb_server.get_version()
try:
cdb.Calibration().get_status()
except CdbPermanentError:
raise CdbPermanentError("CDB error")
示例10: test_get_cabling
# 需要导入模块: from Configuration import Configuration [as 别名]
# 或者: from Configuration.Configuration import getConfigJSON [as 别名]
def test_get_cabling(self):
"""Test we can download cabling for specified detector"""
# load the configuration and get the tof cabling date parameter
config = Configuration()
lconfig = json.loads(config.getConfigJSON())
cablingdate = lconfig['TOF_calib_date_from']
# get cabling for default config date
gtc_ = calibration.get_tof_cabling.GetCabling()
# check we can get cabling for valid detector
dev = "TOF1"
gtc_.get_cabling(dev, cablingdate)
# check we can get cabling for valid det and default date
gtc_.get_cabling(dev, cablingdate)
# check we can get cabling for valid det and specified date
cablingdate = '2012-05-27 12:00:00.0'
gtc_.get_cabling(dev, cablingdate)
# check we can get cabling for valid det and valid run
runnumber = 7417
gtc_.get_cabling_for_run(dev, runnumber)
# check we can get cabling for valid det and run=0
runnumber = 0
gtc_.get_cabling_for_run(dev, runnumber)
# check we raise exception for valid det and invalid run
runnumber = 3
self.assertRaises(Exception, gtc_.get_cabling_for_run, dev, runnumber)
# check we error for invalid detector
dev = "Junk"
self.assertRaises(Exception, gtc_.get_cabling, dev, cablingdate)
# check we error in case of invalid args
dev = "junk"
self.assertRaises(Exception, gtc_.get_cabling, dev, cablingdate)
# check we error in case of no args
dev = ""
self.assertRaises(Exception, gtc_.get_cabling, dev, cablingdate)
示例11: __init__
# 需要导入模块: from Configuration import Configuration [as 别名]
# 或者: from Configuration.Configuration import getConfigJSON [as 别名]
def __init__(self):
"""
Initialise the evaluator with math functions and units
"""
self._current_cabling = {}
self._run_cabling = {}
self.reset()
cfg = Configuration()
cfgdoc = cfg.getConfigJSON()
cfgdoc_json = json.loads(cfgdoc)
cdb_url = cfgdoc_json['cdb_download_url'] + 'cabling?wsdl'
self.cdb_server = cdb.Cabling()
self.tof_devs = {'TOF0', 'TOF1', 'TOF2'}
try:
cdb.Cabling().get_status()
except CdbPermanentError:
raise CdbPermanentError("CDB error") #pylint: disable = E0702
except CdbTemporaryError:
raise CdbTemporaryError("CDB error") #pylint: disable = E0702
self.cdb_server.set_url(cdb_url)