basnijholt / miflora

☘️🌑🌼πŸ₯€πŸ‘ Mi Flora Plant sensor Python package
MIT License
363 stars 98 forks source link

Make windows compatible #28

Closed AnderssonPeter closed 6 years ago

AnderssonPeter commented 7 years ago

I have written a small utility for windows that tries to mimic gatttool and it seems to work at least when i run it in a command line. But when i try to run you python script on windows i get the following error:

  File "C:\Users\xbmc\AppData\Roaming\.homeassistant\deps\miflora\miflora_poller.py", line 249, in parameter_value
    self.fill_cache()
  File "C:\Users\xbmc\AppData\Roaming\.homeassistant\deps\miflora\miflora_poller.py", line 180, in fill_cache
    firmware_version = self.firmware_version()
  File "C:\Users\xbmc\AppData\Roaming\.homeassistant\deps\miflora\miflora_poller.py", line 221, in firmware_version
    res = read_ble(self._mac, '0x038', retries=self.retries, adapter=self._adapter)
  File "C:\Users\xbmc\AppData\Roaming\.homeassistant\deps\miflora\miflora_poller.py", line 117, in read_ble
    preexec_fn=os.setsid) as process:
AttributeError: module 'os' has no attribute 'setsid'

If i understand correctly the os.setsid does not exist on windows and i have no idea what it does. But i tried to remove the preexec_fn=os.setsid and that seemed to solve the issue.

Any chance that you could release a new version that includes a better fix? (my guess is that you can't just remove it on Linux without breaking things).

AnderssonPeter commented 7 years ago

It looks like os.killpg is also not available under windows.

ChristianKuehnel commented 6 years ago

Honestly I'm not a big fan of porting gatttool to windows and wrapping it via stdin/stdout. I would prefer if we find a library that we can talk directly to like bluepy or pygatt.

But I'm not sure if such a library exists on Windows...

ChristianKuehnel commented 6 years ago

duplicate of #51