def __init__(self): self.stock_list = ConfigManager.instance().get_stock_list() self.stock_type = ConfigManager.instance().get_stock_type() self.query_all = ConfigManager.instance().get_query_all() self.query = StockQuery() self.stock_info = {} self.result_dir = os.path.join(os.path.dirname(sys.path[0]), 'Result')
def test_load_args(self): cfg = ConfigManager(config_parms) cfg.set_configfile(test_config_file) self.assertEqual(str(cfg), """[dbparms] host = localhost db = rf2 charset = utf8""")
def test_load_args(self): cfg = ConfigManager(config_parms) cfg.set_configfile(test_config_file) self.assertEqual( str(cfg), """[dbparms] host = localhost db = rf2 charset = utf8""")
def test_load_multi_args2(self): cfg1 = ConfigManager(config_parms) cfg1.set_configfile(test_config_file) cfg2 = ConfigManager(config_parms_2) self.assertEqual(str(cfg1), """[dbparms] host = localhost db = rf2 charset = utf8""") self.assertEqual(str(cfg2), """[otherstuff] db = somewhere""")
def test_load_multi_args2(self): cfg1 = ConfigManager(config_parms) cfg1.set_configfile(test_config_file) cfg2 = ConfigManager(config_parms_2) self.assertEqual( str(cfg1), """[dbparms] host = localhost db = rf2 charset = utf8""") self.assertEqual(str(cfg2), """[otherstuff] db = somewhere""")
def test_set_parm(self): cfg = ConfigManager(config_parms) parser = argparse.ArgumentParser() config_parms.add_to_parser(parser, current=cfg) parser.add_argument('-show', dest='show', action="store_true", help="show current configuration") parser.add_argument('-upd', dest='update', action="store_true", help="update configuration file") parser.add_argument('--create', action="store_true", help="create database if it doesn't exist") parser.add_argument('--configfile', help="configuration file location (default: %s)" % test_config_file, default=test_config_file) opts = parser.parse_args("-db rf2test --host localhost --port 8091 -u root -p rootpw".split()) cfg.update(vars(opts)) cfg.set_configfile(test_config_file) self.assertEqual(str(cfg),"""[dbparms] host = localhost db = rf2test charset = utf8 ss = True port = 8091 user = root passwd = rootpw""") cfg.flush() cfg = ConfigManager(config_parms) self.assertEqual(str(cfg),"""[dbparms] host = localhost db = rf2test charset = utf8 ss = True port = 8091 user = root passwd = rootpw""")
def setConfig(): base = os.path.join(os.path.dirname(__file__), '..', '..') # Set ourselves up on the include path automatically sys.path.append(base) # Add the RF2DB services onto the path sys.path.append(os.path.join(base, '..', 'rf2db')) sys.path.append(os.path.join(base, '..', 'ihtsdoauth')) sys.path.append(os.path.join(base, '..', 'ConfigManager')) sys.path.append(os.path.join(base, '..', 'pyjxslt')) from ConfigManager.ConfigManager import ConfigManager ConfigManager.set_configfile(os.path.join(base, 'settings.conf')) return base
def __init__(self): self.url = '' self.req = None self.resp = None self.content = '' self.stock_info = {} self.api_key = ConfigManager.instance().get_api_key()
def LoadConfiguration(configPath): """ Load config.ini file """ try: configManager = ConfigManager(configPath) barConfig = configManager.ParseConfig() return barConfig except (KeyboardInterrupt, SystemExit): raise except FileNotFoundError: logging.exception("Config file BarSupplyOptimizerConfig.ini not found") ExitWithError() except: # catch all other exceptions logging.exception("Couldn't load BarSupplyOptimizerConfig.ini") ExitWithError()
def test_set_parm(self): cfg = ConfigManager(config_parms) parser = argparse.ArgumentParser() config_parms.add_to_parser(parser, current=cfg) parser.add_argument('-show', dest='show', action="store_true", help="show current configuration") parser.add_argument('-upd', dest='update', action="store_true", help="update configuration file") parser.add_argument('--create', action="store_true", help="create database if it doesn't exist") parser.add_argument('--configfile', help="configuration file location (default: %s)" % test_config_file, default=test_config_file) opts = parser.parse_args( "-db rf2test --host localhost --port 8091 -u root -p rootpw".split( )) cfg.update(vars(opts)) cfg.set_configfile(test_config_file) self.assertEqual( str(cfg), """[dbparms] host = localhost db = rf2test charset = utf8 port = 8091 user = root passwd = rootpw""") cfg.flush() cfg = ConfigManager(config_parms) self.assertEqual( str(cfg), """[dbparms] host = localhost db = rf2test charset = utf8 port = 8091 user = root passwd = rootpw""")
def test_double_set(self): cfg = ConfigManager(config_parms) cfg.set_configfile(test_config_file) cfg.set_configfile(test_config_file) self.assertRaises(AssertionError, cfg.set_configfile, test_config_file + 'z')
def setConfig(cfgfile='settings.conf'): cfg_conf = os.path.join(os.path.dirname(__file__), 'testdata', cfgfile) from ConfigManager.ConfigManager import ConfigManager ConfigManager.set_configfile(cfg_conf, override=True)
def clearConfig(): from ConfigManager.ConfigManager import ConfigManager ConfigManager.clear_configfile()