Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
util.py
Go to the documentation of this file.
1 # coding: utf-8
2 
3 import string
4 import random
5 from serial.tools.list_ports import comports
6 try:
7  from glob import glob
8 except Exception as error:
9  print 'Install glob'
10  raise error
11 
12 
13 ROOT_MESSAGE = """
14  .-------------------------------.
15  ( You need Super Cow Powers here. )
16  '-------------------------------'
17  \ ^__^
18  \ (oo)\_______
19  (__)\ )\/\\
20  ||----w |
21  || ||
22 
23  """
24 
25 
26 def randomstring():
27  """ rewriting method """
28  chars = string.ascii_uppercase + string.digits
29  return ''.join(random.choice(chars) for _ in range(20))
30 
31 
33  # looking for available ports
34  PORTS_AVAILABLE = glob('/dev/ttyUSB*') + glob('/dev/ttyACM*')
35  try:
36  for port, desc, hwid in sorted(comports()):
37  if port not in port:
38  PORTS_AVAILABLE.append(port)
39  except Exception as error:
40  raise error
41  if len(PORTS_AVAILABLE) == 0:
42  PORTS_AVAILABLE = None
43 
44  return PORTS_AVAILABLE
def available_ports
Definition: util.py:32
def randomstring
Definition: util.py:26