title: python - problems handling exception and continuing
body: <p>I am building or trying to build a python script which check's a list of ip addresses (ips.txt) for a specific program using the wmi python module.  However, no matter how I handle the exceptions on assets with no RPC service running the script stops running on an error.  I am using python 2.7.5</p>
  
  <p>Can I catch and pass the error's to proceed?
  Can I catch the error and print or return a note that the ip was not alive or rpc was not running?</p>
  
  <p>Thank you in advance</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import wmi
  list = open("ips.txt")
  
  for line in list.readlines():
      asset = line.strip('\n')
      c = wmi.WMI(asset)
      try:
          for process in c.Win32_Process (name="SbClientManager.exe"):
              print asset, process.ProcessId, process.Name
      except Exception:
          pass
  </code></pre>
  
  <p>I have tried handling the exceptions in multiple way's to continue parsing my list, but the script continues to error out with the following:</p>
  
  <pre><code>    Traceback (most recent call last):
    File ".\check_service.py", line 12, in &lt;module&gt;
      c = wmi.WMI(asset)
    File "C:\Python27\lib\site-packages\wmi.py", line 1290, in connect
      handle_com_error ()
    File "C:\Python27\lib\site-packages\wmi.py", line 241, in handle_com_error
      raise klass (com_error=err)
  wmi.x_wmi: &lt;x_wmi: Unexpected COM Error (-2147023174, 'The RPC server is unavailable.', None, None)&gt;
  </code></pre>
  
  <p>Ultimately, I am just trying to continue the script and catch the error.  Maybe a note stating that IP was not responsive would be helpful.  Here are the exceptions samples that I have tried:</p>
  
  <pre><code>except Exception:
      sys.exc_clear()
  
  except:
      pass
  
  except wmi.x_wmi, x:
      pass
  </code></pre>