Toasty cleanup
This commit is contained in:
1 parent
c2453bb070
commit
41c2845328
1 file changed
+6
-6
@@ -1,14 +1,16 @@
|
|||||||
from couchpotato.core.helpers.encoding import toUnicode
|
from couchpotato.core.helpers.encoding import toUnicode, tryUrlencode
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.notifications.base import Notification
|
from couchpotato.core.notifications.base import Notification
|
||||||
from httplib import HTTPConnection
|
|
||||||
from urllib import urlencode
|
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
log = CPLog(__name__)
|
log = CPLog(__name__)
|
||||||
|
|
||||||
class Toasty(Notification):
|
class Toasty(Notification):
|
||||||
|
|
||||||
|
urls = {
|
||||||
|
'api': 'http://api.supertoasty.com/notify/%s?%s'
|
||||||
|
}
|
||||||
|
|
||||||
def notify(self, message = '', data = {}, listener = None):
|
def notify(self, message = '', data = {}, listener = None):
|
||||||
if self.isDisabled(): return
|
if self.isDisabled(): return
|
||||||
|
|
||||||
@@ -20,9 +22,7 @@ class Toasty(Notification):
|
|||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
http_handler = HTTPConnection("api.supertoasty.com")
|
self.urlopen(self.urls['api'] % (self.conf('api_key'), tryUrlencode(data)), show_error = False)
|
||||||
http_handler.request("GET", "/notify/"+self.conf('api_key')+"?"+urlencode(data))
|
|
||||||
log.info('Toasty notifications sent.')
|
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
log.error('Toasty failed: %s', traceback.format_exc())
|
log.error('Toasty failed: %s', traceback.format_exc())
|
||||||
|
|||||||
Reference in new issue
Block a user