Skip to content

Instantly share code, notes, and snippets.

@bDrwx
Created January 27, 2020 19:14
Show Gist options
  • Save bDrwx/ac55c75318ffca01f3abdca0a145856b to your computer and use it in GitHub Desktop.
Save bDrwx/ac55c75318ffca01f3abdca0a145856b to your computer and use it in GitHub Desktop.
# pylint: disable=wrong-import-position
if sys.platform == 'cli':
from serial.serialcli import Serial
else:
import os
# chose an implementation, depending on os
if os.name == 'nt': # sys.platform == 'win32':
from serial.serialwin32 import Serial
elif os.name == 'posix':
from serial.serialposix import Serial, PosixPollSerial, VTIMESerial # noqa
elif os.name == 'java':
from serial.serialjava import Serial
else:
raise ImportError("Sorry: no implementation for your platform ('{}') available".format(os.name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment