utils.py 535 B

1234567891011121314151617
  1. # -*- coding: utf-8 -*-
  2. # Copyright (C) 2015-2016 Peter Magnusson <peter@birchroad.net>
  3. """Various utility functions"""
  4. from platform import system
  5. from os import environ
  6. __all__ = ['default_port', 'system']
  7. def default_port(sysname=system()):
  8. """This returns the default port used for different systems if SERIALPORT env variable is not set"""
  9. system_default = {
  10. 'Windows': 'COM1',
  11. 'Darwin': '/dev/tty.SLAB_USBtoUART'
  12. }.get(sysname, '/dev/ttyUSB0')
  13. return environ.get('SERIALPORT', system_default)