dobrii den, mozet kto nibud padskazet kak pacinit eto Код (Text): >>> ================================ RESTART ================================ >>> *cmd* 'TYPE A' *resp* '200 Type set to A.' *cmd* 'PORT x,x,x,x,19,137' *resp* '200 Port command successful.' *cmd* 'LIST' *resp* '150 Opening data connection for directory list.' drwxr-xr-x 1 ftp ftp 0 Jul 16 17:30 incoming drwxr-xr-x 1 ftp ftp 0 Jun 29 21:41 photos drwxr-xr-x 1 ftp ftp 0 Jun 25 15:31 public -rw-r--r-- 1 ftp ftp 6148 Jul 04 20:21 .DS_Store *resp* '226 Transfer ok' *cmd* 'CWD /incoming' *resp* '250 CWD command successful. "/incoming" is current directory.' *cmd* 'TYPE A' *resp* '200 Type set to A.' *cmd* 'PORT x,x,x,x,19,139' *resp* '200 Port command successful.' *cmd* 'LIST' *resp* '150 Opening data connection for directory list.' drwxr-xr-x 1 ftp ftp 0 Jun 26 15:37 AVSvideoconverter drwxr-xr-x 1 ftp ftp 0 Jun 26 16:15 CompTIA Security(plus) Deluxe Study Guide drwxr-xr-x 1 ftp ftp 0 Jun 26 16:02 QuickBooks 2009 All-in-One For Dummies -rw-r--r-- 1 ftp ftp 51577510 Jun 26 16:34 Solacev3.1-NoManila.zip -rw-r--r-- 1 ftp ftp 0 Jul 16 17:30 test.txt *resp* '226 Transfer ok' *cmd* 'TYPE I' *resp* '200 Type set to I.' *cmd* 'PORT x,x,x,x,19,141' *resp* '200 Port command successful.' *cmd* 'RETR Solacev3.1-NoManila.zip' *resp* '150 Opening data connection for Solacev3.1-NoManila.zip (51577510 bytes).' Traceback (most recent call last): File "C:/Documents and Settings/owner/Desktop/ftpupload.py", line 9, in <module> ftp.retrbinary('RETR Solacev3.1-NoManila.zip','Solacev3.1-NoManila.zip',100) File "C:\Python26\lib\ftplib.py", line 399, in retrbinary callback(data) TypeError: 'str' object is not callable >>>
Код (Text): def retrbinary(self, cmd, callback, blocksize=8192, rest=None): """Retrieve data in binary mode. A new port is created for you. Args: cmd: A RETR command. callback: A single parameter callable to be called on each block of data read. blocksize: The maximum number of bytes to read from the socket at one time. [default: 8192] rest: Passed to transfercmd(). [default: None] Returns: The response code. """ self.voidcmd('TYPE I') conn = self.transfercmd(cmd, rest) while 1: data = conn.recv(blocksize) if not data: break callback(data) conn.close() return self.voidresp() если я правильно понял, третьим параметром должен быть callable, который пишет принятые данные по назначению. ТС, ты сильно легкой жизни захотел. +)
silno nebeite pa usam, tolko vcera nacil doki citat. kod: Код (Text): #!/bin/env python from ftplib import FTP ftp = FTP('xxxx','xxxx','xxxx') ftp.set_pasv(0) ftp.set_debuglevel(1) ftp.retrlines('LIST') ftp.sendcmd('CWD incoming') ftp.retrlines('LIST') ftp.sendcmd('CWD AVSvideoconverter') ftp.retrlines('LIST') ftp.retrbinary('RETR installation.txt','installation.txt') ftp.quit() paluciaju: Код (Text): >>> ================================ RESTART ================================ >>> *cmd* 'TYPE A' *resp* '200 Type set to A.' *cmd* 'PORT 10,1,25,173,22,177' *resp* '200 Port command successful.' *cmd* 'LIST' *resp* '150 Opening data connection for directory list.' drwxr-xr-x 1 ftp ftp 0 Jul 17 12:09 incoming drwxr-xr-x 1 ftp ftp 0 Jun 29 21:41 photos drwxr-xr-x 1 ftp ftp 0 Jun 25 15:31 public -rw-r--r-- 1 ftp ftp 6148 Jul 04 20:21 .DS_Store *resp* '226 Transfer ok' *cmd* 'CWD incoming' *resp* '250 CWD command successful. "/incoming" is current directory.' *cmd* 'TYPE A' *resp* '200 Type set to A.' *cmd* 'PORT 10,1,25,173,22,179' *resp* '200 Port command successful.' *cmd* 'LIST' *resp* '150 Opening data connection for directory list.' drwxr-xr-x 1 ftp ftp 0 Jun 26 15:37 AVSvideoconverter drwxr-xr-x 1 ftp ftp 0 Jun 26 16:15 CompTIA Security(plus) Deluxe Study Guide drwxr-xr-x 1 ftp ftp 0 Jul 17 11:10 Foto is Raimio gimtadienio *resp* '226 Transfer ok' *cmd* 'CWD AVSvideoconverter' *resp* '250 CWD command successful. "/incoming/AVSvideoconverter" is current directory.' *cmd* 'TYPE A' *resp* '200 Type set to A.' *cmd* 'PORT 10,1,25,173,22,181' *resp* '200 Port command successful.' *cmd* 'LIST' *resp* '150 Opening data connection for directory list.' drwxr-xr-x 1 ftp ftp 0 Jun 26 15:43 CRACK -rwxr-xr-x 1 ftp ftp 52673608 Jun 26 15:37 AVSVideoConverter.exe -rw-r--r-- 1 ftp ftp 1086 Jun 26 15:37 installation.txt -rw-r--r-- 1 ftp ftp 3175 Jun 26 15:37 program info.txt -rw-r--r-- 1 ftp ftp 47 Jun 26 15:37 Torrent downloaded from Demonoid.com.txt *resp* '226 Transfer ok' *cmd* 'TYPE I' *resp* '200 Type set to I.' *cmd* 'PORT 10,1,25,173,22,183' *resp* '200 Port command successful.' *cmd* 'RETR installation.txt' *resp* '150 Opening data connection for installation.txt (1086 bytes).' Traceback (most recent call last): File "C:/Documents and Settings/owner/Desktop/ftpupload.py", line 11, in <module> ftp.retrbinary('RETR installation.txt','installation.txt') File "C:\Python26\lib\ftplib.py", line 399, in retrbinary callback(data) TypeError: 'str' object is not callable >>> sto takoje eto callback? citaju citaju i nedahodit eto fail katorii zapisavat localy?
md5 читай дальше. там все должно быть сказано. А вообще - должно быть примерно так: Код (Text): #!/bin/env python from ftplib import FTP ftp = FTP('xxxx','xxxx','xxxx') ftp.set_pasv(0) ftp.set_debuglevel(1) ftp.retrlines('LIST') ftp.sendcmd('CWD incoming') ftp.retrlines('LIST') ftp.sendcmd('CWD AVSvideoconverter') ftp.retrlines('LIST') [b]with open('installation.txt', "wb") as outfile: ftp.retrbinary('RETR installation.txt', outfile.write) [/b] ftp.quit()