Merge "conman: Add and fix logging."
diff --git a/conman/connection_manager.py b/conman/connection_manager.py
index 7ff526a..f87f1ac 100755
--- a/conman/connection_manager.py
+++ b/conman/connection_manager.py
@@ -492,14 +492,15 @@
logging.debug('Unable to join WLAN on %s', wifi.name)
self._status.connected_to_wlan = False
if self.acs():
- logging.debug('Connected to ACS on %s', wifi.name)
+ logging.debug('Connected to ACS')
if self._try_to_upload_logs:
self._try_upload_logs()
self._try_to_upload_logs = False
- wifi.last_successful_bss_info = getattr(wifi,
- 'last_attempted_bss_info',
- None)
+ if wifi.acs():
+ wifi.last_successful_bss_info = getattr(wifi,
+ 'last_attempted_bss_info',
+ None)
now = time.time()
if (self._wlan_configuration and
hasattr(wifi, 'waiting_for_acs_since')):
@@ -521,7 +522,7 @@
# If we didn't manage to join the WLAN and we don't have an ACS
# connection, we should try to establish one.
else:
- logging.debug('Not connected to ACS on %s', wifi.name)
+ logging.debug('Not connected to ACS')
self._try_next_bssid(wifi)
time.sleep(max(0, self._run_duration_s - (time.time() - start_time)))
diff --git a/conman/interface.py b/conman/interface.py
index 87a080f..972b96c 100755
--- a/conman/interface.py
+++ b/conman/interface.py
@@ -392,14 +392,17 @@
return True
socket = os.path.join(path, self.name)
+ logging.debug('%s socket is %s', self.name, socket)
try:
self._wpa_control = self.get_wpa_control(socket)
self._wpa_control.attach()
+ logging.debug('%s successfully attached', self.name)
except wpactrl.error as e:
logging.error('Error attaching to wpa_supplicant: %s', e)
return False
status = self.wpa_status()
+ logging.debug('%s status after attaching is %s', self.name, status)
self.wpa_supplicant = status.get('wpa_state') == 'COMPLETED'
if not self._initialized:
self.initial_ssid = status.get('ssid')
@@ -416,17 +419,21 @@
status = {}
if self._wpa_control and self._wpa_control.attached:
+ logging.debug('%s ctrl_iface_path %s',
+ self, self._wpa_control.ctrl_iface_path)
lines = []
try:
lines = self._wpa_control.request('STATUS').splitlines()
- except wpactrl.error:
- logging.error('wpa_control STATUS request failed')
+ except wpactrl.error as e:
+ logging.error('wpa_control STATUS request failed %s args %s',
+ e.message, e.args)
for line in lines:
if '=' not in line:
continue
k, v = line.strip().split('=', 1)
status[k] = v
+ logging.debug('%s wpa status is %s', self.name, status)
return status
def get_wpa_control(self, socket):
@@ -481,7 +488,7 @@
WIFIINFO_PATH = '/tmp/wifi/wifiinfo'
def __init__(self, socket):
- self._interface = os.path.split(socket)[-1]
+ self.ctrl_iface_path, self._interface = os.path.split(socket)
# State from QCSAPI and wifi_files.
self._client_mode = False
diff --git a/conman/interface_test.py b/conman/interface_test.py
index 0d8ead7..13dcf14 100755
--- a/conman/interface_test.py
+++ b/conman/interface_test.py
@@ -128,6 +128,10 @@
else:
raise ValueError('Invalid request_type %s' % request_type)
+ @property
+ def ctrl_iface_path(self):
+ return os.path.split(self._socket)[0]
+
# Below methods are not part of WPACtrl.
def add_event(self, event):