1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

Backport from https://github.com/thezoggy/Sick-Beard, applied to our branch

General cleanups in notifiers.

* Cleaned up notifier ui page wording so they follow similar pattern.
* Better exception handling for pyTivo and NMJ
* Cleaned up logging entries, trying to standardize on what level we report and verbiage (not using contractions, prune out duplicate/excessive entries)
This commit is contained in:
Nils Vogels 2014-05-29 02:30:38 +02:00
parent 894e533330
commit 0e34c8c4b3
15 changed files with 97 additions and 88 deletions

View File

@ -19,9 +19,9 @@
<form id="configForm" action="saveNotifications" method="post"> <form id="configForm" action="saveNotifications" method="post">
<div id="config-components"> <div id="config-components">
<ul> <ul>
<li><a href="#tabs-1">Home Theater</a></li> <li><a href="#tabs-1">Home Theater / NAS</a></li>
<li><a href="#tabs-2">Devices</a></li> <li><a href="#tabs-2">Devices</a></li>
<li><a href="#tabs-3">Online</a></li> <li><a href="#tabs-3">Social</a></li>
</ul> </ul>
<div id="tabs-1"> <div id="tabs-1">
@ -381,7 +381,8 @@
<div class="component-group clearfix"> <div class="component-group clearfix">
<div class="component-group-desc"> <div class="component-group-desc">
<h3><a href="http://synology.com/" rel="noreferrer" onclick="window.open('${sickbeard.ANON_REDIRECT}' + this.href, '_blank'); return false;"><img src="$sbRoot/images/notifiers/synoindex.png" alt="" title="Synology Indexer"/> Synology Indexer </a></h3> <h3><a href="http://synology.com/" rel="noreferrer" onclick="window.open('${sickbeard.ANON_REDIRECT}' + this.href, '_blank'); return false;"><img src="$sbRoot/images/notifiers/synoindex.png" alt="" title="Synology"/> Synology </a></h3>
<p>The Synology DiskStation NAS.</p>
<p>Synology Indexer is the daemon running on the Synology NAS to build its media database.</p> <p>Synology Indexer is the daemon running on the Synology NAS to build its media database.</p>
</div> </div>
@ -390,7 +391,7 @@
<input type="checkbox" class="enabler" name="use_synoindex" id="use_synoindex" #if $sickbeard.USE_SYNOINDEX then "checked=\"checked\"" else ""# /> <input type="checkbox" class="enabler" name="use_synoindex" id="use_synoindex" #if $sickbeard.USE_SYNOINDEX then "checked=\"checked\"" else ""# />
<label class="clearfix" for="use_synoindex"> <label class="clearfix" for="use_synoindex">
<span class="component-title">Enable</span> <span class="component-title">Enable</span>
<span class="component-desc">Should SickRage send notifications to the synoindex daemon?<br /><br /> <span class="component-desc">Should SickRage send Synology notifications?<br /><br />
</span> </span>
</label> </label>
<label class="nocheck clearfix" for="use_synoindex"> <label class="nocheck clearfix" for="use_synoindex">
@ -457,7 +458,7 @@
<div class="component-group clearfix"> <div class="component-group clearfix">
<div class="component-group-desc"> <div class="component-group-desc">
<h3><a href="http://pytivo.sourceforge.net/wiki/index.php/PyTivo" rel="noreferrer" onclick="window.open('${sickbeard.ANON_REDIRECT}' + this.href, '_blank'); return false;"><img src="$sbRoot/images/notifiers/pytivo.png" alt="" title="pyTivo"/> pyTivo </a></h3> <h3><a href="http://pytivo.sourceforge.net/wiki/index.php/PyTivo" rel="noreferrer" onclick="window.open('${sickbeard.ANON_REDIRECT}' + this.href, '_blank'); return false;"><img src="$sbRoot/images/notifiers/pytivo.png" alt="" title="pyTivo"/> pyTivo </a></h3>
<p>pyTivo is both an HMO and GoBack server. This notifier will load the completed downloads to your Tivo.</p> <p>pyTivo is both an HMO and GoBack server. This notifier will load the completed downloads to your Tivo.</p>
</div> </div>
<fieldset class="component-group-list"> <fieldset class="component-group-list">
<div class="field-pair"> <div class="field-pair">
@ -708,7 +709,7 @@
<input type="checkbox" class="enabler" name="use_pushover" id="use_pushover" #if $sickbeard.USE_PUSHOVER then "checked=\"checked\"" else ""# /> <input type="checkbox" class="enabler" name="use_pushover" id="use_pushover" #if $sickbeard.USE_PUSHOVER then "checked=\"checked\"" else ""# />
<label class="clearfix" for="use_pushover"> <label class="clearfix" for="use_pushover">
<span class="component-title">Enable</span> <span class="component-title">Enable</span>
<span class="component-desc">Should SickRage send notifications through Pushover?</span> <span class="component-desc">Should SickRage send Pushover notifications?</span>
</label> </label>
</div> </div>
@ -755,14 +756,14 @@
<div class="component-group clearfix"> <div class="component-group clearfix">
<div class="component-group-desc"> <div class="component-group-desc">
<h3><a href="http://boxcar.io/" rel="noreferrer" onclick="window.open('${sickbeard.ANON_REDIRECT}' + this.href, '_blank'); return false;"><img src="$sbRoot/images/notifiers/boxcar.png" alt="" title="Boxcar"/> Boxcar </a></h3> <h3><a href="http://boxcar.io/" rel="noreferrer" onclick="window.open('${sickbeard.ANON_REDIRECT}' + this.href, '_blank'); return false;"><img src="$sbRoot/images/notifiers/boxcar.png" alt="" title="Boxcar"/> Boxcar </a></h3>
<p>Read your messages where and when you want them! A subscription will be send if needed.</p> <p>Universal push notification for iOS. Read your messages where and when you want them! A subscription will be sent if needed.</p>
</div> </div>
<fieldset class="component-group-list"> <fieldset class="component-group-list">
<div class="field-pair"> <div class="field-pair">
<input type="checkbox" class="enabler" name="use_boxcar" id="use_boxcar" #if $sickbeard.USE_BOXCAR then "checked=\"checked\"" else ""# /> <input type="checkbox" class="enabler" name="use_boxcar" id="use_boxcar" #if $sickbeard.USE_BOXCAR then "checked=\"checked\"" else ""# />
<label class="clearfix" for="use_boxcar"> <label class="clearfix" for="use_boxcar">
<span class="component-title">Enable</span> <span class="component-title">Enable</span>
<span class="component-desc">Should SickRage send notifications through Boxcar?</span> <span class="component-desc">Should SickRage send Boxcar notifications?</span>
</label> </label>
</div> </div>
@ -816,7 +817,7 @@
<input type="checkbox" class="enabler" name="use_boxcar2" id="use_boxcar2" #if $sickbeard.USE_BOXCAR2 then "checked=\"checked\"" else ""# /> <input type="checkbox" class="enabler" name="use_boxcar2" id="use_boxcar2" #if $sickbeard.USE_BOXCAR2 then "checked=\"checked\"" else ""# />
<label class="clearfix" for="use_boxcar2"> <label class="clearfix" for="use_boxcar2">
<span class="component-title">Enable</span> <span class="component-title">Enable</span>
<span class="component-desc">Should SickRage send notifications through Boxcar2?</span> <span class="component-desc">Should SickRage Boxcar2 notifications?</span>
</label> </label>
</div> </div>
@ -940,7 +941,7 @@
<input type="checkbox" class="enabler" name="use_pushalot" id="use_pushalot" #if $sickbeard.USE_PUSHALOT then "checked=\"checked\"" else ""# /> <input type="checkbox" class="enabler" name="use_pushalot" id="use_pushalot" #if $sickbeard.USE_PUSHALOT then "checked=\"checked\"" else ""# />
<label class="clearfix" for="use_pushalot"> <label class="clearfix" for="use_pushalot">
<span class="component-title">Enable</span> <span class="component-title">Enable</span>
<span class="component-desc">Should SickRage send notifications through Pushalot?</span> <span class="component-desc">Should SickRage send Pushalot notifications?</span>
</label> </label>
</div> </div>
@ -994,7 +995,7 @@
<input type="checkbox" class="enabler" name="use_pushbullet" id="use_pushbullet" #if $sickbeard.USE_PUSHBULLET then "checked=\"checked\"" else ""# /> <input type="checkbox" class="enabler" name="use_pushbullet" id="use_pushbullet" #if $sickbeard.USE_PUSHBULLET then "checked=\"checked\"" else ""# />
<label class="clearfix" for="use_pushbullet"> <label class="clearfix" for="use_pushbullet">
<span class="component-title">Enable</span> <span class="component-title">Enable</span>
<span class="component-desc">Should SickRage send notifications through Pushbullet?</span> <span class="component-desc">Should SickRage send Pushbullet notifications?</span>
</label> </label>
</div> </div>

