skodaconnect / myskoda

Python library for interacting with MySkoda APIs.
MIT License
9 stars 22 forks source link

Library not running on Windows #77

Closed WebSpider closed 1 month ago

WebSpider commented 1 month ago

According to @scoutice on Discord, attempting to run the library on Windows gives:

C:\Windows\System32>myskoda --user "<<myemail>>" --password "<<mypassword>>" list-vehicles
2024-10-02 18:14:24 PC195 myskoda.myskoda[28192] INFO IDK Authorization was successful.
2024-10-02 18:14:25 PC195 myskoda.mqtt[28192] ERROR Failed to connect to MQTT.
2024-10-02 18:14:30 PC195 asyncio[28192] ERROR Task exception was never retrieved
future: <Task finished name='Task-16' coro=<AsyncioPahoClient._loop_misc() done, defined at C:\Users\thofer\AppData\Local\Programs\Python\Python312\Lib\site-packages\asyncio_paho\client.py:342> exception=NotImplementedError()>
Traceback (most recent call last):
  File "C:\Users\thofer\AppData\Local\Programs\Python\Python312\Lib\site-packages\asyncio_paho\client.py", line 348, in _loop_misc
    self.reconnect()
  File "C:\Users\thofer\AppData\Local\Programs\Python\Python312\Lib\site-packages\paho\mqtt\client.py", line 1086, in reconnect
    self._call_socket_open()
  File "C:\Users\thofer\AppData\Local\Programs\Python\Python312\Lib\site-packages\paho\mqtt\client.py", line 2155, in _call_socket_open
    on_socket_open(self, self._userdata, self._sock)
  File "C:\Users\thofer\AppData\Local\Programs\Python\Python312\Lib\site-packages\asyncio_paho\client.py", line 299, in _on_socket_open_asyncio
    self._event_loop.add_reader(sock, client.loop_read)
  File "C:\Users\thofer\AppData\Local\Programs\Python\Python312\Lib\asyncio\events.py", line 538, in add_reader
    raise NotImplementedError
NotImplementedError
2024-10-02 18:14:30 PC195 myskoda.mqtt[28192] ERROR Failed to connect to MQTT.
2024-10-02 18:14:35 PC195 myskoda.mqtt[28192] ERROR Failed to connect to MQTT.
2024-10-02 18:14:40 PC195 myskoda.mqtt[28192] ERROR Failed to connect to MQTT.
2024-10-02 18:14:45 PC195 myskoda.mqtt[28192] ERROR Failed to connect to MQTT.

He was able to make it work by adding:

if sys.version_info >= (3, 8) and sys.platform.lower().startswith("win"):
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
WebSpider commented 1 month ago

@scoutice can you please see if the issue is solved in the windows-compatibility branch?

scoutice commented 1 month ago

@WebSpider: no, fails on my windows10/amd system: in my sys.platform and sys_platform.lower() delivers "win32"

scoutice commented 1 month ago

Betriebssystemname: Microsoft Windows 10 Pro Betriebssystemversion: 10.0.19045 Nicht zutreffend Build 19045 Betriebssystemhersteller: Microsoft Corporation Betriebssystemkonfiguration: Eigenständige Arbeitsstation Typ des Betriebssystembuilds: Multiprocessor Free Systemstartzeit: 27.09.2024, 07:45:57 Systemhersteller: To Be Filled By O.E.M. Systemmodell: To Be Filled By O.E.M. Systemtyp: x64-based PC Prozessor(en): 1 Prozessor(en) installiert. [01]: AMD64 Family 21 Model 2 Stepping 0 AuthenticAMD ~3900 MHz