def listSerialPorts():
cmd = '<STR_LIT>'<EOL>err, ret = commands.getstatusoutput(cmd)<EOL>if not err:<EOL><INDENT>r = ret.split('<STR_LIT:\n>')<EOL>ret = []<EOL>for line in r:<EOL><INDENT>if line.find('<STR_LIT>') >= <NUM_LIT:0>:<EOL><INDENT>line = line.replace('<STR_LIT:U+0020>', '<STR_LIT>')<EOL>ret.append(line)<EOL><DEDENT><DEDENT><DEDENT>return err, ret<EOL>
http://pyserial.readthedocs.io/en/latest/shortintro.html

This calls the command line tool from pyserial to list the available
serial ports.