def testConfig(self): """test read/write of configuration file""" if 'DAS_CONFIG' in os.environ: del os.environ['DAS_CONFIG'] fds = NamedTemporaryFile() os.environ['DAS_CONFIG'] = fds.name dasconfig = das_configfile() write_configparser(dasconfig, True) readdict = deepcopy(das_readconfig()) self.assertEqual(dict, type(readdict))
def testConfig(self): """test read/write of configuration file""" if os.environ.has_key('DAS_CONFIG'): del os.environ['DAS_CONFIG'] fds = NamedTemporaryFile() os.environ['DAS_CONFIG'] = fds.name dasconfig = das_configfile() write_configparser(dasconfig, True) readdict = deepcopy(das_readconfig()) self.assertEqual(types.DictType, type(readdict))
def main(): "Main function" optmgr = ConfigOptionParser() opts, _ = optmgr.get_opt() _ = opts.uinput if opts.uinput else das_configfile() outconfig = opts.output if opts.output else \ os.path.join(os.getcwd(), 'das_cms.cfg') config = ConfigParser.ConfigParser() for option in DAS_OPTIONS: option.write_to_configparser(config, use_default=False) config.write(open(outconfig, 'wb')) print("Created DAS configuration file", outconfig)