本文整理汇总了Python中config.configmanager.ConfigManager类的典型用法代码示例。如果您正苦于以下问题:Python ConfigManager类的具体用法?Python ConfigManager怎么用?Python ConfigManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
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_check
def test_check(self):
"""
Test config vs. schema
:return: Test results
"""
data = ConfigManager.get_framework_config()
result = ConfigManager.check(data)
self.assertEqual(True, result, "Wrong schema or data")
示例3: run
def run(self):
"""
Instantiate a NetworkCtrl and copy the firmware via SSH to the Router(/tmp/<firmware_name>.bin).
"""
logging.info("%sSysupdate Firmware for Router(" + str(self.router.id) + ") ...", LoggerSetup.get_log_deep(1))
firmware_handler = FirmwareHandler(str(ConfigManager.get_firmware_property('URL')))
firmware = firmware_handler.get_firmware(self.router.model,
str(ConfigManager.get_firmware_property('Release_Model')),
bool(ConfigManager.get_firmware_property('Download_All')))
self.router.firmware = firmware
示例4: test_set_config_path
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")
示例5: sysupdate_firmware
def sysupdate_firmware(cls, router_ids: List[int], update_all: bool) -> None:
"""
Downloads and copies the firmware to the :py:class:`Router` given in the List(by a unique id) or to all Routers
:param router_ids: List of unique numbers to identify a :py:class:`Router`
:param update_all: Is True if all Routers should be updated
"""
from util.router_flash_firmware import RouterFlashFirmware
if update_all:
for router in cls.get_routers():
RouterFlashFirmware.sysupdate(router, ConfigManager.get_firmware_dict()[0])
else:
for router_id in router_ids:
router = cls.get_router_by_id(router_id)
RouterFlashFirmware.sysupdate(router, ConfigManager.get_firmware_dict()[0])
示例6: test_read_file
def test_read_file(self):
"""
Read a file
:return: Tests results
"""
output = ConfigManager.read_file("")
self.assertEqual(output, None, "Wrong output")
output = ConfigManager.read_file(ConfigManager.CONFIG_PATH)
self.assertEqual(output, None, "Wrong output")
file_path = path.join(ConfigManager.CONFIG_PATH, ConfigManager.FRAMEWORK_CONFIG_FILE)
output = ConfigManager.read_file(file_path)
self.assertEqual((output is not None), True, "Wrong output")
示例7: test_power_strip_dict
def test_power_strip_dict(self):
"""
Tests the power strip config
:return: Tests results
"""
data = ConfigManager.get_power_strip_dict()
self.assertEqual(True, data[0], "power_strip: Wrong config")
示例8: test_server_prop
def test_server_prop(self):
"""
Tests the server config with a property
:return: Tests results
"""
data = ConfigManager.get_server_property("Server_Name")
self.assertEqual(data, "TestServer", "Server: Wrong property")
示例9: test_server_list
def test_server_list(self):
"""
Tests the server config
:return: Tests results
"""
data = ConfigManager.get_server_list()
self.assertEqual(len(data), 3, "Server: Wrong size of the List")
示例10: test_power_strip_list
def test_power_strip_list(self):
"""
Tests the power strip config
:return: Tests results
"""
data = ConfigManager.get_power_strip_list()
self.assertEqual(len(data), 1, "power_strip: Wrong size of the List")
示例11: test_web_interface_dict
def test_web_interface_dict(self):
"""
Tests the web interface config
:return: Tests results
"""
data = ConfigManager.get_web_interface_dict()
self.assertEqual(len(data), 3, "web_interface: Wrong size of the List")
示例12: test_server_dict
def test_server_dict(self):
"""
Tests the server config
:return: Tests results
"""
data = ConfigManager.get_server_dict()
self.assertEqual(True, data[0], "Server: Wrong config")
示例13: test_get_config_framework
def test_get_config_framework(self):
"""
Tests the framework config
:return: Tests results
"""
data = ConfigManager.get_framework_config()
self.assertEqual(True, (data is not None), "Wrong data")
示例14: test_get_routers_dict
def test_get_routers_dict(self):
"""
Tests the router config
:return: Tests results
"""
data = ConfigManager.get_routers_dict()
self.assertEqual(True, data[0], "Routers: Wrong config")
示例15: test_test_dict
def test_test_dict(self):
"""
Tests the test config
:return: Tests results
"""
data = ConfigManager.get_test_dict()
self.assertEqual(True, data[0], "test: Wrong config")