ftplib storbinary method interception

Peter Schneider-Kamp petersc at stud.ntnu.no
Sun Jun 4 07:12:16 EDT 2000


Oops, the counter might benefit from actually being
incremented ;-)

def mystorbinary(self, cmd, fp, blocksize):
  '''Store a file in binary mode and print stuff.'''
  self.voidcmd('TYPE I')
  conn = self.transfercmd(cmd)
  counter = 0
  while 1:
    print counter,"Bytes read yet."
    buf = fp.read(blocksize)
    if not buf: break
    conn.send(buf)
    counter = counter + blocksize
  conn.close()
  return self.voidresp()

excuse-or-execute-me-ly y'rs Peter
--
Peter Schneider-Kamp          ++47-7388-7331
Herman Krags veg 51-11        mailto:peter at schneider-kamp.de
N-7050 Trondheim              http://schneider-kamp.de




More information about the Python-list mailing list