joshschmelzle / lswifi

a CLI-centric Wi-Fi scanning tool for Windows
https://pypi.org/project/lswifi/
BSD 3-Clause "New" or "Revised" License
49 stars 7 forks source link

First run shows 1062 not valid SystemErrorCode #9

Closed joshschmelzle closed 2 years ago

joshschmelzle commented 2 years ago

I see a 1062 is not a valid SystemErrorCodes message when running lswifi without an active WLAN NIC. Oddly subsequent launches do not produce the same error. I think I am not handling this error code. Need to investigate.

Testbed:

No active WLAN NIC:

PS C:\Users\jsz> netsh wlan show interfaces
There is no wireless interface on the system.
    Hosted network status  : Not available

Traceback:

PS C:\Users\jsz> lswifi
Traceback (most recent call last):
  File "C:\Users\jsz\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\jsz\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\jsz\AppData\Local\Programs\Python\Python310\Scripts\lswifi.exe\__main__.py", line 7, in <module>
  File "C:\Users\jsz\AppData\Local\Programs\Python\Python310\lib\site-packages\lswifi\__main__.py", line 67, in main
    loop.run_until_complete(main_task)
  File "C:\Users\jsz\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete
    return future.result()
  File "C:\Users\jsz\AppData\Local\Programs\Python\Python310\lib\site-packages\lswifi\core.py", line 74, in scan
    interfaces = WLAN_API.WLAN.get_wireless_interfaces()
  File "C:\Users\jsz\AppData\Local\Programs\Python\Python310\lib\site-packages\lswifi\wlanapi.py", line 1541, in get_wireless_interfaces
    handle = WLAN.open_handle()
  File "C:\Users\jsz\AppData\Local\Programs\Python\Python310\lib\site-packages\lswifi\wlanapi.py", line 1413, in open_handle
    f"wlanapi.wlan.open_handle() failed: {SystemErrorCodes(result)}:{result}"
  File "C:\Users\jsz\AppData\Local\Programs\Python\Python310\lib\enum.py", line 384, in __call__
    return cls.__new__(cls, value)
  File "C:\Users\jsz\AppData\Local\Programs\Python\Python310\lib\enum.py", line 701, in __new__
    raise ve_exc
ValueError: 1062 is not a valid SystemErrorCodes