Skip to content

Instantly share code, notes, and snippets.

@flowolf
Last active February 22, 2016 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flowolf/94a7bb8bbd060cce6502 to your computer and use it in GitHub Desktop.
Save flowolf/94a7bb8bbd060cce6502 to your computer and use it in GitHub Desktop.
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