本文整理汇总了Python中config.configmanager.ConfigManager.set_config_path方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigManager.set_config_path方法的具体用法?Python ConfigManager.set_config_path怎么用?Python ConfigManager.set_config_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.configmanager.ConfigManager
的用法示例。
在下文中一共展示了ConfigManager.set_config_path方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: from config.configmanager import ConfigManager [as 别名]
# 或者: from config.configmanager.ConfigManager import set_config_path [as 别名]
def start(cls, config_path: str = CONFIG_PATH) -> None:
"""
Starts the runtime server with all components
:param config_path: Path to an alternative config directory
"""
cls.CONFIG_PATH = config_path
# set the config_path at the manager
ConfigManager.set_config_path(config_path)
# read from config the Vlan mode
vlan_activate = ConfigManager.get_server_property("Vlan_On")
cls.VLAN = vlan_activate
# read from config if debug mode is on
log_level = int(ConfigManager.get_server_property("Log_Level"))
debug_mode = False
if log_level is 10:
debug_mode = True
cls.DEBUG = debug_mode
# create instance and give params to the logger object
Logger().setup(log_level, log_level, log_level)
# load Router configs
cls.__load_configuration()
if cls.VLAN:
from util.router_info import RouterInfo
# TODO: Die Funktion 'cls.update_router_info' sollte verwendet werden
RouterInfo.update(cls.get_routers()[0])
print("Runtime Server started")
cls._ipc_server.start_ipc_server(cls, True) # serves forever - works like a while(true)
示例2: test_set_config_path
# 需要导入模块: from config.configmanager import ConfigManager [as 别名]
# 或者: from config.configmanager.ConfigManager import set_config_path [as 别名]
def test_set_config_path(self):
"""
Tests to set the config path
:return: Tests results
"""
base_dir = path.dirname(path.dirname(__file__)) # This is your Project Root
config_path = path.join(base_dir, 'framework_unittests/configs/config_no_vlan')
ConfigManager.set_config_path(config_path)
self.assertEqual(ConfigManager.CONFIG_PATH, config_path, "Wrong path")
config_path = path.join(base_dir, 'config') # Join Project Root with config
ConfigManager.set_config_path(config_path)
self.assertEqual(ConfigManager.CONFIG_PATH, config_path, "Wrong path")
示例3: start
# 需要导入模块: from config.configmanager import ConfigManager [as 别名]
# 或者: from config.configmanager.ConfigManager import set_config_path [as 别名]
def start(cls, config_path: str = CONFIG_PATH) -> None:
"""
Starts the runtime server with all components.
:param config_path: Path to an alternative config directory
"""
# server has to be run with root rights - except on travis CI
if not os.geteuid() == 0 and not os.environ.get('TRAVIS'):
sys.exit('Script must be run as root')
cls._stopped = Lock()
signal.signal(signal.SIGTERM, cls._signal_term_handler)
cls.CONFIG_PATH = config_path
# set the config_path at the manager
ConfigManager.set_config_path(config_path)
# read from config the Vlan mode
vlan_activate = ConfigManager.get_server_property("Vlan_On")
cls.VLAN = vlan_activate
# read from config if debug mode is on
log_level = int(ConfigManager.get_server_property("Log_Level"))
debug_mode = False
if log_level is 10:
debug_mode = True
cls.DEBUG = debug_mode
setproctitle("fftserver")
cls._server_stop_event = Event()
cls._pid = os.getpid()
# create instance and give params to the logger object
LoggerSetup.setup(log_level)
# load Router configs
cls.__load_configuration()
for router in cls.get_routers():
cls._running_task.append(None)
cls._waiting_tasks.append(deque())
# start process/thread pool for job and test handling
cls._max_subprocesses = (len(cls._routers) + 1) # plus one for the power strip
cls._task_pool = Pool(processes=cls._max_subprocesses, initializer=init_process,
initargs=(cls._server_stop_event,), maxtasksperchild=1)
cls._task_wait_executor = ThreadPoolExecutor(max_workers=(cls._max_subprocesses * 2))
# start thread for multiprocess stop wait
t = threading.Thread(target=cls._close_wait)
t.start()
# add Namespace and Vlan for each Router
if cls.VLAN:
cls._nv_assistent = NVAssistent("eth0")
for router in cls.get_routers():
logging.debug("Add Namespace and Vlan for Router(" + str(router.id) + ")")
cls._nv_assistent.create_namespace_vlan(router)
# add Namespace and Vlan for 1 Powerstrip (expand to more if necessary)
logging.debug("Add Namespace and Vlan for Powerstrip")
cls._nv_assistent.create_namespace_vlan(cls.get_power_strip())
# update Router
cls.router_online(None, update_all=True, blocked=True)
cls.update_router_info(None, update_all=True)
# open database and read old test results
try:
with shelve.open('test_results', 'c') as db:
# read test values
key_list = db.keys()
for k in key_list:
t = TestResult()
dbt = db[str(k)]
t.failures = dbt.failures
t.errors = dbt.errors
t.testsRun = dbt.testsRun
t._original_stdout = None
t._original_stderr = None
cls._test_results.append((dbt.router_id, dbt.test_name, t))
except Exception as e:
logging.error("Error at read test results from DB: {0}".format(e))
logging.info("Runtime Server started")
try:
cls._ipc_server.start_ipc_server(cls, True) # serves forever - works like a while(true)
except (KeyboardInterrupt, SystemExit):
logging.info("Received an interrupt signal")
cls.stop()