def test_addLogLevelOptionToArgs(self): for level_name in Logging.getLogLevels(): parser = argparse.ArgumentParser() with self.assertRaises(exceptions.SystemExit): parser.parse_args(['--log_level', level_name]) Logging.addLogLevelOptionToArgs(parser) with self.assertRaises(exceptions.SystemExit): parser.parse_args(['--log_level']) parser.parse_args(['--log_level', level_name])
def test_exist_getLogLevels(self): bad_level_name = 'blarg' l = logging.getLogger(bad_level_name) with self.assertRaises(ValueError): l.setLevel(bad_level_name) for level_name in Logging.getLogLevels(): l = logging.getLogger(level_name) l.setLevel(level_name)
def test_setupLogging(self): Logging.setupLogging('WARNING', 'testname') self.assertNotEqual(sys.stdout, sys.__stdout__) self.assertNotEqual(sys.stderr, sys.__stderr__)
return False if __name__ == "__main__": # material = 'iron_scint_bars' material = sys.argv[1] name = "range_test_%s" % material run = 0 random.seed() config_class = Configuration.DEFAULT(name, run) Configuration.GLOBAL_CONFIG = config_class.get_configuration_dict() Logging.setupLogging("DEBUG", name) log = logging.getLogger("root").getChild("simulate") # make shorter variable name for us config = config_class.get_configuration_dict() log.info("Using the following configuration:") log.info(config) rand_engine = G4.Ranlux64Engine() HepRandom.setTheEngine(rand_engine) seed = config["seed"] if seed == 0: seed = random.randint(1, 65536) log.warning("Using random seed %d", seed) else:
from gnomon import GeneratorAction from gnomon import TrackingAction from gnomon.DetectorConstruction import VlenfDetectorConstruction from gnomon.Configuration import RUNTIME_CONFIG as rc from gnomon import Logging from scipy.stats import uniform log = None # Logger for this file if __name__ == "__main__": desc = 'Simulate the NuSTORM experiment magnetized iron detectors' parser = argparse.ArgumentParser(description=desc) Logging.addLogLevelOptionToArgs(parser) # adds --log_level Configuration.populate_args(parser) parser.add_argument('--name', '-n', help='DB in CouchDB for output', type=str, required=True) parser.add_argument('--run', '-r', help='run number', type=int, required=True) args = parser.parse_args() config_class = Configuration.DEFAULT(args.name, args.run, overload=vars(args)) Configuration.GLOBAL_CONFIG = config_class.get_configuration_dict() Logging.setupLogging(args.log_level, args.name) log = logging.getLogger('root').getChild('simulate')
return False if __name__ == "__main__": #material = 'iron_scint_bars' material = sys.argv[1] name = 'range_test_%s' % material run = 0 random.seed() config_class = Configuration.DEFAULT(name, run) Configuration.GLOBAL_CONFIG = config_class.get_configuration_dict() Logging.setupLogging('DEBUG', name) log = logging.getLogger('root').getChild('simulate') # make shorter variable name for us config = config_class.get_configuration_dict() log.info('Using the following configuration:') log.info(config) rand_engine = G4.Ranlux64Engine() HepRandom.setTheEngine(rand_engine) seed = config['seed'] if seed == 0: seed = random.randint(1, 65536) log.warning('Using random seed %d', seed) else:
return True return False if __name__ == "__main__": #material = 'iron_scint_bars' material = sys.argv[1] name = 'range_test_%s' % material run = 0 random.seed() config_class = Configuration.DEFAULT(name, run) Configuration.GLOBAL_CONFIG = config_class.get_configuration_dict() Logging.setupLogging('DEBUG', name) log = logging.getLogger('root').getChild('simulate') # make shorter variable name for us config = config_class.get_configuration_dict() log.info('Using the following configuration:') log.info(config) rand_engine = G4.Ranlux64Engine() HepRandom.setTheEngine(rand_engine) seed = config['seed'] if seed == 0: seed = random.randint(1, 65536) log.warning('Using random seed %d', seed) else: