ftplib

ftplib progress bar

有些话、适合烂在心里 提交于 2019-12-11 04:32:11
问题 When I run the script it closes the terminal. I want to print and display a message and also to see that it has completed. Maybe a status bar? import ftplib from ftplib import FTP ftp_add = input('ftp address:') username = input('username:') password = input('password:') ftp = FTP(ftp_add) ftp.login(username, password) ftp.retrlines('LIST') ftp.cwd("/public_html") file_list = [] filenames = ftp.nlst() ftp.close() 来源: https://stackoverflow.com/questions/43404660/ftplib-progress-bar

ftplib file select

牧云@^-^@ 提交于 2019-12-11 02:02:40
问题 Manual says To download a file, use ftp.retrlines('RETR ' + filename) Here is what i do: ftp.retrbinary('RETR media/backups/andrey.txt', open("file_to_get.txt", 'a+').write) Could please someone advise how to put filename variable, previously added via raw_input, after the "RETR" command? Used %s but this does not work, it gets processed like a part of a filename. ftp.retrbinary('RETR %s', open("file_to_get.txt", 'a+').write) %raw_input("print file name") produces this: c:\>python ftp_client

Python ftplib: low download & upload speeds when using python ftplib

我与影子孤独终老i 提交于 2019-12-10 19:59:08
问题 I was wondering if any one observed that the time taken to download or upload a file over ftp using Python's ftplib is very large as compared to performing FTP get/put over windows command prompt or using Perl's Net::FTP module. I created a simple FTP client similar to http://code.activestate.com/recipes/521925-python-ftp-client/ but I am unable to attain the speed which I get when running FTP at the Windows DOS prompt or using perl. Is there something I am missing or is it a problem with the

threaded 'NOOP' command during retrbinary

送分小仙女□ 提交于 2019-12-10 18:54:01
问题 I've written an FTP script that must unfortunately deal with a server that's behind a firewall. The ISP also cuts of my control connection quite early, no matter what kind of timeout settings I might set on either side of the firewall. I've finally come to two choices. 1) fork the code at the retrbinary command so that a 'NOOP' is sent every n seconds while the download completes, or 2) fork the code at the retrbinary command so that the script compares the local file's size against the

Why is a success message considered an error in ftplib

核能气质少年 提交于 2019-12-10 18:06:10
问题 import ftplib server = '192.168.1.109' user = 'bob' password = 'likes_sandwiches' box = ftplib.FTP(server) box.login(user, password) s = box.mkd('\\a\\this4\\') box.close() x = raw_input('done, eat sandwiches now') This returns: Traceback (most recent call last): File "C:\scripts\ftp_test.py", line 25, in s = box.mkd('\E\this4\') File "C:\Python26\lib\ftplib.py", line 553, in mkd return parse257(resp) File "C:\Python26\lib\ftplib.py", line 651, in parse257 raise error_reply, resp error_reply:

ftp sending python bytesio stream

浪尽此生 提交于 2019-12-10 12:56:43
问题 I want to send a file with python ftplib, from one ftp site to another, so to avoid file read/write processees. I create a BytesIO stream: myfile=BytesIO() And i succesfully retrieve a image file from ftp site one with retrbinary: ftp_one.retrbinary('RETR P1090080.JPG', myfile.write) I can save this memory object to a regular file: fot=open('casab.jpg', 'wb') fot=myfile.readvalue() But i am not able to send this stream via ftp with storbinary. I thought this would work: ftp_two.storbinary(

How do I parse a listing of files to get just the filenames in Python?

荒凉一梦 提交于 2019-12-09 06:42:52
问题 So lets say I'm using Python's ftplib to retrieve a list of log files from an FTP server. How would I parse that list of files to get just the file names (the last column) inside a list? See the link above for example output. 回答1: Using retrlines() probably isn't the best idea there, since it just prints to the console and so you'd have to do tricky things to even get at that output. A likely better bet would be to use the nlst() method, which returns exactly what you want: a list of the file

ftplib - file creation very slow: SSLError: The read operation timed out

假装没事ソ 提交于 2019-12-09 03:35:27
import ftplib import csv import StringIO sio = StringIO.StringIO() data = csv.writer(sio) data.writerows(data_to_export) sio.seek(0) ftps.storbinary("STOR " + 'blah.csv', sio) ftps.close() So the file I'm creating is only 56 lines, it creates very slowly. And when it finishes creating, I get this error: ftps.storbinary("STOR " + 'blah.csv', sio) File "/usr/lib/python2.7/ftplib.py", line 752, in storbinary conn.unwrap() File "/usr/lib/python2.7/ssl.py", line 384, in unwrap s = self._sslobj.shutdown() SSLError: The read operation timed out I don't get it why it is so slow and why it gives time

Error 0 when using ftplib

心已入冬 提交于 2019-12-08 13:02:33
问题 I am trying to download files using python's ftplib and I am running in an issue. When I run the script on my computer I am getting an error: Traceback (most recent call last): File "ftp_get.py", line 20, in <module> ftps.retrbinary('RETR '+ filename, file.write) File "C:\Python27\lib\ftplib.py", line 710, in retrbinary conn.unwrap() File "C:\Python27\lib\ssl.py", line 771, in unwrap s = self._sslobj.shutdown() socket.error: [Errno 0] Error But when I run it on a server, it works flawlessly.

ftplib - file creation very slow: SSLError: The read operation timed out

杀马特。学长 韩版系。学妹 提交于 2019-12-08 08:38:58
问题 import ftplib import csv import StringIO sio = StringIO.StringIO() data = csv.writer(sio) data.writerows(data_to_export) sio.seek(0) ftps.storbinary("STOR " + 'blah.csv', sio) ftps.close() So the file I'm creating is only 56 lines, it creates very slowly. And when it finishes creating, I get this error: ftps.storbinary("STOR " + 'blah.csv', sio) File "/usr/lib/python2.7/ftplib.py", line 752, in storbinary conn.unwrap() File "/usr/lib/python2.7/ssl.py", line 384, in unwrap s = self._sslobj