-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python3 + Linted + Switched to requests lib #2
base: master
Are you sure you want to change the base?
Conversation
Hi Justin, Impressive. Nice to know someone else uses the code. My remarks: Incorrect speed Your code IMHO gives incorrect results:
145 Mbps is impossible on my VDSL-connection. The site https://fast.com/ and my python2 tool report around 35 Mbps. Python2 compatibility I would like to keep the code python2 compatible, because I want it to be stay compatible with sabnzbd and NAS-devices which do have python2. After installing
Do you think that is solvable? |
Hey, I'll check to see about the speed bug. I'll also check about keeping python3 compatibility but I am less confident in that. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few notes on the bug in the implementation and some suggestions about python 2-3 compatibility.
mbps = "%.1f" % net_bits | ||
print("Loop", loop, "Total MB", total_mb, "Delta_MB", delta_mb) | ||
print("Speed kB/s:", speedkBps, "aka Mbps ", mbps) | ||
lasttotal = total |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the source of the bug which leads to a spurious (high) result. This line should be outside the if verbose:
block, semantically speaking I'd put it at the end of the loop, just before time.sleep()
.
time.sleep(sleepseconds) | ||
|
||
Mbps = (application_bytes_to_networkbits(highestspeedkBps)/1024) | ||
Mbps = float("%.1f" % Mbps) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is in the original source code, but while we're here I'd change this to round(Mbps,1)
.
|
||
''' | ||
Python CLI-tool (without need for a GUI) to measure Internet speed with fast.com | ||
|
||
Python CLI-tool to measure Internet speed with fast.com | ||
''' | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest adding from __future__ import print_function, division
in order to get consistent results across python 2 and 3.
@@ -1,8 +1,7 @@ | |||
#!/usr/bin/env python | |||
#!/usr/bin/env python3 | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest adding from __future__ import print_function
here too for full 2-3 compatibility.
I found the bug and posted some suggestions for python 2-3 compatibility. With the above future imports the output should be the same both in python 2 and 3. @sanderjo I can't reproduce the exception you get on 2.7, for me the above runs fine on both 3.6 and 2.7. |
Made the following changes:
python3
flake8
requests
lib fromurllib
andurllib2