Created
December 31, 2013 13:06
-
-
Save chesster/8196518 to your computer and use it in GitHub Desktop.
Transmission status on Conky
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/env python | |
# -*- coding: utf-8 -*- | |
import os | |
def transmission2list(): | |
tsystem_call = "transmission-remote -l" | |
fin,fout = os.popen4(tsystem_call) | |
torrents = fout.read().replace("Up & Down","UpDown").replace("None","0 B").replace("sec"," sec").splitlines()[1:-1] | |
list = [] | |
for torrent in torrents: | |
t = torrent.split() | |
if t[4] == 'Done' or t[4] == 'Unknown' or t[4] == 'Uploading': | |
tt = { | |
"percent" : t[1], | |
"have" : "%s%s" % (t[2], t[3]), | |
"eta" : t[4], | |
"up" : t[5], | |
"down" : t[6], | |
"ratio" : t[7], | |
"status" : t[8], | |
"name" : ' '.join(t[9:]), | |
} | |
else: | |
tt = { | |
"percent" : t[1], | |
"have" : "%s%s" % (t[2], t[3]), | |
"eta" : "%s%s" % (t[4], t[5]), | |
"up" : t[6], | |
"down" : t[7], | |
"ratio" : t[8], | |
"status" : t[9], | |
"name" : ' '.join(t[10:]), | |
} | |
list.append(tt); | |
return list | |
if __name__ == '__main__': | |
icons = { | |
"Unknown": '', | |
"B": '', | |
"Idle": '${font Webdings};${font}', | |
"Stopped": '${font Webdings}<${font}', | |
"UpDown": '${font Webdings}6${font}', | |
"Downloading": '${font Webdings}6${font}', | |
"Seeding": '${font Webdings}5${font}', | |
} | |
leech_string = "${color}%s${color} \n %s ${color1}%s${color} %sKB / %sKB ETA:%s \n ${voffset -5}" | |
seed_string = "${color1}%s${color} \n %s ${color1}%s${color} %sKB / %sKB ETA:%s \n ${voffset -5}" | |
list = transmission2list() | |
if list == []: | |
print("${color0} Brak plikow do pobrania${color}") | |
else: | |
for i in list: | |
if i["status"] == "Seeding": | |
f_string = seed_string | |
else: | |
f_string = leech_string | |
print (f_string) % (i["name"], icons[i["status"]], i["percent"], i["down"], i["up"], i["eta"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment