tanzpartner Posted November 21, 2021 Share Posted November 21, 2021 (edited) Hi there, my green conscience was getting seriously hurt every time I used a website to calculate how long an upload would take. So I took the time and wrote a little Python script that I'm running from an Alfred workflow. My keyword trigger is "ct" followed by a number that represents the amount of data in gigabytes. I use round numbers because I only care about roughly knowing how long it takes. Not a precise time, which isn't even possible because transmission speed can vary. If anyone is interested, here is the python code, you can paste it into the "Run script" block in the workflow editor. Adjust the "Transfer_Speed" to whatever your upload speed is in KBbs, mine is roughly 4500 KBps (my ISP claims it's 5000, but you know what that means...). I would call the Alfred Input Window and type ct 10 and hit enter, then I will see the result in large type. #!/usr/bin/python import sys import math # This script calculates upload time # # Upload speed is 4500 KB / sec Transfer_Speed = 4500 # This is the input argument from Alfred Workflow Data_Amount = float(int(sys.argv[1])) # Calculate the time Transfer_Time = round((((Data_Amount * 1000000) / Transfer_Speed) / 60), 2) Transfer_Hours = math.trunc(Transfer_Time / 60) Transfer_Minutes = round((Transfer_Time - (Transfer_Hours * 60)), 2) # Create the output query = str(Transfer_Hours) + " Hours and " + str(Transfer_Minutes) + " Minutes" sys.stdout.write(query) Enjoy and have a good Sunday. Hans Edited November 21, 2021 by tanzpartner Link to comment
vitor Posted November 21, 2021 Share Posted November 21, 2021 17 minutes ago, tanzpartner said: Adjust the "Transfer_Speed" to whatever your upload speed is in KBbs, mine is roughly 4500 KBps (my ISP claims it's 5000, but you know what that means...). Worth noting Monterey has a new networkQuality command-line tool which measures this. Link to comment
tanzpartner Posted November 21, 2021 Author Share Posted November 21, 2021 16 minutes ago, vitor said: Worth noting Monterey has a new networkQuality command-line tool which measures this. Thanks! But that kind of defeats the green aspect of calculating locally without creating network traffic resulting in energy use. I know it's a small contribution, but I want to do more of these little tasks locally without network use. YMMV of course. Link to comment
vitor Posted November 21, 2021 Share Posted November 21, 2021 To clarify, I’m not suggesting you do that on every script run. Rather, it is a suggestion to whoever comes into your post later on, so they have a quick way to measure the value to change in your code without needing to rely on a third-party speediest website. Oh, and welcome to the forums! tanzpartner 1 Link to comment
tanzpartner Posted November 21, 2021 Author Share Posted November 21, 2021 Sorry. Forum dynamic got the better of me. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now