View File

@ -42,7 +42,7 @@ import emailnotify
from sickbeard.common import * from sickbeard.common import *
# home theater # home theater / nas
xbmc_notifier = xbmc.XBMCNotifier() xbmc_notifier = xbmc.XBMCNotifier()
plex_notifier = plex.PLEXNotifier() plex_notifier = plex.PLEXNotifier()
nmj_notifier = nmj.NMJNotifier() nmj_notifier = nmj.NMJNotifier()
@ -60,7 +60,7 @@ boxcar2_notifier = boxcar2.Boxcar2Notifier()
nma_notifier = nma.NMA_Notifier() nma_notifier = nma.NMA_Notifier()
pushalot_notifier = pushalot.PushalotNotifier() pushalot_notifier = pushalot.PushalotNotifier()
pushbullet_notifier = pushbullet.PushbulletNotifier() pushbullet_notifier = pushbullet.PushbulletNotifier()
# online # social
twitter_notifier = tweet.TwitterNotifier() twitter_notifier = tweet.TwitterNotifier()
trakt_notifier = trakt.TraktNotifier() trakt_notifier = trakt.TraktNotifier()
email_notifier = emailnotify.EmailNotifier() email_notifier = emailnotify.EmailNotifier()

View File

@ -30,8 +30,8 @@ API_URL = "https://boxcar.io/devices/providers/fWc4sgSmpcN6JujtBmR6/notification
class BoxcarNotifier: class BoxcarNotifier:
def test_notify(self, email, title="Test"): def test_notify(self, boxcar_username):
return self._sendBoxcar("This is a test notification from SickRage", title, email) return self._notify("This is a test notification from Sick Beard", "Test", boxcar_username, force=True)
def _sendBoxcar(self, msg, title, email, subscribe=False): def _sendBoxcar(self, msg, title, email, subscribe=False):
""" """
@ -73,7 +73,7 @@ class BoxcarNotifier:
except urllib2.HTTPError, e: except urllib2.HTTPError, e:
# if we get an error back that doesn't have an error code then who knows what's really happening # if we get an error back that doesn't have an error code then who knows what's really happening
if not hasattr(e, 'code'): if not hasattr(e, 'code'):
logger.log("Boxcar notification failed." + ex(e), logger.ERROR) logger.log("Boxcar notification failed. Error code: " + ex(e), logger.ERROR)
return False return False
else: else:
logger.log("Boxcar notification failed. Error code: " + str(e.code), logger.WARNING) logger.log("Boxcar notification failed. Error code: " + str(e.code), logger.WARNING)
@ -104,10 +104,10 @@ class BoxcarNotifier:
# If you receive an HTTP status code of 400, it is because you failed to send the proper parameters # If you receive an HTTP status code of 400, it is because you failed to send the proper parameters
elif e.code == 400: elif e.code == 400:
logger.log("Wrong data send to boxcar", logger.ERROR) logger.log("Wrong data sent to boxcar", logger.ERROR)
return False return False
logger.log("Boxcar notification successful.", logger.DEBUG) logger.log("Boxcar notification successful.", logger.MESSAGE)
return True return True
def notify_snatch(self, ep_name, title=notifyStrings[NOTIFY_SNATCH]): def notify_snatch(self, ep_name, title=notifyStrings[NOTIFY_SNATCH]):
@ -143,8 +143,7 @@ class BoxcarNotifier:
logger.log("Sending notification for " + message, logger.DEBUG) logger.log("Sending notification for " + message, logger.DEBUG)
self._sendBoxcar(message, title, username) return self._sendBoxcar(message, title, username)
return True
notifier = BoxcarNotifier notifier = BoxcarNotifier

