本文整理汇总了Python中ossimsetupconfig.AVOssimSetupConfigHandler.get_general_admin_ip方法的典型用法代码示例。如果您正苦于以下问题:Python AVOssimSetupConfigHandler.get_general_admin_ip方法的具体用法?Python AVOssimSetupConfigHandler.get_general_admin_ip怎么用?Python AVOssimSetupConfigHandler.get_general_admin_ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ossimsetupconfig.AVOssimSetupConfigHandler
的用法示例。
在下文中一共展示了AVOssimSetupConfigHandler.get_general_admin_ip方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_general_admin_ip
# 需要导入模块: from ossimsetupconfig import AVOssimSetupConfigHandler [as 别名]
# 或者: from ossimsetupconfig.AVOssimSetupConfigHandler import get_general_admin_ip [as 别名]
def test_get_general_admin_ip(self):
config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1.conf")
self.assertEqual(config.get_general_admin_ip(),"192.168.2.22")
del config
config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup3.conf")
self.assertEqual(config.get_general_admin_ip(),None)
del config
config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup4.conf")
self.assertEqual(config.get_general_admin_ip(),None)
del config
config = AVOssimSetupConfigHandler(TEST_FILES_PATH+"ossim_setup1111.conf")
self.assertEqual(config.get_general_admin_ip(),None)
del config
示例2: fetch_server_ip
# 需要导入模块: from ossimsetupconfig import AVOssimSetupConfigHandler [as 别名]
# 或者: from ossimsetupconfig.AVOssimSetupConfigHandler import get_general_admin_ip [as 别名]
def fetch_server_ip(raw_ip):
if raw_ip == '0.0.0.0/0':
# Fetch ip address of the server from ossim_setup.conf
# when client uses DHCP
config_parser = AVOssimSetupConfigHandler()
server_ip = config_parser.get_general_admin_ip()
if args.debug:
print "Client uses DHCP: {}".format(raw_ip)
print "Fetched ip from ossim_conf: {}".format(server_ip)
return server_ip
command = "ip route get {} | head -1 | tr -s ' '".format(raw_ip)
server_ip = subprocess.check_output(
command, shell=True, stderr=subprocess.STDOUT
)
if args.debug:
print "command: ", command
print "command output: ", server_ip.strip()
return server_ip.strip().split()[-1]