diff options
author | msoulier <msoulier@63283fd4-ec1e-0410-9879-cb7f675518da> | 2008-05-20 02:12:31 +0000 |
---|---|---|
committer | msoulier <msoulier@63283fd4-ec1e-0410-9879-cb7f675518da> | 2008-05-20 02:12:31 +0000 |
commit | 596af4075fe1fb4c051e9f60ef7ef7308f05f4c3 (patch) | |
tree | 71db1d5125a8874ce290024eea4c583f0024f6af /tftpy/TftpClient.py | |
parent | 3b1bae3470180251ee3118ff35756a80cbbdf64b (diff) | |
download | tftpy-596af4075fe1fb4c051e9f60ef7ef7308f05f4c3.tar.gz |
Fixed division by zero error in rate calculations in download function of
client. Thanks to Stefaan Vanheesbeke for the report.
git-svn-id: https://tftpy.svn.sourceforge.net/svnroot/tftpy/trunk@81 63283fd4-ec1e-0410-9879-cb7f675518da
Diffstat (limited to 'tftpy/TftpClient.py')
-rw-r--r-- | tftpy/TftpClient.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tftpy/TftpClient.py b/tftpy/TftpClient.py index 4dd263e..c64245b 100644 --- a/tftpy/TftpClient.py +++ b/tftpy/TftpClient.py @@ -202,15 +202,18 @@ class TftpClient(TftpSession): # end while + outputfile.close() end_time = time.time() duration = end_time - start_time - outputfile.close() - logger.info('') - logger.info("Downloaded %d bytes in %d seconds" % (bytes, duration)) - bps = (bytes * 8.0) / duration - kbps = bps / 1024.0 - logger.info("Average rate: %.2f kbps" % kbps) + if duration == 0: + logger.info("Duration too short, rate undetermined") + else: + logger.info('') + logger.info("Downloaded %d bytes in %d seconds" % (bytes, duration)) + bps = (bytes * 8.0) / duration + kbps = bps / 1024.0 + logger.info("Average rate: %.2f kbps" % kbps) dupcount = 0 for key in dups: dupcount += dups[key] |