From 9e98d1a26bdaae8115f0c7076326f81a47771237 Mon Sep 17 00:00:00 2001 From: Artem Glebov Date: Sat, 9 Mar 2013 09:49:09 +0300 Subject: [PATCH 1/2] Correctly showing downloads with various statuses Fixed the bug causing an error when a torrent has a status other than 'stopped', 'seeding' or 'downloading'. --- resources/lib/gui.py | 2 +- resources/skins/Default/media/icons/pending.png | Bin 0 -> 4752 bytes 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 resources/skins/Default/media/icons/pending.png diff --git a/resources/lib/gui.py b/resources/lib/gui.py index ab152a1..9d00e7f 100644 --- a/resources/lib/gui.py +++ b/resources/lib/gui.py @@ -87,7 +87,7 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog): 'downloading': 'down.png'} l.setLabel(torrent.name) l.setLabel2(statusline) - l.setProperty('TorrentStatusIcon', statusicons[torrent.status]) + l.setProperty('TorrentStatusIcon', statusicons.get(torrent.status, 'pending.png')) l.setProperty('TorrentID', str(i)) l.setProperty('TorrentProgress', "%.2f" % torrent.progress) l.setInfo('torrent', torrent.fields) diff --git a/resources/skins/Default/media/icons/pending.png b/resources/skins/Default/media/icons/pending.png new file mode 100644 index 0000000000000000000000000000000000000000..f356feb95850f0aec37a7bc76c6b820f0f54d9c0 GIT binary patch literal 4752 zcmYjVc|26#`@b^`lO_8W$p{G_gzS65NS16_GWLB9L$cFCgs~SDBN`b*sAMQx_H4<> zl4URqim@->+wZU6>%PuCuh;WB_de&mpXdF4&N<0uCI-w5=NJG0U`871-2(f#e+^Ct zzS}gNd%=#*<%WSCaQg3g)m)whTFwL++J*oCBgel60iG4|f=2pK68C%EYY>wZI}xEtFya4buHJu9-GGNvQu^Z;w0Q7HSDhzad2#G z?EU-q9|D{RUctdv(jeA-_0WX#a5+fIPIGN-?Xn-25^J`rM8mHXMt}#9&XNBJe7nMx zML!FD)z{JTe>R}U_NWN}mkMo##ocg!dwK_0$l&JTxdVKdn}Nms8?$)%gbIjrKW~L; z^R34604gO99>74e`oWWrgkjK_9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Cc?NcP2lZAra;2spZb01>aQA^yl&U3e< zPW&9&j5Q!C^sj1YkYa+`oqaKG@k0FJS7smxd43UlOdZg93#xsW5OtEk2wP3PDT&L# z-_E-m(Nvr0TJZF4u9~_7rdz1{BUM7BK9@1xRvK{VQThLOFeewbFqMwJE)Pt>yCVR3 L-9)cS*D2wDY_|n& literal 0 HcmV?d00001 From 5a3573b15d4abb8febd3619ca3d3d48818b1eed9 Mon Sep 17 00:00:00 2001 From: Artem Glebov Date: Thu, 14 Mar 2013 08:26:20 +0300 Subject: [PATCH 2/2] Moved the invariant code out of the loop in updateTorrents() --- resources/lib/gui.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/lib/gui.py b/resources/lib/gui.py index 9d00e7f..79df672 100644 --- a/resources/lib/gui.py +++ b/resources/lib/gui.py @@ -19,6 +19,10 @@ KEY_MENU_ID = 92 EXIT_SCRIPT = ( 6, 10, 247, 275, 61467, 216, 257, 61448, ) CANCEL_DIALOG = EXIT_SCRIPT + ( 216, 257, 61448, ) +STATUS_ICONS = {'stopped': 'pause.png', + 'seeding': 'ok.png', + 'downloading': 'down.png'} + class TransmissionGUI(xbmcgui.WindowXMLDialog): def __init__(self, strXMLname, strFallbackPath, strDefaultName, bforeFallback=0): self.list = {} @@ -67,7 +71,7 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog): self.repeater.start() def updateTorrents(self): list = self.getControl(120) - torrents = self.transmission.info() + self.torrents = self.transmission.info() for i, torrent in torrents.iteritems(): statusline = "[%(status)s] %(down)s down (%(pct).2f%%), %(up)s up (Ratio: %(ratio).2f)" % \ {'down': Bytes.format(torrent.downloadedEver), 'pct': torrent.progress, \ @@ -81,13 +85,9 @@ class TransmissionGUI(xbmcgui.WindowXMLDialog): else: # Update existing list item l = self.list[i] - self.torrents = torrents - statusicons = {'stopped': 'pause.png', - 'seeding': 'ok.png', - 'downloading': 'down.png'} l.setLabel(torrent.name) l.setLabel2(statusline) - l.setProperty('TorrentStatusIcon', statusicons.get(torrent.status, 'pending.png')) + l.setProperty('TorrentStatusIcon', STATUS_ICONS.get(torrent.status, 'pending.png')) l.setProperty('TorrentID', str(i)) l.setProperty('TorrentProgress', "%.2f" % torrent.progress) l.setInfo('torrent', torrent.fields)