From e58ca4183db292918e4434b22739761185a74b8d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 11 Feb 2015 04:26:40 +0100 Subject: [AndroidPhoneNotify][WindowsPhoneNotify] Don't use storage --- module/plugins/hooks/WindowsPhoneNotify.py | 96 ++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 module/plugins/hooks/WindowsPhoneNotify.py (limited to 'module/plugins/hooks/WindowsPhoneNotify.py') diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py new file mode 100644 index 000000000..821b9643c --- /dev/null +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- + +import httplib + +from time import time + +from module.plugins.Hook import Hook + + +class WindowsPhoneNotify(Hook): + __name__ = "WindowsPhoneNotify" + __type__ = "hook" + __version__ = "0.06" + + __config__ = [("id" , "str" , "Push ID" , "" ), + ("url" , "str" , "Push url" , "" ), + ("notifycaptcha" , "bool", "Notify captcha request" , True ), + ("notifypackage" , "bool", "Notify package finished" , True ), + ("notifyprocessed", "bool", "Notify processed packages status" , True ), + ("timeout" , "int" , "Timeout between captchas in seconds" , 5 ), + ("force" , "bool", "Send notifications if client is connected", False)] + + __description__ = """Send push notifications to Windows Phone""" + __license__ = "GPLv3" + __authors__ = [("Andy Voigt", "phone-support@hotmail.de"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + event_list = ["allDownloadsProcessed"] + + + #@TODO: Remove in 0.4.10 + def initPeriodical(self): + pass + + + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + self.last_notify = 0 + + + def newCaptchaTask(self, task): + if not self.getConfig("notifycaptcha"): + return False + + if time() - self.last_notify < self.getConf("timeout"): + return False + + self.notify(_("Captcha"), _("New request waiting user input")) + + + def packageFinished(self, pypack): + if self.getConfig("notifypackage"): + self.notify(_("Package finished"), pypack.name) + + + def allDownloadsProcessed(self): + if not self.getConfig("notifyprocessed"): + return False + + if any(True for pdata in self.core.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 getXmlData(self, msg): + return (" " + " pyLoad %s " + " " % msg) + + + def notify(self, event, msg=""): + id = self.getConfig("id") + url = self.getConfig("url") + + if not id or not url: + return False + + if self.core.isClientConnected() and not self.getConfig("force"): + return False + + request = self.getXmlData("%s: %s" % (event, msg) if msg else event) + webservice = httplib.HTTP(url) + + webservice.putrequest("POST", id) + webservice.putheader("Host", url) + webservice.putheader("Content-type", "text/xml") + webservice.putheader("X-NotificationClass", "2") + webservice.putheader("X-WindowsPhone-Target", "toast") + webservice.putheader("Content-length", "%d" % len(request)) + webservice.endheaders() + webservice.send(request) + webservice.close() + + self.last_notify = time() -- cgit v1.2.3 From ee6746b16c8f56d24f48f55387fee799d8e28b4d Mon Sep 17 00:00:00 2001 From: Stefano Date: Wed, 11 Feb 2015 18:40:04 +0100 Subject: [UpdateManager] Bump version number to refresh broken plugins See #1168 --- module/plugins/hooks/WindowsPhoneNotify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/WindowsPhoneNotify.py') diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index 821b9643c..e0dd75f92 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -10,7 +10,7 @@ from module.plugins.Hook import Hook class WindowsPhoneNotify(Hook): __name__ = "WindowsPhoneNotify" __type__ = "hook" - __version__ = "0.06" + __version__ = "0.07" __config__ = [("id" , "str" , "Push ID" , "" ), ("url" , "str" , "Push url" , "" ), -- cgit v1.2.3 From db330ae85f9de5a9a19c7141c1a2d6877e02e7da Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 8 Mar 2015 23:32:11 +0100 Subject: Update notify addon --- module/plugins/hooks/WindowsPhoneNotify.py | 52 ++++++++++++++++++------------ 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'module/plugins/hooks/WindowsPhoneNotify.py') diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index e0dd75f92..010198bf1 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -1,29 +1,29 @@ # -*- coding: utf-8 -*- import httplib +import time -from time import time - -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, Expose class WindowsPhoneNotify(Hook): __name__ = "WindowsPhoneNotify" __type__ = "hook" - __version__ = "0.07" + __version__ = "0.08" __config__ = [("id" , "str" , "Push ID" , "" ), ("url" , "str" , "Push url" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), ("notifypackage" , "bool", "Notify package finished" , True ), - ("notifyprocessed", "bool", "Notify processed packages status" , True ), - ("timeout" , "int" , "Timeout between captchas in seconds" , 5 ), - ("force" , "bool", "Send notifications if client is connected", False)] + ("notifyprocessed", "bool", "Notify status of processed packages" , 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__ = """Send push notifications to Windows Phone""" __license__ = "GPLv3" - __authors__ = [("Andy Voigt", "phone-support@hotmail.de"), - ("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("Andy Voigt" , "phone-support@hotmail.de"), + ("Walter Purcaro", "vuolter@gmail.com" )] event_list = ["allDownloadsProcessed"] @@ -35,16 +35,14 @@ class WindowsPhoneNotify(Hook): def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - self.last_notify = 0 + self.info = {} #@TODO: Remove in 0.4.10 + self.last_notify = 0 + self.notifications = 0 def newCaptchaTask(self, task): if not self.getConfig("notifycaptcha"): - return False - - if time() - self.last_notify < self.getConf("timeout"): - return False + return self.notify(_("Captcha"), _("New request waiting user input")) @@ -56,7 +54,7 @@ class WindowsPhoneNotify(Hook): def allDownloadsProcessed(self): if not self.getConfig("notifyprocessed"): - return False + return if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): self.notify(_("Package failed"), _("One or more packages was not completed successfully")) @@ -70,15 +68,28 @@ class WindowsPhoneNotify(Hook): " " % msg) + @Expose def notify(self, event, msg=""): id = self.getConfig("id") url = self.getConfig("url") if not id or not url: - return False + return + + if self.core.isClientConnected() and not self.getConfig("ignoreclient"): + return + + elapsed_time = time.time() - self.last_notify + + if elapsed_time < self.getConf("sendtimewait"): + return + + if elapsed_time > 60: + self.notifications = 0 + + elif self.notifications >= self.getConf("sendpermin"): + return - if self.core.isClientConnected() and not self.getConfig("force"): - return False request = self.getXmlData("%s: %s" % (event, msg) if msg else event) webservice = httplib.HTTP(url) @@ -93,4 +104,5 @@ class WindowsPhoneNotify(Hook): webservice.send(request) webservice.close() - self.last_notify = time() + self.last_notify = time.time() + self.notifications += 1 -- cgit v1.2.3 From 7beb65e991bc6d1913c3b5bb2ef69e659d5b8342 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 01:55:52 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/WindowsPhoneNotify.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'module/plugins/hooks/WindowsPhoneNotify.py') diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index 010198bf1..a1068ead5 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -41,19 +41,19 @@ class WindowsPhoneNotify(Hook): def newCaptchaTask(self, task): - if not self.getConfig("notifycaptcha"): + if not self.getConfig('notifycaptcha'): return self.notify(_("Captcha"), _("New request waiting user input")) def packageFinished(self, pypack): - if self.getConfig("notifypackage"): + if self.getConfig('notifypackage'): self.notify(_("Package finished"), pypack.name) def allDownloadsProcessed(self): - if not self.getConfig("notifyprocessed"): + if not self.getConfig('notifyprocessed'): return if any(True for pdata in self.core.api.getQueue() if pdata.linksdone < pdata.linkstotal): @@ -69,14 +69,17 @@ class WindowsPhoneNotify(Hook): @Expose - def notify(self, event, msg=""): - id = self.getConfig("id") - url = self.getConfig("url") + def notify(self, + event, + msg="", + key=(self.getConfig('id'), self.getConfig('url'))): + + id, url = key if not id or not url: return - if self.core.isClientConnected() and not self.getConfig("ignoreclient"): + if self.core.isClientConnected() and not self.getConfig('ignoreclient'): return elapsed_time = time.time() - self.last_notify -- cgit v1.2.3 From d070742d8e4aebe59797a1ea86b51f9eb25915b4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 18 Mar 2015 13:31:58 +0100 Subject: [AndroidPhoneNotify][WindowsPhoneNotify] New notifications --- module/plugins/hooks/WindowsPhoneNotify.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks/WindowsPhoneNotify.py') diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index a1068ead5..d8215f9fe 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -9,13 +9,15 @@ from module.plugins.Hook import Hook, Expose class WindowsPhoneNotify(Hook): __name__ = "WindowsPhoneNotify" __type__ = "hook" - __version__ = "0.08" + __version__ = "0.09" __config__ = [("id" , "str" , "Push ID" , "" ), ("url" , "str" , "Push url" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), ("notifypackage" , "bool", "Notify package finished" , True ), - ("notifyprocessed", "bool", "Notify status of processed packages" , 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)] @@ -26,7 +28,7 @@ class WindowsPhoneNotify(Hook): ("Walter Purcaro", "vuolter@gmail.com" )] - event_list = ["allDownloadsProcessed"] + event_list = ["allDownloadsProcessed", "plugin_updated"] #@TODO: Remove in 0.4.10 @@ -40,6 +42,23 @@ class WindowsPhoneNotify(Hook): self.notifications = 0 + def plugin_updated(self, type_plugins): + if not self.getConfig('notifyupdate'): + return + + self.notify(_("Plugins updated"), str(type_plugins)) + + + def coreExiting(self): + if not self.getConfig('notifyexit'): + return + + if self.core.do_restart: + self.notify(_("Restarting pyLoad")) + else: + self.notify(_("Exiting pyLoad")) + + def newCaptchaTask(self, task): if not self.getConfig('notifycaptcha'): return -- cgit v1.2.3 From f1ce338ed31e49373cea5453a2fbdb6c686ca510 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 26 Mar 2015 10:16:04 +0100 Subject: interval code cosmetics --- module/plugins/hooks/WindowsPhoneNotify.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'module/plugins/hooks/WindowsPhoneNotify.py') diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index d8215f9fe..e61057f9f 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -29,11 +29,7 @@ class WindowsPhoneNotify(Hook): event_list = ["allDownloadsProcessed", "plugin_updated"] - - - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): -- cgit v1.2.3 From 9d0fef4d50c9f46daf00e50814a57b3000097ac8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 27 May 2015 23:17:33 +0200 Subject: Fix https://github.com/pyload/pyload/issues/1428 --- module/plugins/hooks/WindowsPhoneNotify.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'module/plugins/hooks/WindowsPhoneNotify.py') diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index e61057f9f..da960591c 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -9,10 +9,10 @@ from module.plugins.Hook import Hook, Expose class WindowsPhoneNotify(Hook): __name__ = "WindowsPhoneNotify" __type__ = "hook" - __version__ = "0.09" + __version__ = "0.10" - __config__ = [("id" , "str" , "Push ID" , "" ), - ("url" , "str" , "Push url" , "" ), + __config__ = [("push-id" , "str" , "Push ID" , "" ), + ("push-url" , "str" , "Push url" , "" ), ("notifycaptcha" , "bool", "Notify captcha request" , True ), ("notifypackage" , "bool", "Notify package finished" , True ), ("notifyprocessed", "bool", "Notify packages processed" , True ), @@ -45,6 +45,10 @@ class WindowsPhoneNotify(Hook): self.notify(_("Plugins updated"), str(type_plugins)) + def coreReady(self): + self.key = (self.getConfig('push-id'), self.getConfig('push-url')) + + def coreExiting(self): if not self.getConfig('notifyexit'): return @@ -87,10 +91,9 @@ class WindowsPhoneNotify(Hook): def notify(self, event, msg="", - key=(self.getConfig('id'), self.getConfig('url'))): - - id, url = key + key=(None, None)): + id, url = key or self.key if not id or not url: return @@ -108,7 +111,6 @@ class WindowsPhoneNotify(Hook): elif self.notifications >= self.getConf("sendpermin"): return - request = self.getXmlData("%s: %s" % (event, msg) if msg else event) webservice = httplib.HTTP(url) @@ -124,3 +126,5 @@ class WindowsPhoneNotify(Hook): self.last_notify = time.time() self.notifications += 1 + + return True -- cgit v1.2.3 From 9f3ab57ec994deb24cd31a1dfbd338eb71bffc8c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 27 May 2015 23:46:29 +0200 Subject: Spare code cosmetics --- module/plugins/hooks/WindowsPhoneNotify.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/WindowsPhoneNotify.py') diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index da960591c..8f66761f6 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -28,12 +28,14 @@ class WindowsPhoneNotify(Hook): ("Walter Purcaro", "vuolter@gmail.com" )] - event_list = ["allDownloadsProcessed", "plugin_updated"] interval = 0 #@TODO: Remove in 0.4.10 def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + self.info = {} #@TODO: Remove in 0.4.10 + + self.event_list = ["allDownloadsProcessed", "plugin_updated"] + self.last_notify = 0 self.notifications = 0 -- cgit v1.2.3