old_contents: #I got this code on http://stackoverflow.com/questions/12090503/listing-available-com-ports-with-python
  #So, yeah. I didn't wrote this code :-P
  import sys
  import glob
  import serial
  
  def serial_ports():
  	""" Lists serial port names
  
  		:raises EnvironmentError:
  			On unsupported or unknown platforms
  		:returns:
  			A list of the serial ports available on the system
  	"""
  	if sys.platform.startswith('win'):
  		ports = ['COM%s' % (i + 1) for i in range(256)]
  	elif sys.platform.startswith('linux') or sys.platform.startswith('cygwin'):
  		# this excludes your current terminal "/dev/tty"
  		ports = glob.glob('/dev/tty[A-Za-z]*')
  	elif sys.platform.startswith('darwin'):
  		ports = glob.glob('/dev/tty.*')
  	else:
  		raise EnvironmentError('Unsupported platform')
  
  	result = []
  	for port in ports:
  		try:
  			s = serial.Serial(port)
  			s.close()
  			result.append(port)
  		except (OSError, serial.SerialException):
  			pass
  	return result
  
  if __name__ == '__main__':
  	print(serial_ports())
  
new_contents: #I got this code on http://stackoverflow.com/questions/12090503/listing-available-com-ports-with-python
  #So, yeah. I didn't wrote this code :-P
  import sys
  import glob
  import serial
  
  def serial_ports():
  	""" Lists serial port names
  
  		:raises EnvironmentError:
  			On unsupported or unknown platforms
  		:returns:
  			A list of the serial ports available on the system
  	"""
  	if sys.platform.startswith('win'):
  		ports = ['COM%s' % (i + 1) for i in range(256)]
  	elif sys.platform.startswith('linux') or sys.platform.startswith('cygwin'):
  		# this excludes your current terminal "/dev/tty"
  		# ports = glob.glob('/dev/tty[A-Za-z]*')
  		ports = glob.glob('/dev/ttyUSB[A-Za-z0-9]*')
  	elif sys.platform.startswith('darwin'):
  		ports = glob.glob('/dev/tty.*')
  	else:
  		raise EnvironmentError('Unsupported platform')
  
  	result = []
  	for port in ports:
  		try:
  			s = serial.Serial(port)
  			s.close()
  			result.append(port)
  		except (OSError, serial.SerialException):
  			pass
  	return result
  
  if __name__ == '__main__':
  	print(serial_ports())
  
subject: Make hardware search only on USB on Ubuntu Linux