View File

@ -127,7 +127,7 @@ class GrowlNotifier:
for pc in growlHosts: for pc in growlHosts:
opts['host'] = pc[0] opts['host'] = pc[0]
opts['port'] = pc[1] opts['port'] = pc[1]
logger.log(u"Sending growl to " + opts['host'] + ":" + str(opts['port']) + ": " + message) logger.log(u"GROWL: Sending message '" + message + "' to " + opts['host'] + ":" + str(opts['port']), logger.DEBUG)
try: try:
if self._send_growl(opts, message): if self._send_growl(opts, message):
return True return True
@ -136,8 +136,8 @@ class GrowlNotifier:
return self._send_growl(opts, message) return self._send_growl(opts, message)
else: else:
return False return False
except socket.error, e: except Exception, e:
logger.log(u"Unable to send growl to " + opts['host'] + ":" + str(opts['port']) + ": " + ex(e)) logger.log(u"GROWL: Unable to send growl to " + opts['host'] + ":" + str(opts['port']) + " - " + ex(e), logger.WARNING)
return False return False
def _sendRegistration(self, host=None, password=None, name='SickRage Notification'): def _sendRegistration(self, host=None, password=None, name='SickRage Notification'):
@ -179,10 +179,9 @@ class GrowlNotifier:
try: try:
return self._send(opts['host'], opts['port'], register.encode(), opts['debug']) return self._send(opts['host'], opts['port'], register.encode(), opts['debug'])
except socket.error, e: except Exception, e:
logger.log( logger.log(u"GROWL: Unable to send growl to " + opts['host'] + ":" + str(opts['port']) + " - " + ex(e), logger.WARNING)
u"Unable to send growl to " + opts['host'] + ":" + str(opts['port']) + ": " + str(e).decode('utf-8'))
return False return False
notifier = GrowlNotifier notifier = GrowlNotifier

View File

@ -67,15 +67,15 @@ class LibnotifyNotifier:
try: try:
import pynotify import pynotify
except ImportError: except ImportError:
logger.log(u"Unable to import pynotify. libnotify notifications won't work.") logger.log(u"Unable to import pynotify. libnotify notifications won't work.", logger.ERROR)
return False return False
try: try:
import gobject import gobject
except ImportError: except ImportError:
logger.log(u"Unable to import gobject. We can't catch a GError in display.") logger.log(u"Unable to import gobject. We can't catch a GError in display.", logger.ERROR)
return False return False
if not pynotify.init('SickRage'): if not pynotify.init('SickRage'):
logger.log(u"Initialization of pynotify failed. libnotify notifications won't work.") logger.log(u"Initialization of pynotify failed. libnotify notifications won't work.", logger.ERROR)
return False return False
self.pynotify = pynotify self.pynotify = pynotify
self.gobject = gobject self.gobject = gobject

View File

