From 80cf59050330802c687d28657b3892eb1e8b72ac Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 16 Aug 2022 11:36:34 +0300 Subject: [PATCH 1/3] Add width --- apparse/iw_device_parser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apparse/iw_device_parser.py b/apparse/iw_device_parser.py index 1d01f13..1c499fa 100644 --- a/apparse/iw_device_parser.py +++ b/apparse/iw_device_parser.py @@ -6,7 +6,7 @@ class IwDeviceParser(BaseParser): """Parser for a device list of the iw utility""" - _channel_regex = re.compile(r'^(?P\d+) \((?P\d+) MHz\)') + _channel_regex = re.compile(r'^(?P\d+) \((?P\d+) MHz\), width: (?P\d+)') _tx_power_regex = re.compile(r'^(?P\d+\.\d+) dBm$') _default_keys = ( @@ -15,6 +15,7 @@ class IwDeviceParser(BaseParser): 'type', 'channel', 'frequency', + 'width', 'tx_power' ) _parser_keys = { @@ -65,6 +66,7 @@ def parse(self, data): elif key == 'channel': self._data[self._current]['channel'] = int(groups['channel']) self._data[self._current]['frequency'] = int(groups['frequency']) + self._data[self._current]['width'] = int(groups['width']) elif key == 'txpower': self._data[self._current]['tx_power'] = float(groups['tx_power']) From 165568c6a399177974afe833bf61ddb743aee7ac Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 18 Oct 2022 12:22:49 +0300 Subject: [PATCH 2/3] Handle cases where width may not always be present Co-authored-by: Alexander --- apparse/iw_device_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apparse/iw_device_parser.py b/apparse/iw_device_parser.py index 1c499fa..be25d50 100644 --- a/apparse/iw_device_parser.py +++ b/apparse/iw_device_parser.py @@ -6,7 +6,7 @@ class IwDeviceParser(BaseParser): """Parser for a device list of the iw utility""" - _channel_regex = re.compile(r'^(?P\d+) \((?P\d+) MHz\), width: (?P\d+)') + _channel_regex = re.compile(r'^(?P\d+) \((?P\d+) MHz\)(?:, width: (?P\d+) MHz)') _tx_power_regex = re.compile(r'^(?P\d+\.\d+) dBm$') _default_keys = ( From e8bdf4a6ac0030eee3300708552fdf56d8f0068e Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 18 Oct 2022 12:23:05 +0300 Subject: [PATCH 3/3] Handle cases where width may not always be present Co-authored-by: Alexander --- apparse/iw_device_parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apparse/iw_device_parser.py b/apparse/iw_device_parser.py index be25d50..094eb25 100644 --- a/apparse/iw_device_parser.py +++ b/apparse/iw_device_parser.py @@ -66,7 +66,8 @@ def parse(self, data): elif key == 'channel': self._data[self._current]['channel'] = int(groups['channel']) self._data[self._current]['frequency'] = int(groups['frequency']) - self._data[self._current]['width'] = int(groups['width']) + if groups['width'] is not None: + self._data[self._current]['width'] = int(groups['width']) elif key == 'txpower': self._data[self._current]['tx_power'] = float(groups['tx_power'])