title: Python FTP grabbing and saving images issue
body: <p><strong>EDIT: I got it working it just won't download anything...</strong></p>
  
  <p>So here is my code simplified now:</p>
  
  <pre><code>notions_ftp = ftplib.FTP(ftp_host, ftp_user, ftp_passwd)
  folder = "Leisure Arts - Images"
  notions_ftp.cwd(folder)
  image = open("015693PR-com.jpg","wb")
  notions_ftp.retrlines("RETR 015693PR-com.jpg", image.write)
  send_image = open("015693PR-com.jpg", 'r')
  </code></pre>
  
  <p>And Here is my output:</p>
  
  <pre><code>'250 "/Leisure Arts - Images": is current directory.'
  '226 Transfer complete. 0 bytes in 0.00 sec. (0.000 Kb/s)'
  </code></pre>
  
  <p><strong>Original Post:</strong>
  OK So I have been messing with this all day long. I am fairly new to Python FTP. So I have searched through here and came up w/ this:</p>
  
  <pre><code>images = notions_ftp.nlst()
      for image_name in image_names:
          if found_url == False:
              try:
                  for image in images:
                      ftp_image_name = "./%s" % image_name
                      if ftp_image_name == image:
                          found_url = True
                          image_name_we_want = image_name
              except:
                  pass
  
      # We failed to find an image for this product, it will have to be done manually
      if found_url == False:
          log.info("Image ain't there baby -- SKU: %s" % sku)
          return False
      # Hey we found something! Open the image....
      notions_ftp.retrlines("RETR %s" % image_name_we_want, open(image_name_we_want, "rb"))
      1/0
  </code></pre>
  
  <p>So I have narrowed the error down to the line before I divide by zero. Here is the error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;console&gt;", line 6, in &lt;module&gt;
    File "&lt;console&gt;", line 39, in insert_image
  IOError: [Errno 2] No such file or directory: '411483CC-IT,IM.jpg'
  </code></pre>
  
  <p>So if you follow the code you will see that the image IS in the directory because image_name_we_want is set if found in that directory listing on the first line of my code. And I KNOW it's there because I am looking at the FTP site myself and ...it's freakin there. So at some point during all of this I got the image to save locally, which is most desired, but I have long since forgot what I used to make it do that. Either way, why does it think that the image isn't there when it clearly finds it in the listing.</p>
  
  <p>OK so I took the suggestion and now I get:</p>
  
  <pre><code>14:01:18,057 ERROR [pylons-admin] Image to big or corrupt! Skipping Image for product sku: 411483
  14:01:18,057 ERROR [pylons-admin] Image to big or corrupt! Skipping Image for product sku: 411483
  Traceback (most recent call last):
    File "&lt;console&gt;", line 6, in &lt;module&gt;
    File "&lt;console&gt;", line 40, in insert_image
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ftplib.py", line 418, in retrlines
      callback(line)
  TypeError: 'file' object is not callable
  &gt;&gt;&gt; 14:01:24,694 INFO  [pylons-admin] Script Done! Updated 0 Products w/ Images
  </code></pre>
  
  <p>So it got the first image, which I think really is corrupt, but then when it goes on to the next one to be processed it throws that error on the file object. So here is how I changed it and the rest of the code not put here in the first place:</p>
  
  <pre><code># Hey we found something! Open the image....
      f = open(image_name_we_want, "wb")
      notions_ftp.retrlines("RETR %s" % image_name_we_want, f)
      send_image = open(image_name_we_want, 'r')
  
      # ...and send it for processing
      try:
          image_id = product_obj.set_image(send_image, 5, 1)
      except IOError, error:
          log.error("Image to big or corrupt! Skipping Image for product sku: %s" % sku)
          image_id = False
      else:
          if image_id == False:
              log.error("Could not Insert the image for product sku: %s" % sku)
              f.close()
              return False
          else:
              f.close()
              os.remove(image_name_we_want)
              return True
  </code></pre>