meshtastic / python

The Python CLI and API for talking to Meshtastic devices
https://meshtastic.org
367 stars 155 forks source link

Does not start on Windows Server 2022 #639

Open tuesdays opened 1 month ago

tuesdays commented 1 month ago

When starting the via pip3 installed version of the cli, it crashes while validating the OS.

PS C:\meshtastic\cli\meshtastic> meshtastic --info
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Scripts\meshtastic.exe\__main__.py", line 7, in <module>
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\meshtastic\__main__.py", line 1573, in main
    common()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\meshtastic\__main__.py", line 1064, in common
    client = meshtastic.serial_interface.SerialInterface(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\meshtastic\serial_interface.py", line 64, in __init__
    StreamInterface.__init__(
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\meshtastic\stream_interface.py", line 41, in __init__
    self.is_windows11 = is_windows11()
                        ^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\meshtastic\util.py", line 513, in is_windows11
    if float(platform.release()) >= 10.0:
       ^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not convert string to float: '2022Server'

How to reproduce:

  1. Install Python 3.12.4 with the default "next - next - next" setup on Windows Server 2022
  2. Run pip3 install --upgrade pytap2
  3. Run pip3 install --upgrade meshtastic
  4. Run meshtastic --info
tuesdays commented 1 month ago

After commenting the check function out, the CLI works fine. For easy fix, here the list of platform.release() return values for Windows OS.

Windows 7: '7' Windows 8: '8' Windows 8.1: '8.1' Windows 10: '10' Windows 11: '10.0' Windows Server 2012 R2: '2012R2Server' Windows Server 2016: '2016Server' Windows Server 2019: '2019Server' Windows Server 2022: '2022Server'