Author: andar
Revision: 5366
Log:
Get the blocklist plugin kind of working.. Still needs some lovin'.
Diff:
Modified: trunk/deluge/core/core.py
===================================================================
--- trunk/deluge/core/core.py 2009-06-10 03:08:41 UTC (rev 5365)
+++ trunk/deluge/core/core.py 2009-06-10 03:42:33 UTC (rev 5366)
@@ -591,11 +591,11 @@
self.ip_filter.add_rule(range[0], range[1], 1)
# Start a 2 second timer (and remove the previous one if it exists)
- #if self.__set_ip_filter_timer:
- # self.__set_ip_filter_timer.stop()
+ if self.__set_ip_filter_timer:
+ self.__set_ip_filter_timer.stop()
- #self.__set_ip_filter_timer = LoopingCall(self.session.set_ip_filter,
self.ip_filter)
- #self.__set_ip_filter_timer.start(2, False)
+ self.__set_ip_filter_timer = LoopingCall(self.session.set_ip_filter,
self.ip_filter)
+ self.__set_ip_filter_timer.start(2, False)
@export
def reset_ip_filter(self):
Modified: trunk/deluge/plugins/blocklist/blocklist/core.py
===================================================================
--- trunk/deluge/plugins/blocklist/blocklist/core.py 2009-06-10 03:08:41 UTC
(rev 5365)
+++ trunk/deluge/plugins/blocklist/blocklist/core.py 2009-06-10 03:42:33 UTC
(rev 5366)
@@ -33,15 +33,15 @@
#
#
-
-import threading
import urllib
import os
import datetime
-import gobject
import time
import shutil
+from twisted.internet.task import LoopingCall
+from twisted.internet import reactor
+
from deluge.log import LOG as log
from deluge.plugins.pluginbase import CorePluginBase
import deluge.component as component
@@ -91,9 +91,8 @@
# This function is called every 'check_after_days' days, to download
# and import a new list if needed.
- self.update_timer = gobject.timeout_add(
- self.config["check_after_days"] * 24 * 60 * 60 * 1000,
- self.download_blocklist, True)
+ self.update_timer = LoopingCall(self.download_blocklist)
+ self.update_timer.start(self.config["check_after_days"] * 24 * 60 * 60)
def disable(self):
log.debug("Reset IP Filter..")
@@ -114,7 +113,7 @@
def import_list(self, force=False):
"""Import the blocklist from the blocklist.cache, if load is True, then
it will download the blocklist file if needed."""
- threading.Thread(target=self.import_blocklist, kwargs={"force":
force}).start()
+ reactor.callInThread(self.import_blocklist, force=force)
@export()
def get_config(self):
@@ -222,16 +221,10 @@
return
self.is_downloading = True
- threading.Thread(
- target=self.download_blocklist_thread,
- args=(self.on_download_blocklist, load)).start()
+ reactor.callInThread(self.download_blocklist_thread,
self.on_download_blocklist, load)
def download_blocklist_thread(self, callback, load):
"""Downloads the blocklist specified by 'url' in the config"""
- def _call_callback(callback, load):
- callback(load)
- return False
-
def on_retrieve_data(count, block_size, total_blocks):
fp = float(count * block_size) / total_blocks
if fp > 1.0:
@@ -256,7 +249,7 @@
log.debug("Blocklist successfully downloaded..")
self.config["file_date"] =
datetime.datetime.strptime(headers["last-modified"],"%a, %d %b %Y %H:%M:%S
GMT").ctime()
self.config["file_size"] = long(headers["content-length"])
- gobject.idle_add(_call_callback, callback, load)
+ reactor.callLater(0, callback, load)
return
def need_new_blocklist(self):
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---