@ -26,7 +26,7 @@ class NMA_Notifier:
def _sendNMA(self, nma_api=None, nma_priority=None, event=None, message=None, force=False): def _sendNMA(self, nma_api=None, nma_priority=None, event=None, message=None, force=False):
title = 'Sick-Beard' title = 'SickRage'
if not sickbeard.USE_NMA and not force: if not sickbeard.USE_NMA and not force:
return False return False
@ -37,10 +37,6 @@ class NMA_Notifier:
if nma_priority == None: if nma_priority == None:
nma_priority = sickbeard.NMA_PRIORITY nma_priority = sickbeard.NMA_PRIORITY
logger.log(u"NMA title: " + title, logger.DEBUG)
logger.log(u"NMA event: " + event, logger.DEBUG)
logger.log(u"NMA message: " + message, logger.DEBUG)
batch = False batch = False
p = pynma.PyNMA() p = pynma.PyNMA()
@ -49,13 +45,15 @@ class NMA_Notifier:
if len(keys) > 1: batch = True if len(keys) > 1: batch = True
logger.log("NMA: Sending notice with details: event=\"%s\", message=\"%s\", priority=%s, batch=%s" % (event, message, nma_priority, batch), logger.DEBUG)
response = p.push(title, event, message, priority=nma_priority, batch_mode=batch) response = p.push(title, event, message, priority=nma_priority, batch_mode=batch)
if not response[nma_api][u'code'] == u'200': if not response[nma_api][u'code'] == u'200':
logger.log(u'Could not send notification to NotifyMyAndroid', logger.ERROR) logger.log(u'Could not send notification to NotifyMyAndroid', logger.ERROR)
return False return False
else: else:
logger.log(u"NMA: Notification sent to NotifyMyAndroid", logger.MESSAGE)
return True return True
notifier = NMA_Notifier notifier = NMA_Notifier

View File

@ -22,6 +22,7 @@ import telnetlib
import re import re
from sickbeard import logger from sickbeard import logger
from sickbeard.exceptions import ex
try: try:
import xml.etree.cElementTree as etree import xml.etree.cElementTree as etree
@ -44,7 +45,7 @@ class NMJNotifier:
try: try:
terminal = telnetlib.Telnet(host) terminal = telnetlib.Telnet(host)
except Exception: except Exception:
logger.log(u"Warning: unable to get a telnet session to %s" % (host), logger.ERROR) logger.log(u"Warning: unable to get a telnet session to %s" % (host), logger.WARNING)
return False return False
# tell the terminal to output the necessary info to the screen so we can search it later # tell the terminal to output the necessary info to the screen so we can search it later
@ -66,7 +67,7 @@ class NMJNotifier:
logger.log(u"Found NMJ database %s on device %s" % (database, device), logger.DEBUG) logger.log(u"Found NMJ database %s on device %s" % (database, device), logger.DEBUG)
sickbeard.NMJ_DATABASE = database sickbeard.NMJ_DATABASE = database
else: else:
logger.log(u"Could not get current NMJ database on %s, NMJ is probably not running!" % (host), logger.ERROR) logger.log(u"Could not get current NMJ database on %s, NMJ is probably not running!" % (host), logger.WARNING)
return False return False
# if the device is a remote host then try to parse the mounting URL and save it to the config # if the device is a remote host then try to parse the mounting URL and save it to the config
@ -79,7 +80,7 @@ class NMJNotifier:
sickbeard.NMJ_MOUNT = mount sickbeard.NMJ_MOUNT = mount
else: else:
logger.log(u"Detected a network share on the Popcorn Hour, but could not get the mounting url", logger.log(u"Detected a network share on the Popcorn Hour, but could not get the mounting url",
logger.DEBUG) logger.WARNING)
return False return False
return True return True
@ -117,7 +118,13 @@ class NMJNotifier:
logger.log(u"Try to mount network drive via url: %s" % (mount), logger.DEBUG) logger.log(u"Try to mount network drive via url: %s" % (mount), logger.DEBUG)
handle = urllib2.urlopen(req) handle = urllib2.urlopen(req)
except IOError, e: except IOError, e:
logger.log(u"Warning: Couldn't contact popcorn hour on host %s: %s" % (host, e)) if hasattr(e, 'reason'):
logger.log(u"NMJ: Could not contact Popcorn Hour on host %s: %s" % (host, e.reason), logger.WARNING)
elif hasattr(e, 'code'):
logger.log(u"NMJ: Problem with Popcorn Hour on host %s: %s" % (host, e.code), logger.WARNING)
return False
except Exception, e:
logger.log(u"NMJ: Unknown exception: " + ex(e), logger.ERROR)
return False return False
# build up the request URL and parameters # build up the request URL and parameters
@ -126,7 +133,8 @@ class NMJNotifier:
"arg0": "scanner_start", "arg0": "scanner_start",
"arg1": database, "arg1": database,
"arg2": "background", "arg2": "background",
"arg3": ""} "arg3": ""
}
params = urllib.urlencode(params) params = urllib.urlencode(params)
updateUrl = UPDATE_URL % {"host": host, "params": params} updateUrl = UPDATE_URL % {"host": host, "params": params}
@ -137,7 +145,13 @@ class NMJNotifier:
handle = urllib2.urlopen(req) handle = urllib2.urlopen(req)
response = handle.read() response = handle.read()
except IOError, e: except IOError, e:
logger.log(u"Warning: Couldn't contact Popcorn Hour on host %s: %s" % (host, e)) if hasattr(e, 'reason'):
logger.log(u"NMJ: Could not contact Popcorn Hour on host %s: %s" % (host, e.reason), logger.WARNING)
elif hasattr(e, 'code'):
logger.log(u"NMJ: Problem with Popcorn Hour on host %s: %s" % (host, e.code), logger.WARNING)
return False
except Exception, e:
logger.log(u"NMJ: Unknown exception: " + ex(e), logger.ERROR)
return False return False
# try to parse the resulting XML # try to parse the resulting XML
@ -150,10 +164,10 @@ class NMJNotifier:
# if the result was a number then consider that an error # if the result was a number then consider that an error
if int(result) > 0: if int(result) > 0:
logger.log(u"Popcorn Hour returned an errorcode: %s" % (result)) logger.log(u"Popcorn Hour returned an errorcode: %s" % (result), logger.ERROR)
return False return False
else: else:
logger.log(u"NMJ started background scan") logger.log(u"NMJ started background scan", logger.MESSAGE)
return True return True
def _notifyNMJ(self, host=None, database=None, mount=None, force=False): def _notifyNMJ(self, host=None, database=None, mount=None, force=False):

