Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sum up your transmission uploads
#!/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
You can’t perform that action at this time.