title: Python Paramiko Callback - duplicate output at 100% during file transfer
body: <p>I am using paramiko to access a network device and retrieve files.
  This is working ok.
  I added the callback function, to get progress on each file xfer. And I see that for each file that is transferred, it seems to report twice that it has finished the transfer.</p>
  
  <p>Here is the code.</p>
  
  <pre><code>from __future__ import division
  import paramiko, os
  
  def byte_count(xfer, to_be_xfer):
      print net_file + " transferred: {0:.0f} %".format((xfer / to_be_xfer) * 100)
  
  path = '/var/log/VPN*'
  cmd = 'file list ' + path
  
  ssh = paramiko.SSHClient()
  ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  ssh.connect('10.10.10.10', username = uname, password = psswd)
  stdin, stdout, stderr = ssh.exec_command(cmd)
  
  filelist = stdout.read().splitlines()
  
  ftp = ssh.open_sftp()
  for f in filelist:
      net_path,net_file=os.path.split(f)
      ftp.get(f, 'c:\\temp\\' + net_file, callback=byte_count) 
  ftp.close()
  
  print '\nExiting..'
  
  ssh.close()
  </code></pre>
  
  <p>I get this as a result...</p>
  
  <p>VPN transferred: 14 %<br>
  VPN transferred: 28 %<br>
  VPN transferred: 42 %<br>
  VPN transferred: 56 %<br>
  VPN transferred: 69 %<br>
  VPN transferred: 83 %<br>
  VPN transferred: 97 %<br>
  VPN transferred: 100 %<br>
  VPN transferred: 100 %<br>
  VPN.0.gz transferred: 100 %<br>
  VPN.0.gz transferred: 100 %<br>
  VPN.1.gz transferred: 44 %<br>
  VPN.1.gz transferred: 88 %<br>
  VPN.1.gz transferred: 100 %<br>
  VPN.1.gz transferred: 100 %<br>
  VPN.2.gz transferred: 43 %<br>
  VPN.2.gz transferred: 87 %<br>
  VPN.2.gz transferred: 100 %<br>
  VPN.2.gz transferred: 100 %  </p>
  
  <p>Why is the last line reported twice? Is there anyway to fix this?</p>