helloSystem / Utilities

Utilities written in PyQt5, meant for use with helloSystem
BSD 2-Clause "Simplified" License
28 stars 29 forks source link

Network: Wrong network name if signal level is three digits #80

Closed probonopd closed 3 years ago

probonopd commented 3 years ago

We must not use things like

https://github.com/helloSystem/Utilities/blob/265fe66c156d1debfeb5c8444b646db99fee053e/Developer%20Preview/Network.app/Network#L143-L148

where we hardcode the number of characters.

We need to use a regex instead.

This regex can parse the output correctly:

import re

regex = r"((?:[0-9A-Fa-f]{2}[:-]){5}(?:[0-9A-Fa-f]{2}))\ +([0-9]+)\ +(-[0-9]*)\ +([^\ ]+)\ +(.*?)\n"

matches = re.findall(regex, test_str, re.MULTILINE)
probonopd commented 3 years ago

Simple is better:

                regex = r"([^\ ]+)\t([^\ ]+)\t([^\ ]+)\t([^\ ]+)\t(.*)$"
                matches = re.findall(regex, line)