summaryrefslogtreecommitdiffstats
path: root/module/interaction
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-12 12:49:42 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-12 12:49:42 +0100
commit6232db5a1d3b8b5e4412af67d5bc7ca65f94333c (patch)
tree02a95e1216ace355d84a9704fb9070bd744b17c2 /module/interaction
parentadded missing file (diff)
downloadpyload-6232db5a1d3b8b5e4412af67d5bc7ca65f94333c.tar.xz
renamed most events, push events to webui
Diffstat (limited to 'module/interaction')
-rw-r--r--module/interaction/EventManager.py80
1 files changed, 11 insertions, 69 deletions
diff --git a/module/interaction/EventManager.py b/module/interaction/EventManager.py
index 976a92413..b25514b6a 100644
--- a/module/interaction/EventManager.py
+++ b/module/interaction/EventManager.py
@@ -2,9 +2,6 @@
from threading import Lock
from traceback import print_exc
-from time import time
-
-from module.utils import lock
class EventManager:
"""
@@ -16,30 +13,25 @@ class EventManager:
===================== ================ ===========================================================
Name Arguments Description
===================== ================ ===========================================================
- metaEvent eventName, *args Called for every event, with eventName and original args
- downloadPreparing fid A download was just queued and will be prepared now.
- downloadStarts fid A plugin will immediately start the download afterwards.
- linksAdded links, pid Someone just added links, you are able to modify these links.
- allDownloadsProcessed All links were handled, pyLoad would idle afterwards.
- allDownloadsFinished All downloads in the queue are finished.
- unrarFinished folder, fname An Unrar job finished
- configChanged sec, opt, value The config was changed.
+ event eventName, *args Called for every event, with eventName and original args
+ download:preparing fid A download was just queued and will be prepared now.
+ download:start fid A plugin will immediately start the download afterwards.
+ download:allProcessed All links were handled, pyLoad would idle afterwards.
+ download:allFinished All downloads in the queue are finished.
+ config:changed sec, opt, value The config was changed.
===================== ================ ===========================================================
| Notes:
- | allDownloadsProcessed is *always* called before allDownloadsFinished.
- | configChanged is *always* called before pluginConfigChanged.
+ | download:allProcessed is *always* called before download:allFinished.
"""
- CLIENT_EVENTS = ("packageUpdated", "packageInserted", "linkUpdated", "packageDeleted")
-
def __init__(self, core):
self.core = core
self.log = core.log
# uuid : list of events
self.clients = {}
- self.events = {"metaEvent": []}
+ self.events = {"event": []}
self.lock = Lock()
@@ -66,12 +58,12 @@ class EventManager:
def dispatchEvent(self, event, *args):
"""dispatches event with args"""
- for f in self.events["metaEvent"]:
+ for f in self.events["event"]:
try:
f(event, *args)
except Exception, e:
self.log.warning("Error calling event handler %s: %s, %s, %s"
- % ("metaEvent", f, args, str(e)))
+ % ("event", f, args, str(e)))
if self.core.debug:
print_exc()
@@ -83,54 +75,4 @@ class EventManager:
self.log.warning("Error calling event handler %s: %s, %s, %s"
% (event, f, args, str(e)))
if self.core.debug:
- print_exc()
-
- self.updateClients(event, args)
-
- @lock
- def updateClients(self, event, args):
- # append to client event queue
- if event in self.CLIENT_EVENTS:
- for uuid, client in self.clients.items():
- if client.delete():
- del self.clients[uuid]
- else:
- client.append(event, args)
-
- def removeFromEvents(self, func):
- """ Removes func from all known events """
- for name, events in self.events.iteritems():
- if func in events:
- events.remove(func)
-
-
-
-class Client:
-
- # delete clients after this time
- TIMEOUT = 60 * 60
- # max events, if this value is reached you should assume that older events were dropped
- MAX = 30
-
- def __init__(self):
- self.lastActive = time()
- self.events = []
-
- def delete(self):
- return self.lastActive + self.TIMEOUT < time()
-
- def append(self, event, args):
- ev = (event, args)
- if ev not in self.events:
- self.events.insert(0, ev)
-
- del self.events[self.MAX:]
-
-
- def get(self):
- self.lastActive = time()
-
- events = self.events
- self.events = []
-
- return [(ev, [str(x) for x in args]) for ev, args in events] \ No newline at end of file
+ print_exc() \ No newline at end of file