mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-15 01:24:29 +02:00
fix for dashes in name
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
jc changelog
|
||||
|
||||
20230402 v1.23.2
|
||||
- Fix `iwconfig` command parser for SSIDs with dashes in the name
|
||||
|
||||
20230323 v1.23.1
|
||||
- Fix `zpool-status` command parser for lines that start with tab
|
||||
- Fix `timedatectl` command parser when RTC set to local
|
||||
|
@ -108,4 +108,4 @@ Returns:
|
||||
### Parser Information
|
||||
Compatibility: linux
|
||||
|
||||
Version 1.0 by Thomas Vincent (vrince@gmail.com)
|
||||
Version 1.1 by Thomas Vincent (vrince@gmail.com)
|
||||
|
@ -85,7 +85,7 @@ import jc.utils
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
description = '`iwconfig` command parser'
|
||||
author = 'Thomas Vincent'
|
||||
author_email = 'vrince@gmail.com'
|
||||
@ -146,7 +146,7 @@ def parse(
|
||||
|
||||
raw_output: List[Dict] = []
|
||||
|
||||
re_interface = re.compile(r'^(?P<name>[a-zA-Z0-9:._-]+)\s+(?P<protocol>([a-zA-Z0-9]+\s)*[a-zA-Z0-9.]+)\s+ESSID:\"(?P<essid>[a-zA-Z0-9:._\s\-]+)\"')
|
||||
re_interface = re.compile(r'^(?P<name>[a-zA-Z0-9:._\-]+)\s+(?P<protocol>([a-zA-Z0-9]+\s)*[a-zA-Z0-9.]+)\s+ESSID:\"(?P<essid>[a-zA-Z0-9:._\s\-]+)\"')
|
||||
re_mode = re.compile(r'Mode:(?P<mode>\w+)')
|
||||
re_frequency = re.compile(r'Frequency:(?P<frequency>[0-9.]+)\s(?P<frequency_unit>\w+)')
|
||||
re_access_point = re.compile(r'Access Point:\s*(?P<access_point>[0-9A-F:]+)')
|
||||
|
1
tests/fixtures/generic/iwconfig-space-dash-ssid.json
vendored
Normal file
1
tests/fixtures/generic/iwconfig-space-dash-ssid.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"name":"wlp-50","protocol":"IEEE 802.11","essid":"BLABLABLA-bla bla bla","mode":"Managed","frequency":5.18,"frequency_unit":"GHz","access_point":"E6:63:DA:16:50:BF","bit_rate":6.0,"bit_rate_unit":"Mb/s","tx_power":30,"tx_power_unit":"dBm","retry_short_limit":7,"rts_threshold":false,"fragment_threshold":false,"power_management":true,"link_quality":"58/70","signal_level":-52,"signal_level_unit":"dBm","rx_invalid_nwid":0,"rx_invalid_crypt":0,"rx_invalid_frag":0,"tx_excessive_retries":0,"invalid_misc":1766,"missed_beacon":0}]
|
9
tests/fixtures/generic/iwconfig-space-dash-ssid.out
vendored
Normal file
9
tests/fixtures/generic/iwconfig-space-dash-ssid.out
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
wlp-50 IEEE 802.11 ESSID:"BLABLABLA-bla bla bla"
|
||||
Mode:Managed Frequency:5.18 GHz Access Point: E6:63:DA:16:50:BF
|
||||
Bit Rate=6 Mb/s Tx-Power=30 dBm
|
||||
Retry short limit:7 RTS thr:off Fragment thr:off
|
||||
Power Management:on
|
||||
Link Quality=58/70 Signal level=-52 dBm
|
||||
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
|
||||
Tx excessive retries:0 Invalid misc:1766 Missed beacon:0
|
||||
|
@ -15,6 +15,9 @@ class iwconfigTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, 'fixtures/generic/iwconfig-many.out'), 'r', encoding='utf-8') as f:
|
||||
iwconfig_many_output = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, 'fixtures/generic/iwconfig-space-dash-ssid.out'), 'r', encoding='utf-8') as f:
|
||||
iwconfig_space_dash_ssid = f.read()
|
||||
|
||||
# output
|
||||
with open(os.path.join(THIS_DIR, 'fixtures/generic/iwconfig.json'), 'r', encoding='utf-8') as f:
|
||||
iwconfig_json = json.loads(f.read())
|
||||
@ -23,7 +26,10 @@ class iwconfigTests(unittest.TestCase):
|
||||
iwconfig_raw_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, 'fixtures/generic/iwconfig-many.json'), 'r', encoding='utf-8') as f:
|
||||
iwconfig_many_json = json.loads(f.read())
|
||||
iwconfig_many_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, 'fixtures/generic/iwconfig-space-dash-ssid.json'), 'r', encoding='utf-8') as f:
|
||||
iwconfig_space_dash_ssid_json = json.loads(f.read())
|
||||
|
||||
|
||||
def test_iwconfig_nodata(self):
|
||||
@ -50,5 +56,11 @@ class iwconfigTests(unittest.TestCase):
|
||||
"""
|
||||
self.assertEqual(jc.parsers.iwconfig.parse(self.iwconfig_many_output, quiet=True), self.iwconfig_many_json)
|
||||
|
||||
def test_iwconfig_space_dash_ssid(self):
|
||||
"""
|
||||
Test 'iwconfig' many spaces and dashes in the SSID
|
||||
"""
|
||||
self.assertEqual(jc.parsers.iwconfig.parse(self.iwconfig_space_dash_ssid, quiet=True), self.iwconfig_space_dash_ssid_json)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user