From 984c4f820325662e9f6125d7c4c0a71ebcd4d070 Mon Sep 17 00:00:00 2001 From: Martijn Voncken Date: Wed, 22 Oct 2008 16:08:53 +0000 Subject: [PATCH] webui : use TrackerIcons class --- deluge/tests/test_tracker_icons.py | 5 +++-- deluge/tracker_icons.py | 5 ++--- deluge/ui/webui/pages.py | 18 ++++++++++++++++++ .../templates/classic/part_label_filters.html | 2 +- .../templates/white/part_label_filters.html | 4 ++-- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/deluge/tests/test_tracker_icons.py b/deluge/tests/test_tracker_icons.py index 297ff8707..0e4e253bf 100644 --- a/deluge/tests/test_tracker_icons.py +++ b/deluge/tests/test_tracker_icons.py @@ -11,12 +11,13 @@ def del_old(): os.remove(filename) def test_get(): - del_old() + #del_old() trackericons = TrackerIcons() + print trackericons.images print trackericons.get("unknown2") print trackericons.get("google.com") print trackericons.get("legaltorrents.com") - time.sleep(1.0) + time.sleep(5.0) print trackericons.get("legaltorrents.com") def callback1(value): diff --git a/deluge/tracker_icons.py b/deluge/tracker_icons.py index d35d0e5cf..f8832f578 100644 --- a/deluge/tracker_icons.py +++ b/deluge/tracker_icons.py @@ -90,9 +90,9 @@ class TrackerIcons(object): def get_async(self, tracker_host, callback): if tracker_host in self.images: - if callback: - callback(self.images[tracker_host]) + callback(self.images[tracker_host]) else: + self.images[tracker_host] = None threading.Thread(target=self. _fetch_icon_thread, args=(tracker_host, callback)).start() @@ -103,7 +103,6 @@ class TrackerIcons(object): if tracker_host in self.images: return self.images[tracker_host] else: - self.images[tracker_host] = None self.get_async(tracker_host, None) return None diff --git a/deluge/ui/webui/pages.py b/deluge/ui/webui/pages.py index c75d8b545..b9f0c2c46 100644 --- a/deluge/ui/webui/pages.py +++ b/deluge/ui/webui/pages.py @@ -51,6 +51,7 @@ import os from deluge import component from deluge.ui.client import sclient as proxy from deluge.configmanager import ConfigManager +from deluge.tracker_icons import TrackerIcons page_manager = component.get("PageManager") config = ConfigManager("webui06.conf") @@ -447,6 +448,23 @@ class pixmaps: print content route("/pixmaps/(.*)", pixmaps) + +class tracker_icon: + tracker_icons = TrackerIcons() + def GET(self, name): + filename = self.tracker_icons.get(name) + if filename: + log.debug("file-name=%s" % name) + web.header("Cache-Control" , "public, must-revalidate, max-age=86400") + web.header("Content-Type", "image/x-icon") + data = open(filename, "rb").read() + print data + else: + log.debug("not found:%s" % name) + web.header("Content-Type", "image/x-icon") + +route("/tracker/icon/(.*)", tracker_icon) + class close: "close open window" @deco.deluge_page diff --git a/deluge/ui/webui/templates/classic/part_label_filters.html b/deluge/ui/webui/templates/classic/part_label_filters.html index 85708d5e8..27b6873c1 100644 --- a/deluge/ui/webui/templates/classic/part_label_filters.html +++ b/deluge/ui/webui/templates/classic/part_label_filters.html @@ -22,7 +22,7 @@ $for cat in filter_items.keys(): $if cat == "state": $if cat == "tracker_host": - + $if not value: $if cat == "label": $_("No Label") ($count) diff --git a/deluge/ui/webui/templates/white/part_label_filters.html b/deluge/ui/webui/templates/white/part_label_filters.html index 6e86b3f46..06e69e7a3 100644 --- a/deluge/ui/webui/templates/white/part_label_filters.html +++ b/deluge/ui/webui/templates/white/part_label_filters.html @@ -43,9 +43,9 @@ $for cat in filter_items.keys(): > $if cat == "state": - + $if cat == "tracker_host": - + $if not value: $if cat == "label": $_("No Label") ($count)