Python3 + Linted + Switched to requests lib#2
Python3 + Linted + Switched to requests lib#2justinaustin wants to merge 5 commits intosanderjo:masterfrom
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! |
adeak
left a comment
There was a problem hiding this comment.
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.
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.
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 to measure Internet speed with fast.com | ||
| ''' | ||
|
|
||
|
|
There was a problem hiding this comment.
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.
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:
python3flake8requestslib fromurllibandurllib2