title: Setting up proxy with FTP with Python
body: <p>We are trying to develop a Python module that will hit an FTP server and download files to my local machine. When we try to run the FTP portion of the module it is timing out.</p>
  <p>We have a proxy server (let's call it &quot;officeproxy.com:8080&quot;) to handle this and when using an FTP client like FileZilla or Windows Explorer to access FTP sites we are successful.</p>
  <p>Let's call the ftp site &quot;ftp.cal.com&quot;.  User name is &quot;papa&quot;.  Password is &quot;tango123&quot;.</p>
  <p>So far we have:</p>
  <pre><code>Proxy = officeproxy.com:8080
  FTP = ftp.cal.com
  User = papa
  PW = tango123 
  </code></pre>
  <p>The above are not real entities so if you want to swap them out for real ones, be my guest.</p>
  <p>I need a module to first load the proxy service then run the FTP portion.</p>
  <p>I am running Python 2.7.</p>
  <p>I have searched around and have this code so far.  The OP said it is just a short module to test connection to FTP and read one file.</p>
  <p>(Note: I have intentionally put <code>#</code> in a lot of places to show when I don't know to fill in, or other reasons):</p>
  <pre><code>import urllib2
  # I have filled in the proxy info
  proxy_host = 'officeproxy.com:8080'
  
  # I don't think this needs any modification, right?  
  proxy_handler = urllib2.ProxyHandler({'ftp': proxy_host})
  
  # ditto here 
  proxy_auth_handler = urllib2.ProxyBasicAuthHandler() 
  
  # now here is where I am unsure what to put; 
  # also, I really need FTP user and FTP password, and NOT Proxy... 
  # so what do I need to change here?
  proxy_auth_handler.add_password(None, proxy_host, proxy_user, proxy_passwd) 
  opener_thru_proxy = urllib2.build_opener(proxy_handler, proxy_auth_handler)
  
  # I filled in this part
  conn = opener_thru_proxy.open('ftp://ftp.cal.com/hello.txt') 
  
  # I don't believe I need to change this, right?
  print conn.read()
  </code></pre>