pythonpyserialwine

Determine if a python program is running on WINE


I can check for Linux/Windows/cygwin/etc. with sys.platform, but on WINE it just reports 'win32'.

I am attempting to write a multi-platform application that uses pyserial, and I am using WINE to test setup of a Windows environment. On Windows serial ports are named COMxx, but on Linux they are /dev/ttyxxx. However, on WINE the serial ports have Linux names. I need to detect if it is running on WINE separate from Windows so I can handle this properly.


Solution

  • First of all, and this is untested, try creating a symlink from .wine/dosdevices/COM1 to /dev/ttyS0. It should simply allow you to open the com port the Windows way.

    If, however, you are determined to know whether you are running on Wine, the "official" way is to check whether the registry has the key "HKEY_LOCAL_MACHINE\Software\Wine".

    Either way, if opening COM1 doesn't work on Wine, it is a bug and should be filed with the Wine bugzilla.