View File

@ -87,7 +87,7 @@ class NMJv2Notifier:
return True return True
except IOError, e: except IOError, e:
logger.log(u"Warning: Couldn't contact popcorn hour on host %s: %s" % (host, e)) logger.log(u"Warning: Couldn't contact popcorn hour on host %s: %s" % (host, e), logger.WARNING)
return False return False
return False return False
@ -105,7 +105,7 @@ class NMJv2Notifier:
#if a host is provided then attempt to open a handle to that URL #if a host is provided then attempt to open a handle to that URL
try: try:
url_scandir = "http://" + host + ":8008/metadata_database?arg0=update_scandir&arg1=" + sickbeard.NMJv2_DATABASE + "&arg2=&arg3=update_all" url_scandir = "http://" + host + ":8008/metadata_database?arg0=update_scandir&arg1=" + sickbeard.NMJv2_DATABASE + "&arg2=&arg3=update_all"
logger.log(u"NMJ scan update command send to host: %s" % (host)) logger.log(u"NMJ scan update command sent to host: %s" % (host), logger.DEBUG)
url_updatedb = "http://" + host + ":8008/metadata_database?arg0=scanner_start&arg1=" + sickbeard.NMJv2_DATABASE + "&arg2=background&arg3=" url_updatedb = "http://" + host + ":8008/metadata_database?arg0=scanner_start&arg1=" + sickbeard.NMJv2_DATABASE + "&arg2=background&arg3="
logger.log(u"Try to mount network drive via url: %s" % (host), logger.DEBUG) logger.log(u"Try to mount network drive via url: %s" % (host), logger.DEBUG)
prereq = urllib2.Request(url_scandir) prereq = urllib2.Request(url_scandir)
@ -116,7 +116,7 @@ class NMJv2Notifier:
handle2 = urllib2.urlopen(req) handle2 = urllib2.urlopen(req)
response2 = handle2.read() response2 = handle2.read()
except IOError, e: except IOError, e:
logger.log(u"Warning: Couldn't contact popcorn hour on host %s: %s" % (host, e)) logger.log(u"Warning: Couldn't contact popcorn hour on host %s: %s" % (host, e), logger.WARNING)
return False return False
try: try:
et = etree.fromstring(response1) et = etree.fromstring(response1)
@ -142,15 +142,15 @@ class NMJv2Notifier:
"Read only file system"] "Read only file system"]
if int(result1) > 0: if int(result1) > 0:
index = error_codes.index(result1) index = error_codes.index(result1)
logger.log(u"Popcorn Hour returned an error: %s" % (error_messages[index])) logger.log(u"Popcorn Hour returned an error: %s" % (error_messages[index]), logger.ERROR)
return False return False
else: else:
if int(result2) > 0: if int(result2) > 0:
index = error_codes.index(result2) index = error_codes.index(result2)
logger.log(u"Popcorn Hour returned an error: %s" % (error_messages[index])) logger.log(u"Popcorn Hour returned an error: %s" % (error_messages[index]), logger.ERROR)
return False return False
else: else:
logger.log(u"NMJv2 started background scan") logger.log(u"NMJv2 started background scan", logger.MESSAGE)
return True return True
def _notifyNMJ(self, host=None, force=False): def _notifyNMJ(self, host=None, force=False):

View File

