summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/internal/Addon.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-20 02:30:23 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-20 02:30:23 +0100
commita12a8f46cd4c6fd0974bbfdb79df07cdd3aed543 (patch)
tree76ebf345666e6a7e074f540ee232c8f3056188fb /pyload/plugins/internal/Addon.py
parentsetuptools support (diff)
downloadpyload-a12a8f46cd4c6fd0974bbfdb79df07cdd3aed543.tar.xz
[Addon] Periodical default to off
Diffstat (limited to 'pyload/plugins/internal/Addon.py')
-rw-r--r--pyload/plugins/internal/Addon.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/pyload/plugins/internal/Addon.py b/pyload/plugins/internal/Addon.py
index e0be3097e..b126b97d6 100644
--- a/pyload/plugins/internal/Addon.py
+++ b/pyload/plugins/internal/Addon.py
@@ -37,14 +37,11 @@ class Addon(Base):
#: automatically register event listeners for functions, attribute will be deleted dont use it yourself
- event_map = None
+ event_map = {}
# Alternative to event_map
#: List of events the plugin can handle, name the functions exactly like eventname.
- event_list = None # dont make duplicate entries in event_map
-
- #: periodic call interval in secondc
- interval = 60
+ event_list = [] #@NOTE: dont make duplicate entries in event_map
def __init__(self, core, manager):
@@ -55,6 +52,7 @@ class Addon(Base):
#: Callback of periodical job task, used by AddonManager
self.cb = None
+ self.interval = -1 #: disabled
#: `AddonManager`
self.manager = manager
@@ -78,23 +76,28 @@ class Addon(Base):
self.event_list = None
self.setup()
+
self.initPeriodical()
- def initPeriodical(self):
- if self.interval >=1:
- self.cb = self.core.scheduler.addJob(0, self._periodical, threaded=False)
+ def initPeriodical(self, delay=0, threaded=False):
+ self.cb = self.core.scheduler.addJob(delay, self._periodical, args=[threaded], threaded=threaded)
+
+
+ def _periodical(self, threaded):
+ if self.interval < 0:
+ self.cb = None
+ return
- def _periodical(self):
try:
- if self.isActivated():
- self.periodical()
+ self.periodical()
+
except Exception, e:
self.logError(_("Error executing addon: %s") % e)
if self.core.debug:
print_exc()
- self.cb = self.core.scheduler.addJob(self.interval, self._periodical, threaded=False)
+ self.cb = self.core.scheduler.addJob(self.interval, self._periodical, threaded=threaded)
def __repr__(self):