summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/internal')
-rw-r--r--module/plugins/internal/Account.py2
-rw-r--r--module/plugins/internal/Addon.py2
-rw-r--r--module/plugins/internal/Notifier.py117
-rw-r--r--module/plugins/internal/OCR.py2
-rw-r--r--module/plugins/internal/Plugin.py2
5 files changed, 121 insertions, 4 deletions
diff --git a/module/plugins/internal/Account.py b/module/plugins/internal/Account.py
index f883eb25c..f55ae90ed 100644
--- a/module/plugins/internal/Account.py
+++ b/module/plugins/internal/Account.py
@@ -88,7 +88,7 @@ class Account(Plugin):
self.periodical()
except Exception, e:
- self.log_error(_("Error executing periodical task: %s") % e, trace=True)
+ self.log_error(_("Error performing periodical task"), e)
self.restart_periodical(threaded=threaded, delay=self.interval)
diff --git a/module/plugins/internal/Addon.py b/module/plugins/internal/Addon.py
index 5f2e53bf0..e6de50aaa 100644
--- a/module/plugins/internal/Addon.py
+++ b/module/plugins/internal/Addon.py
@@ -122,7 +122,7 @@ class Addon(Plugin):
self.periodical()
except Exception, e:
- self.log_error(_("Error executing periodical task: %s") % e, trace=True)
+ self.log_error(_("Error performing periodical task"), e)
self.restart_periodical(threaded=threaded, delay=self.interval)
diff --git a/module/plugins/internal/Notifier.py b/module/plugins/internal/Notifier.py
new file mode 100644
index 000000000..f562fb4bf
--- /dev/null
+++ b/module/plugins/internal/Notifier.py
@@ -0,0 +1,117 @@
+# -*- coding: utf-8 -*-
+
+import time
+
+from module.plugins.internal.Notifier import Notifier, Expose
+from module.plugins.internal.utils import isiterable
+
+
+class AndroidPhoneNotify(Notifier):
+ __name__ = "Notifier"
+ __type__ = "hook"
+ __version__ = "0.01"
+ __status__ = "testing"
+
+ __config__ = [("activated" , "bool", "Activated" , False),
+ ("notifycaptcha" , "bool", "Notify captcha request" , True ),
+ ("notifypackage" , "bool", "Notify package finished" , True ),
+ ("notifyprocessed", "bool", "Notify packages processed" , True ),
+ ("notifyupdate" , "bool", "Notify plugin updates" , True ),
+ ("notifyexit" , "bool", "Notify pyLoad shutdown" , True ),
+ ("sendtimewait" , "int" , "Timewait in seconds between notifications", 5 ),
+ ("sendpermin" , "int" , "Max notifications per minute" , 12 ),
+ ("ignoreclient" , "bool", "Send notifications if client is connected", False)]
+
+ __description__ = """Base notifier plugin"""
+ __license__ = "GPLv3"
+ __authors__ = [("Walter Purcaro", "vuolter@gmail.com" )]
+
+
+ def init(self):
+ self.event_map = {'allDownloadsProcessed': "all_downloads_processed",
+ 'plugin_updated' : "plugin_updated" }
+
+ self.last_notify = 0
+ self.notifications = 0
+
+
+ def plugin_updated(self, type_plugins):
+ if not self.get_config('notifyupdate'):
+ return
+
+ self.notify(_("Plugins updated"), str(type_plugins))
+
+
+ def exit(self):
+ if not self.get_config('notifyexit'):
+ return
+
+ if self.pyload.do_restart:
+ self.notify(_("Restarting pyLoad"))
+ else:
+ self.notify(_("Exiting pyLoad"))
+
+
+ def captcha_task(self, task):
+ if not self.get_config('notifycaptcha'):
+ return
+
+ self.notify(_("Captcha"), _("New request waiting user input"))
+
+
+ def package_finished(self, pypack):
+ if self.get_config('notifypackage'):
+ self.notify(_("Package finished"), pypack.name)
+
+
+ def all_downloads_processed(self):
+ if not self.get_config('notifyprocessed'):
+ return
+
+ if any(True for pdata in self.pyload.api.getQueue() if pdata.linksdone < pdata.linkstotal):
+ self.notify(_("Package failed"), _("One or more packages was not completed successfully"))
+ else:
+ self.notify(_("All packages finished"))
+
+
+ def get_key(self):
+ raise NotImplementedError
+
+
+ def send(self, event, msg, key):
+ raise NotImplementedError
+
+
+ @Expose
+ def notify(self, event, msg="", key=None):
+ key = key or self.get_key()
+ if isiterable(key) and all(key) or not key:
+ return
+
+ if self.pyload.isClientConnected() and not self.get_config('ignoreclient'):
+ return
+
+ elapsed_time = time.time() - self.last_notify
+
+ if elapsed_time < self.get_config("sendtimewait"):
+ return
+
+ if elapsed_time > 60:
+ self.notifications = 0
+
+ elif self.notifications >= self.get_config("sendpermin"):
+ return
+
+ try:
+ resp = self.send(event, msg, key)
+
+ except Exception, e:
+ self.log_error(_("Error sending notification"), e)
+ return False
+
+ else:
+ return True
+
+ finally:
+ self.last_notify = time.time()
+ self.notifications += 1
diff --git a/module/plugins/internal/OCR.py b/module/plugins/internal/OCR.py
index 78ad383ca..c783b816f 100644
--- a/module/plugins/internal/OCR.py
+++ b/module/plugins/internal/OCR.py
@@ -137,7 +137,7 @@ class OCR(Plugin):
os.remove(tmpSub.name)
except OSError, e:
- self.log_warning(e, trace=True)
+ self.log_warning(e)
def recognize(self, name):
diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py
index a190c0cb0..9f14855ab 100644
--- a/module/plugins/internal/Plugin.py
+++ b/module/plugins/internal/Plugin.py
@@ -266,7 +266,7 @@ class Plugin(object):
f.write(encode(html))
except IOError, e:
- self.log_error(e, trace=True)
+ self.log_error(e)
finally:
del frame #: Delete the frame or it wont be cleaned