473,399 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Getting the bytes or percent uploaded/downloaded through FTP?

Hi, I'm just wondering if there is any way to get the number of bytes,
or the percentage, that have been uploaded/downloaded when
uploading/downloading a file throught ftp in Python. I have searched
Google many times but could find nothing.

Sep 5 '05 #1
7 2891
Na****@gmail.com wrote:
Hi, I'm just wondering if there is any way to get the number of bytes,
or the percentage, that have been uploaded/downloaded when
uploading/downloading a file throught ftp in Python. I have searched
Google many times but could find nothing.


If you're using urllib you can do something like this:

def reporter(block, block_size, total_size):
left = total_size - block * block_size
sys.stderr.write('\r')
sys.stderr.write('Downloading %s: ' % file_name)
if left > 0: # the estimate is a bit rough, so we fake it a little
sys.stderr.write('%sK left.' % (left/1024))
else:
sys.stderr.write('done.')

# it's possible that this line is shorter than the previous,
# so we need to "erase" any leftovers
sys.stderr.write(' '*10)
sys.stderr.write('\b'*10)

import urllib
urllib.urlretrieve(url, destination, reporter)
sys.stderr.write('\n')
--
Benji York

Sep 5 '05 #2
Thanks, Benji but I need to be able to get the bytes and/or percent of
a download too. :-(

Sep 5 '05 #3
Na****@gmail.com wrote:
Thanks, Benji but I need to be able to get the bytes and/or percent of
a download too. :-(

The only way I can think of to get the size of the file you're about to
download is using the FTP object's .dir() method. If you have the Tools
directory (standard on Windows, with source on other platforms) you can
take a look at the ftpmirror script - a fairly recent version can be seen at

http://weblog.cs.uiowa.edu/python-2....s/ftpmirror.py

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Sep 5 '05 #4
Steve Holden wrote:
The only way I can think of to get the size of the file you're about to
download is using the FTP object's .dir() method. If you have the Tools
directory (standard on Windows, with source on other platforms) you can
take a look at the ftpmirror script - a fairly recent version can be seen at

http://weblog.cs.uiowa.edu/python-2....s/ftpmirror.py


to handle arbitrary servers, you also need a flexibel LIST response
parser; see:

http://cr.yp.to/ftpparse.html

python bindings:

http://c0re.23.nu/c0de/ftpparsemodule/

and

http://effbot.org/downloads/#ftpparse

</F>

Sep 5 '05 #5
Thanks guys. I'll try to these things too work.

Sep 5 '05 #6
Thanks guys. I'll try to these things too work.

Sep 5 '05 #7
Wait, can this be used when uploading a file?

Sep 5 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: John Hunter | last post by:
I have a largish data set (1000 observations x 100 floating point variables), and some of the of the data are missing. I want to try a variety of clustering, neural network, etc, algorithms on the...
1
by: Oleg Ogurok | last post by:
Hi all, I have a page that's long (>400kb) and therefore takes several seconds to download. I want to put either a progress bar or a simple counter that would show how many percent of the page...
1
by: Ron Vecchi | last post by:
I am using asp.net to upload an image and then perform resizing on it and saving the different sizes to file. The resized images were coming up and being displayed in the bowser fine but the image...
0
by: Roland | last post by:
Hello! Firstly, sorry for my poor English... :/ Next, I want to show you my library dll - HttpClient. This library can: - get page - submit form - download and upload file (you can monitor for...
9
by: salil123 | last post by:
How we can keep track of number of bytes downloaded at client side using PHP?. or user has canceled the downloading? so that downloaded bytes can be entered in database can you give me the...
4
by: salil123 | last post by:
Hi I want to know how we can keep track of number bytes downloaded at client side. I want to make a program that will keep track of number of bytes downloaded after downloading is completed....
185
by: jacob navia | last post by:
Hi We are rewriting the libc for the 64 bit version of lcc-win and we have added a new field in the FILE structure: char *FileName; fopen() will save the file name and an accessor function will...
6
by: Author | last post by:
I have VS 2005 professional. Here is the version info: Microsoft Visual Studio 2005 Version 8.0.50727.762 (SP .050727-7600) &copy; 2005 Microsoft Corporation. All rights reserved. When I...
2
dmjpro
by: dmjpro | last post by:
Here is my code import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.net.InetAddress; import java.net.InetSocketAddress;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.