title: Find USB serial port with Python script
body: <p>I am trying to write a script in python so I can find in 1 sec the COM number of the USB serial adapter I have plugged to my laptop.
  What I need is to isolate the COMx port so I can display the result and open putty with that specific port. Can you help me with that?</p>
  
  <p>Until now I have already written a script in batch/powershell and I am getting this information but I havent been able to separate the text of the COMx port so I can call the putty program with the serial parameter.
  I have also been able to find the port via Python but I cant isolate it from the string.</p>
  
  <pre><code>import re           # Used for regular expressions (unused)
  import os           # To check that the path of the files defined in the config file exist (unused)
  import sys          # To leave the script if (unused)
  import numpy as np
  from infi.devicemanager import DeviceManager
  dm = DeviceManager()
  dm.root.rescan()
  devs = dm.all_devices
  print ('Size of Devs: ',len(devs))
  print ('Type of Devs: ',type(devs))
  myarray = ([])
  myarray =np.array(devs)
  print ('Type of thing: ',type(myarray))
  match = '&lt;USB Serial Port (COM6)&gt;' (custom match. the ideal would be "USB Serial Port")
  i=0
  #print (myarray, '\n')
  while i != len(devs):
      if match == myarray[i]: 
          print ('Found it!')
          break
      print ('array: ',i," : ", myarray[i])
      i = i+1
  print ('array 49: ', myarray[49]) (here I was checking what is the difference of the "element" inside the array)
  print ('match   : ', match) (and what is the difference of what I submitted)
  print ('end')
  </code></pre>
  
  <p>I was expecting the if match == myarray[i] to find the two elements but for some reason it doesnt. Its returning me that those two are not the same.</p>
  
  <p>Thank you for any help in advance!</p>
  
  <p>=== UPDATE ===
  Full script can be found here
  <a href="https://github.com/elessargr/k9-serial" rel="nofollow noreferrer">https://github.com/elessargr/k9-serial</a></p>