Seite 1 von 1
ftplib download frage
Verfasst: Freitag 13. Mai 2005, 13:49
von pr0stAta
Halli Hallo, eigentlich etwas peinlich zu fragen, aber
kann mir jemand erklären wie
Code: Alles auswählen
retrbinary( command, callback[, maxblocksize[, rest]])
funktioniert? Ich habs geschafft dateien auf nem ftp hochzuladen aber schaffe es nicht, jpg's oder andere dateitypen herunterzuladen.
soweit ist mir das schon klar, aber was ist mit callback gemeint?
danke schonmal im voraus.
gruss prosta
Verfasst: Samstag 14. Mai 2005, 00:10
von BlackJack
Das muss eine Funktion sein die einen Parameter entgegennimmt. Die wird für oder besser gesagt mit jedem empfangenen Datenblock aufgerufen. Die `write()` Methode von einer offenen Datei müsste zum Beispiel funktionieren.
Verfasst: Samstag 14. Mai 2005, 00:14
von rayo
Hi
Entweder in der Doku nachlesen oder sonst einfach mal ne Dummy-Funktion übergeben und kucken wann der Callback aufgerufen wird.
Code: Alles auswählen
def callbackTest(self, *args, **kwargs):
print 'Callback', args, kwargs
self.ftp.retrbinary("RETR " + filename, self.callbackTest)
Aber in der Doku stehts so schön

:
Code: Alles auswählen
retrbinary( command, callback[, maxblocksize[, rest]])
Retrieve a file in binary transfer mode. command should be an
appropriate "RETR" command: 'RETR filename'. The callback
function is called for each block of data received, with a single
string argument giving the data block. The optional maxblocksize
argument specifies the maximum chunk size to read on the
low-level socket object created to do the actual transfer (which will
also be the largest size of the data blocks passed to callback). A
reasonable default is chosen. rest means the same thing as in the
transfercmd() method.
Gruss
Verfasst: Dienstag 17. Mai 2005, 07:39
von pr0stAta
wunderbar. nun hab ichs auch geschafft danke :>