@ -82,7 +82,7 @@ class PLEXNotifier(XBMCNotifier):
if sickbeard.USE_PLEX and sickbeard.PLEX_UPDATE_LIBRARY: if sickbeard.USE_PLEX and sickbeard.PLEX_UPDATE_LIBRARY:
if not sickbeard.PLEX_SERVER_HOST: if not sickbeard.PLEX_SERVER_HOST:
logger.log(u"No Plex Server host specified, check your settings", logger.DEBUG) logger.log(u"No Plex Media Server host specified, check your settings", logger.DEBUG)
return False return False
logger.log(u"Updating library for the Plex Media Server host: " + sickbeard.PLEX_SERVER_HOST, logger.log(u"Updating library for the Plex Media Server host: " + sickbeard.PLEX_SERVER_HOST,

View File

@ -65,11 +65,7 @@ class ProwlNotifier:
title = "SickRage" title = "SickRage"
logger.log(u"Prowl title: " + title, logger.DEBUG) logger.log("PROWL: Sending notice with details: event=\"%s\", message=\"%s\", priority=%s, api=%s" % (event, message, prowl_priority, prowl_api), logger.DEBUG)
logger.log(u"Prowl event: " + event, logger.DEBUG)
logger.log(u"Prowl message: " + message, logger.DEBUG)
logger.log(u"Prowl api: " + prowl_api, logger.DEBUG)
logger.log(u"Prowl priority: " + prowl_priority, logger.DEBUG)
http_handler = HTTPSConnection("api.prowlapp.com") http_handler = HTTPSConnection("api.prowlapp.com")
@ -91,7 +87,7 @@ class ProwlNotifier:
request_status = response.status request_status = response.status
if request_status == 200: if request_status == 200:
logger.log(u"Prowl notifications sent.", logger.DEBUG) logger.log(u"Prowl notifications sent.", logger.MESSAGE)
return True return True
elif request_status == 401: elif request_status == 401:
logger.log(u"Prowl auth failed: %s" % response.reason, logger.ERROR) logger.log(u"Prowl auth failed: %s" % response.reason, logger.ERROR)

View File

@ -33,7 +33,7 @@ API_KEY = "awKfdt263PLaEWV9RXuSn4c46qoAyA"
class PushoverNotifier: class PushoverNotifier:
def test_notify(self, userKey=None): def test_notify(self, userKey=None):
return self._sendPushover("This is a test notification from SickRage", 'Test', userKey) return self._notifyPushover("This is a test notification from SickRage", 'Test', userKey, force=True)
def _sendPushover(self, msg, title, userKey=None): def _sendPushover(self, msg, title, userKey=None):
""" """
@ -74,7 +74,7 @@ class PushoverNotifier:
logger.log("Pushover notification failed." + ex(e), logger.ERROR) logger.log("Pushover notification failed." + ex(e), logger.ERROR)
return False return False
else: else:
logger.log("Pushover notification failed. Error code: " + str(e.code), logger.WARNING) logger.log("Pushover notification failed. Error code: " + str(e.code), logger.ERROR)
# HTTP status 404 if the provided email address isn't a Pushover user. # HTTP status 404 if the provided email address isn't a Pushover user.
if e.code == 404: if e.code == 404:
@ -98,7 +98,7 @@ class PushoverNotifier:
logger.log("Wrong data sent to pushover", logger.ERROR) logger.log("Wrong data sent to pushover", logger.ERROR)
return False return False
logger.log("Pushover notification successful.", logger.DEBUG) logger.log("Pushover notification successful.", logger.MESSAGE)
return True return True
def notify_snatch(self, ep_name, title=notifyStrings[NOTIFY_SNATCH]): def notify_snatch(self, ep_name, title=notifyStrings[NOTIFY_SNATCH]):
@ -114,24 +114,24 @@ class PushoverNotifier:
if sickbeard.PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD: if sickbeard.PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD:
self._notifyPushover(title, ep_name + ": " + lang) self._notifyPushover(title, ep_name + ": " + lang)
def _notifyPushover(self, title, message, userKey=None): def _notifyPushover(self, title, message, userKey=None, force=False):
""" """
Sends a pushover notification based on the provided info or SB config Sends a pushover notification based on the provided info or SB config
title: The title of the notification to send title: The title of the notification to send
message: The message string to send message: The message string to send
userKey: The userKey to send the notification to userKey: The userKey to send the notification to
force: Enforce sending, for instance for testing
""" """
if not sickbeard.USE_PUSHOVER: if not sickbeard.USE_PUSHOVER and not force:
logger.log("Notification for Pushover not enabled, skipping this notification", logger.DEBUG) logger.log("Notification for Pushover not enabled, skipping this notification", logger.DEBUG)
return False return False
logger.log("Sending notification for " + message, logger.DEBUG) logger.log("Sending notification for " + message, logger.DEBUG)
# self._sendPushover(message, title, userKey) # self._sendPushover(message, title, userKey)
self._sendPushover(message, title) return self._sendPushover(message, title)
return True
notifier = PushoverNotifier notifier = PushoverNotifier

View File

@ -23,6 +23,7 @@ from urllib import urlencode
from urllib2 import Request, urlopen, HTTPError from urllib2 import Request, urlopen, HTTPError
from sickbeard import logger from sickbeard import logger
from sickbeard.exceptions import ex
from sickbeard import encodingKludge as ek from sickbeard import encodingKludge as ek
@ -81,7 +82,7 @@ class pyTivoNotifier:
requestUrl = "http://" + host + "/TiVoConnect?" + urlencode( requestUrl = "http://" + host + "/TiVoConnect?" + urlencode(
{'Command': 'Push', 'Container': container, 'File': file, 'tsn': tsn}) {'Command': 'Push', 'Container': container, 'File': file, 'tsn': tsn})
logger.log(u"pyTivo notification: Requesting " + requestUrl) logger.log(u"pyTivo notification: Requesting " + requestUrl, logger.DEBUG)
request = Request(requestUrl) request = Request(requestUrl)
@ -89,13 +90,14 @@ class pyTivoNotifier:
response = urlopen(request) #@UnusedVariable response = urlopen(request) #@UnusedVariable
except HTTPError , e: except HTTPError , e:
if hasattr(e, 'reason'): if hasattr(e, 'reason'):
logger.log(u"pyTivo notification: Error, failed to reach a server") logger.log(u"pyTivo notification: Error, failed to reach a server - " + e.reason, logger.ERROR)
logger.log(u"'Error reason: " + e.reason)
return False return False
elif hasattr(e, 'code'): elif hasattr(e, 'code'):
logger.log(u"pyTivo notification: Error, the server couldn't fulfill the request") logger.log(u"pyTivo notification: Error, the server couldn't fulfill the request - ", + e.code, logger.ERROR)
logger.log(u"Error code: " + e.code) return False
return False except Exception, e:
logger.log(u"PYTIVO: Unknown exception: " + ex(e), logger.ERROR)
return False
else: else:
logger.log(u"pyTivo notification: Successfully requested transfer of file") logger.log(u"pyTivo notification: Successfully requested transfer of file")
return True return True

View File

@ -48,7 +48,7 @@ class synoIndexNotifier:
if sickbeard.USE_SYNOINDEX: if sickbeard.USE_SYNOINDEX:
synoindex_cmd = ['/usr/syno/bin/synoindex', '-N', ek.ek(os.path.abspath, new_path), synoindex_cmd = ['/usr/syno/bin/synoindex', '-N', ek.ek(os.path.abspath, new_path),
ek.ek(os.path.abspath, old_path)] ek.ek(os.path.abspath, old_path)]
logger.log(u"Executing command " + str(synoindex_cmd)) logger.log(u"Executing command " + str(synoindex_cmd), logger.DEBUG)
logger.log(u"Absolute path to command: " + ek.ek(os.path.abspath, synoindex_cmd[0]), logger.DEBUG) logger.log(u"Absolute path to command: " + ek.ek(os.path.abspath, synoindex_cmd[0]), logger.DEBUG)
try: try:
p = subprocess.Popen(synoindex_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, p = subprocess.Popen(synoindex_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
@ -56,7 +56,7 @@ class synoIndexNotifier:
out, err = p.communicate() #@UnusedVariable out, err = p.communicate() #@UnusedVariable
logger.log(u"Script result: " + str(out), logger.DEBUG) logger.log(u"Script result: " + str(out), logger.DEBUG)
except OSError, e: except OSError, e:
logger.log(u"Unable to run synoindex: " + ex(e)) logger.log(u"Unable to run synoindex: " + ex(e), logger.ERROR)
def deleteFolder(self, cur_path): def deleteFolder(self, cur_path):
self.makeObject('-D', cur_path) self.makeObject('-D', cur_path)
@ -73,7 +73,7 @@ class synoIndexNotifier:
def makeObject(self, cmd_arg, cur_path): def makeObject(self, cmd_arg, cur_path):
if sickbeard.USE_SYNOINDEX: if sickbeard.USE_SYNOINDEX:
synoindex_cmd = ['/usr/syno/bin/synoindex', cmd_arg, ek.ek(os.path.abspath, cur_path)] synoindex_cmd = ['/usr/syno/bin/synoindex', cmd_arg, ek.ek(os.path.abspath, cur_path)]
logger.log(u"Executing command " + str(synoindex_cmd)) logger.log(u"Executing command " + str(synoindex_cmd), logger.DEBUG)
logger.log(u"Absolute path to command: " + ek.ek(os.path.abspath, synoindex_cmd[0]), logger.DEBUG) logger.log(u"Absolute path to command: " + ek.ek(os.path.abspath, synoindex_cmd[0]), logger.DEBUG)
try: try:
p = subprocess.Popen(synoindex_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, p = subprocess.Popen(synoindex_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
@ -81,7 +81,7 @@ class synoIndexNotifier:
out, err = p.communicate() #@UnusedVariable out, err = p.communicate() #@UnusedVariable
logger.log(u"Script result: " + str(out), logger.DEBUG) logger.log(u"Script result: " + str(out), logger.DEBUG)
except OSError, e: except OSError, e:
logger.log(u"Unable to run synoindex: " + ex(e)) logger.log(u"Unable to run synoindex: " + ex(e), logger.ERROR)
notifier = synoIndexNotifier notifier = synoIndexNotifier

View File

@ -61,12 +61,12 @@ class TwitterNotifier:
oauth_consumer = oauth.Consumer(key=self.consumer_key, secret=self.consumer_secret) oauth_consumer = oauth.Consumer(key=self.consumer_key, secret=self.consumer_secret)
oauth_client = oauth.Client(oauth_consumer) oauth_client = oauth.Client(oauth_consumer)
logger.log('Requesting temp token from Twitter') logger.log('Requesting temp token from Twitter', logger.DEBUG)
resp, content = oauth_client.request(self.REQUEST_TOKEN_URL, 'GET') resp, content = oauth_client.request(self.REQUEST_TOKEN_URL, 'GET')
if resp['status'] != '200': if resp['status'] != '200':
logger.log('Invalid respond from Twitter requesting temp token: %s' % resp['status']) logger.log('Invalid response from Twitter requesting temp token: %s' % resp['status'], logger.ERROR)
else: else:
request_token = dict(parse_qsl(content)) request_token = dict(parse_qsl(content))
@ -85,26 +85,26 @@ class TwitterNotifier:
token = oauth.Token(request_token['oauth_token'], request_token['oauth_token_secret']) token = oauth.Token(request_token['oauth_token'], request_token['oauth_token_secret'])
token.set_verifier(key) token.set_verifier(key)
logger.log('Generating and signing request for an access token using key ' + key) logger.log('Generating and signing request for an access token using key ' + key, logger.DEBUG)
signature_method_hmac_sha1 = oauth.SignatureMethod_HMAC_SHA1() #@UnusedVariable signature_method_hmac_sha1 = oauth.SignatureMethod_HMAC_SHA1() #@UnusedVariable
oauth_consumer = oauth.Consumer(key=self.consumer_key, secret=self.consumer_secret) oauth_consumer = oauth.Consumer(key=self.consumer_key, secret=self.consumer_secret)
logger.log('oauth_consumer: ' + str(oauth_consumer)) logger.log('oauth_consumer: ' + str(oauth_consumer), logger.DEBUG)
oauth_client = oauth.Client(oauth_consumer, token) oauth_client = oauth.Client(oauth_consumer, token)
logger.log('oauth_client: ' + str(oauth_client)) logger.log('oauth_client: ' + str(oauth_client), logger.DEBUG)
resp, content = oauth_client.request(self.ACCESS_TOKEN_URL, method='POST', body='oauth_verifier=%s' % key) resp, content = oauth_client.request(self.ACCESS_TOKEN_URL, method='POST', body='oauth_verifier=%s' % key)
logger.log('resp, content: ' + str(resp) + ',' + str(content)) logger.log('resp, content: ' + str(resp) + ',' + str(content), logger.DEBUG)
access_token = dict(parse_qsl(content)) access_token = dict(parse_qsl(content))
logger.log('access_token: ' + str(access_token)) logger.log('access_token: ' + str(access_token), logger.DEBUG)
logger.log('resp[status] = ' + str(resp['status'])) logger.log('resp[status] = ' + str(resp['status']), logger.DEBUG)
if resp['status'] != '200': if resp['status'] != '200':
logger.log('The request for a token with did not succeed: ' + str(resp['status']), logger.ERROR) logger.log('The request for a token with did not succeed: ' + str(resp['status']), logger.ERROR)
return False return False
else: else:
logger.log('Your Twitter Access Token key: %s' % access_token['oauth_token']) logger.log('Your Twitter Access Token key: %s' % access_token['oauth_token'], logger.DEBUG)
logger.log('Access Token secret: %s' % access_token['oauth_token_secret']) logger.log('Access Token secret: %s' % access_token['oauth_token_secret'], logger.DEBUG)
sickbeard.TWITTER_USERNAME = access_token['oauth_token'] sickbeard.TWITTER_USERNAME = access_token['oauth_token']
sickbeard.TWITTER_PASSWORD = access_token['oauth_token_secret'] sickbeard.TWITTER_PASSWORD = access_token['oauth_token_secret']
return True return True
@ -117,7 +117,7 @@ class TwitterNotifier:
access_token_key = sickbeard.TWITTER_USERNAME access_token_key = sickbeard.TWITTER_USERNAME
access_token_secret = sickbeard.TWITTER_PASSWORD access_token_secret = sickbeard.TWITTER_PASSWORD
logger.log(u"Sending tweet: " + message) logger.log(u"Sending tweet: " + message, logger.DEBUG)
api = twitter.Api(username, password, access_token_key, access_token_secret) api = twitter.Api(username, password, access_token_key, access_token_secret)
@ -138,4 +138,4 @@ class TwitterNotifier:
return self._send_tweet(prefix + ": " + message) return self._send_tweet(prefix + ": " + message)
notifier = TwitterNotifier notifier = TwitterNotifier

View File

@ -66,7 +66,7 @@ class XBMCNotifier:
3 | (pre Eden) 3 | (pre Eden)
4 | v11 (Eden) 4 | v11 (Eden)
5 | (pre Frodo) 5 | (pre Frodo)
6 | v12 (Frodo) 6 | v12 (Frodo) / v13 (Gotham)
""" """
@ -327,7 +327,7 @@ class XBMCNotifier:
time.sleep(5) time.sleep(5)
# do a full update if requested # do a full update if requested
else: else:
logger.log(u"Doing Full Library XBMC update on host: " + host, logger.DEBUG) logger.log(u"Doing Full Library XBMC update on host: " + host, logger.MESSAGE)
updateCommand = {'command': 'ExecBuiltIn', 'parameter': 'XBMC.updatelibrary(video)'} updateCommand = {'command': 'ExecBuiltIn', 'parameter': 'XBMC.updatelibrary(video)'}
request = self._send_to_xbmc(updateCommand, host) request = self._send_to_xbmc(updateCommand, host)