Last active
February 22, 2016 12:34
-
-
Save flowolf/94a7bb8bbd060cce6502 to your computer and use it in GitHub Desktop.
Sum up your transmission uploads
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# tested with transmission-remote 2.51 (13280) | |
# call like: | |
# $ transmission-remote -l | ./sum_up.py | |
# units: https://en.wikipedia.org/wiki/Megabyte | |
import sys | |
total = 0 | |
input = sys.stdin | |
for l in input: | |
#print l[:-1] | |
line = l.split() | |
if line[0] == "Sum:": | |
continue | |
if line[0] == "ID": | |
continue | |
sum = float(line[2]) * float(line[7]) | |
if(line[3] == "GB"): | |
sum = sum * 1000 | |
total = total + sum | |
t_KB = total * 1000 | |
t_KiB = total * 1000000 / 1024 | |
print str(t_KB / 1000) + " MB \t" + str(t_KiB / 1024) + " MiB" | |
print str(t_KB / 1000000) + " GB \t" + str(t_KiB / 1024**2) + " GiB" | |
print str(t_KB / 1000000000) + " TB \t" + str(t_KiB / 1024**3) + " TiB" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment