From af8f8e04729213684d57129b5e82e509f426201a Mon Sep 17 00:00:00 2001 From: Sean Robinson Date: Sat, 19 Apr 2014 14:49:01 -0700 Subject: [PATCH] Change interpolation style in configuration file The old interpolation style depends on values found locally or in the DEFAULT section. The new interpolation style allows using values from any other section, which is needed to get the interface value from the GENERAL section. Also, update the test data. Signed-off-by: Sean Robinson --- test/data/wifi-radar-test.conf | 6 +++--- test/unit/config.py | 8 ++++---- wifi-radar | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/test/data/wifi-radar-test.conf b/test/data/wifi-radar-test.conf index 11cb5e4..604e6cf 100644 --- a/test/data/wifi-radar-test.conf +++ b/test/data/wifi-radar-test.conf @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- [DHCP] -args = -D -o -i dhcp_client -t 30 +args = -D -o -i dhcp_client -t ${timeout} command = /sbin/dhcpcd kill_args = -k -pidfile = /etc/dhcpc/dhcpcd-auto_detect.pid +pidfile = /etc/dhcpc/dhcpcd-${GENERAL:interface}.pid timeout = 30 [GENERAL] @@ -20,7 +20,7 @@ route_command = /sbin/route version = 0.0.0 [WPA] -args = -B -i auto_detect -c /etc/wpa_supplicant.conf -D wext -P /var/run/wpa_supplicant.pid +args = -B -i ${GENERAL:interface} -c ${configuration} -D ${driver} -P ${pidfile} command = /usr/sbin/wpa_supplicant configuration = /etc/wpa_supplicant.conf driver = wext diff --git a/test/unit/config.py b/test/unit/config.py index ddbb9f8..1c4820a 100644 --- a/test/unit/config.py +++ b/test/unit/config.py @@ -271,13 +271,13 @@ class TestConfigFileManager(unittest.TestCase): 'loglevel': '50', 'route_command': '/sbin/route', 'version': '0.0.0'} - self.DHCP = {'args': '-D -o -i dhcp_client -t 30', + self.DHCP = {'args': '-D -o -i dhcp_client -t ${timeout}', 'command': '/sbin/dhcpcd', 'kill_args': '-k', - 'pidfile': '/etc/dhcpc/dhcpcd-auto_detect.pid', + 'pidfile': '/etc/dhcpc/dhcpcd-${GENERAL:interface}.pid', 'timeout': '30'} - self.WPA = {'args': '-B -i auto_detect -c /etc/wpa_supplicant.conf ' - '-D wext -P /var/run/wpa_supplicant.pid', + self.WPA = {'args': '-B -i ${GENERAL:interface} -c ${configuration} ' + '-D ${driver} -P ${pidfile}', 'command': '/usr/sbin/wpa_supplicant', 'configuration': '/etc/wpa_supplicant.conf', 'driver': 'wext', diff --git a/wifi-radar b/wifi-radar index a024cd9..b6ac849 100755 --- a/wifi-radar +++ b/wifi-radar @@ -95,16 +95,17 @@ config_dhcp = { # DHCP client # How long to wait for an IP addr from DHCP server 'timeout': '30', # Arguments to use with DHCP client on connect - 'args': '-D -o -i dhcp_client -t %(timeout)s', + 'args': '-D -o -i dhcp_client -t ${timeout}', # Argument to use with DHCP client on disconnect 'kill_args': '-k', # The file where DHCP client PID is written - 'pidfile': '/etc/dhcpc/dhcpcd-%(interface)s.pid' } + 'pidfile': '/etc/dhcpc/dhcpcd-${GENERAL:interface}.pid' } config_wpa = { # WPA Supplicant 'command': '/usr/sbin/wpa_supplicant', # Arguments to use with WPA Supplicant on connect - 'args': '-B -i %(interface)s -c %(configuration)s -D %(driver)s -P %(pidfile)s', + 'args': '-B -i ${GENERAL:interface} -c ${configuration} ' + '-D ${driver} -P ${pidfile}', # Arguments to use with WPA Supplicant on disconnect 'kill_command': '', # Where the WPA Supplicant config file can be found -- 2.11.4.GIT