Browse Source

Toasty cleanup

pull/1244/head
Ruud 13 years ago
parent
commit
41c2845328
  1. 12
      couchpotato/core/notifications/toasty/main.py

12
couchpotato/core/notifications/toasty/main.py

@ -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())

Loading…
Cancel
Save