Tigge/antfs-cli

Divide By Zero in Progress Bar Callback

Opened this issue · 6 comments

line 278 in garmin.py
eta = datetime.timedelta(seconds=int(delta / new_progress - delta))

if new_progress==0 then you get FP exception
this happens when using the --upload flag, but not when downloading

action required
add conditional to check new_progress!=0
is there a smarter way?

Oh, yes. Nice catch. Either that or modify the ant.fs module a bit to not use the callback when progress is zero. Either should be fine, but it would be nice if the callbacks behaved the same way for both uploads and download.

could use the python package eta, then not have to worry about it. Ill have a look this evening

I'd rather try to avoid adding extra external dependencies, but anyway,
this should be simple enough to fix with an addition if case I think.
Looking quickly in ant/fs/manager.py in the upload method it seems like
this shouldn't happen though.

On 16 January 2014 16:13, MathSter notifications@github.com wrote:

could use the python package eta, then not have to worry about it. Ill
have a look this evening


Reply to this email directly or view it on GitHubhttps://github.com//issues/86#issuecomment-32476911
.

I think Its because upload uses the current chunks offset whereas download uses the total downloaded. For the first chunk the offset is/could be zero?

Yep as it stands it is reporting a progress of zero when uploading the first chuck is complete which is incorrect
line 279 in manage.py should read
callback(float(offset+len(data_packet)) / float(len(data)))
to correctly report the ETA

That looks a bit better, yes. Very good!

On 16 January 2014 17:22, MathSter notifications@github.com wrote:

Yep as it stands it is reporting a progress of zero when uploading the
first chuck is complete which is incorrect
line 279 in manage.py should read
callback(float(offset+len(data_packet)) / float(len(data)))
to correctly report the ETA


Reply to this email directly or view it on GitHubhttps://github.com//issues/86#issuecomment-32484226
.