From 6aa149752b4a2c08e4b34d8b1ebce4d4bf58ef3a Mon Sep 17 00:00:00 2001 From: Mark Rawson Date: Thu, 3 Jul 2014 07:43:48 +0100 Subject: [PATCH 1/2] Send notifications to all enabled notifiers upon SickRage update. --- sickbeard/common.py | 4 +++ sickbeard/notifiers/__init__.py | 4 +++ sickbeard/notifiers/boxcar.py | 8 +++++- sickbeard/notifiers/boxcar2.py | 8 +++++- sickbeard/notifiers/emailnotify.py | 33 ++++++++++++++++++++++++- sickbeard/notifiers/growl.py | 6 +++++ sickbeard/notifiers/libnotify.py | 5 ++++ sickbeard/notifiers/nma.py | 6 +++++ sickbeard/notifiers/nmj.py | 4 +++ sickbeard/notifiers/nmjv2.py | 4 +++ sickbeard/notifiers/plex.py | 6 +++++ sickbeard/notifiers/prowl.py | 7 ++++++ sickbeard/notifiers/pushalot.py | 8 ++++++ sickbeard/notifiers/pushbullet.py | 6 +++++ sickbeard/notifiers/pushover.py | 8 +++++- sickbeard/notifiers/pytivo.py | 3 +++ sickbeard/notifiers/synoindex.py | 3 +++ sickbeard/notifiers/synologynotifier.py | 6 +++++ sickbeard/notifiers/trakt.py | 3 +++ sickbeard/notifiers/tweet.py | 6 +++++ sickbeard/notifiers/xbmc.py | 6 +++++ sickbeard/versionChecker.py | 11 +++++++-- 22 files changed, 149 insertions(+), 6 deletions(-) diff --git a/sickbeard/common.py b/sickbeard/common.py index fbbf8341..a572926d 100644 --- a/sickbeard/common.py +++ b/sickbeard/common.py @@ -50,11 +50,15 @@ SEASON_RESULT = -2 NOTIFY_SNATCH = 1 NOTIFY_DOWNLOAD = 2 NOTIFY_SUBTITLE_DOWNLOAD = 3 +NOTIFY_SICKRAGE_UPDATE = 4 +NOTIFY_SICKRAGE_UPDATE_TEXT = 5 notifyStrings = {} notifyStrings[NOTIFY_SNATCH] = "Started Download" notifyStrings[NOTIFY_DOWNLOAD] = "Download Finished" notifyStrings[NOTIFY_SUBTITLE_DOWNLOAD] = "Subtitle Download Finished" +notifyStrings[NOTIFY_SICKRAGE_UPDATE] = "SickRage Updated" +notifyStrings[NOTIFY_SICKRAGE_UPDATE_TEXT] = "SickRage updated to version: " ### Episode statuses UNKNOWN = -1 # should never happen diff --git a/sickbeard/notifiers/__init__.py b/sickbeard/notifiers/__init__.py index 99ece634..683cb72c 100644 --- a/sickbeard/notifiers/__init__.py +++ b/sickbeard/notifiers/__init__.py @@ -101,3 +101,7 @@ def notify_subtitle_download(ep_name, lang): def notify_snatch(ep_name): for n in notifiers: n.notify_snatch(ep_name) + +def notify_sickrage_update(new_version = ""): + for n in notifiers: + n.notify_sickrage_update(new_version) diff --git a/sickbeard/notifiers/boxcar.py b/sickbeard/notifiers/boxcar.py index 3787e344..e65b9068 100644 --- a/sickbeard/notifiers/boxcar.py +++ b/sickbeard/notifiers/boxcar.py @@ -23,7 +23,7 @@ import time import sickbeard from sickbeard import logger -from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD +from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD, NOTIFY_SICKRAGE_UPDATE, NOTIFY_SICKRAGE_UPDATE_TEXT from sickbeard.exceptions import ex API_URL = "https://boxcar.io/devices/providers/fWc4sgSmpcN6JujtBmR6/notifications" @@ -122,6 +122,12 @@ class BoxcarNotifier: def notify_subtitle_download(self, ep_name, lang, title=notifyStrings[NOTIFY_SUBTITLE_DOWNLOAD]): if sickbeard.BOXCAR_NOTIFY_ONSUBTITLEDOWNLOAD: self._notifyBoxcar(title, ep_name + ": " + lang) + + def notify_sickrage_update(self, new_version = "??"): + if sickbeard.USE_BOXCAR: + update_text=notifyStrings[NOTIFY_SICKRAGE_UPDATE_TEXT] + title=notifyStrings[NOTIFY_SICKRAGE_UPDATE] + self._notifyBoxcar(title, update_text + new_version) def _notifyBoxcar(self, title, message, username=None, force=False): """ diff --git a/sickbeard/notifiers/boxcar2.py b/sickbeard/notifiers/boxcar2.py index 07f9cf00..0a727f8f 100755 --- a/sickbeard/notifiers/boxcar2.py +++ b/sickbeard/notifiers/boxcar2.py @@ -24,7 +24,7 @@ import time import sickbeard from sickbeard import logger -from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD +from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD, NOTIFY_SICKRAGE_UPDATE, NOTIFY_SICKRAGE_UPDATE_TEXT from sickbeard.exceptions import ex API_URL = "https://new.boxcar.io/api/notifications" @@ -96,6 +96,12 @@ class Boxcar2Notifier: def notify_subtitle_download(self, ep_name, lang, title=notifyStrings[NOTIFY_SUBTITLE_DOWNLOAD]): if sickbeard.BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD: self._notifyBoxcar2(title, ep_name + ": " + lang) + + def notify_sickrage_update(self, new_version = "??"): + if sickbeard.USE_BOXCAR2: + update_text=notifyStrings[NOTIFY_SICKRAGE_UPDATE_TEXT] + title=notifyStrings[NOTIFY_SICKRAGE_UPDATE] + self._notifyBoxcar2(title, update_text + new_version) def _notifyBoxcar2(self, title, message, accesstoken=None): """ diff --git a/sickbeard/notifiers/emailnotify.py b/sickbeard/notifiers/emailnotify.py index 7ad93488..2358d461 100644 --- a/sickbeard/notifiers/emailnotify.py +++ b/sickbeard/notifiers/emailnotify.py @@ -27,7 +27,7 @@ import re import sickbeard -from sickbeard import logger +from sickbeard import logger, common from sickbeard import db from sickbeard.exceptions import ex @@ -141,6 +141,37 @@ class EmailNotifier: logger.log("Download notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG) else: logger.log("Download notification ERROR: %s" % self.last_err, logger.ERROR) + + + def notify_sickrage_update(self, new_version = "??"): + """ + Send a notification that an updated version of SickRage has been installed + + """ + if sickbeard.USE_EMAIL: + update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT] + title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE] + + to = self._generate_recepients(show) + if len(to) == 0: + logger.log('Skipping email notify because there are no configured recepients', logger.WARNING) + else: + try: + msg = MIMEMultipart('alternative') + msg.attach(MIMEText( + "

SickRage Notification - " + title + "

\n

" + update_text + new_version + "

\n\n", + 'html')) + except: + logger.log("SickRage update notification ERROR: %s" % self.last_err, logger.ERROR) + + msg['Subject'] = lang + ' Subtitle Downloaded: ' + ep_name + msg['From'] = sickbeard.EMAIL_FROM + msg['To'] = ','.join(to) + if self._sendmail(sickbeard.EMAIL_HOST, sickbeard.EMAIL_PORT, sickbeard.EMAIL_FROM, sickbeard.EMAIL_TLS, + sickbeard.EMAIL_USER, sickbeard.EMAIL_PASSWORD, to, msg): + logger.log("Download notification sent to [%s] for '%s'" % (to, ep_name), logger.DEBUG) + else: + logger.log("Download notification ERROR: %s" % self.last_err, logger.ERROR) def _generate_recepients(self, show): addrs = [] diff --git a/sickbeard/notifiers/growl.py b/sickbeard/notifiers/growl.py index a40141a0..08ff6776 100644 --- a/sickbeard/notifiers/growl.py +++ b/sickbeard/notifiers/growl.py @@ -43,6 +43,12 @@ class GrowlNotifier: def notify_subtitle_download(self, ep_name, lang): if sickbeard.GROWL_NOTIFY_ONSUBTITLEDOWNLOAD: self._sendGrowl(common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD], ep_name + ": " + lang) + + def notify_sickrage_update(self, new_version = "??"): + if sickbeard.USE_GROWL: + update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT] + title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE] + self._sendGrowl(title, update_text + new_version) def _send_growl(self, options, message=None): diff --git a/sickbeard/notifiers/libnotify.py b/sickbeard/notifiers/libnotify.py index 2b39db72..c4c72499 100644 --- a/sickbeard/notifiers/libnotify.py +++ b/sickbeard/notifiers/libnotify.py @@ -92,6 +92,11 @@ class LibnotifyNotifier: def notify_subtitle_download(self, ep_name, lang): if sickbeard.LIBNOTIFY_NOTIFY_ONSUBTITLEDOWNLOAD: self._notify(common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD], ep_name + ": " + lang) + + def notify_sickrage_update(self, new_version = "??"): + if sickbeard.USE_LIBNOTIFY: + update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT], title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE] + self._notify(title, update_text + new_version) def test_notify(self): return self._notify('Test notification', "This is a test notification from SickRage", force=True) diff --git a/sickbeard/notifiers/nma.py b/sickbeard/notifiers/nma.py index 1593e468..25f7d5a6 100644 --- a/sickbeard/notifiers/nma.py +++ b/sickbeard/notifiers/nma.py @@ -23,6 +23,12 @@ class NMA_Notifier: if sickbeard.NMA_NOTIFY_ONSUBTITLEDOWNLOAD: self._sendNMA(nma_api=None, nma_priority=None, event=common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD], message=ep_name + ": " + lang) + + def notify_sickrage_update(self, new_version = "??"): + if sickbeard.USE_NMA: + update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT] + title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE] + self._sendNMA(nma_api=None, nma_priority=None, event=title, message=update_text + new_version) def _sendNMA(self, nma_api=None, nma_priority=None, event=None, message=None, force=False): diff --git a/sickbeard/notifiers/nmj.py b/sickbeard/notifiers/nmj.py index 75746ef5..807b36bd 100644 --- a/sickbeard/notifiers/nmj.py +++ b/sickbeard/notifiers/nmj.py @@ -96,6 +96,10 @@ class NMJNotifier: def notify_subtitle_download(self, ep_name, lang): if sickbeard.USE_NMJ: self._notifyNMJ() + + def notify_sickrage_update(self, new_version): + return False + # Not implemented, no reason to start scanner. def test_notify(self, host, database, mount): return self._sendNMJ(host, database, mount) diff --git a/sickbeard/notifiers/nmjv2.py b/sickbeard/notifiers/nmjv2.py index 6b9b53f8..fc2f16a0 100644 --- a/sickbeard/notifiers/nmjv2.py +++ b/sickbeard/notifiers/nmjv2.py @@ -42,6 +42,10 @@ class NMJv2Notifier: def notify_subtitle_download(self, ep_name, lang): self._notifyNMJ() + + def notify_sickrage_update(self, new_version): + return False + # Not implemented, no reason to start scanner. def test_notify(self, host): return self._sendNMJ(host) diff --git a/sickbeard/notifiers/plex.py b/sickbeard/notifiers/plex.py index 1e5cbb62..f5be0ba4 100644 --- a/sickbeard/notifiers/plex.py +++ b/sickbeard/notifiers/plex.py @@ -65,6 +65,12 @@ class PLEXNotifier(XBMCNotifier): def notify_subtitle_download(self, ep_name, lang): if sickbeard.PLEX_NOTIFY_ONSUBTITLEDOWNLOAD: self._notify_pmc(ep_name + ": " + lang, common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD]) + + def notify_sickrage_update(self, new_version = "??"): + if sickbeard.USE_PLEX: + update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT] + title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE] + self._notify_pmc(update_text + new_version, title) def test_notify(self, host, username, password): return self._notify_pmc("Testing Plex notifications from SickRage", "Test Notification", host, username, diff --git a/sickbeard/notifiers/prowl.py b/sickbeard/notifiers/prowl.py index ce2ecbad..19355839 100644 --- a/sickbeard/notifiers/prowl.py +++ b/sickbeard/notifiers/prowl.py @@ -51,6 +51,13 @@ class ProwlNotifier: if sickbeard.PROWL_NOTIFY_ONSUBTITLEDOWNLOAD: self._sendProwl(prowl_api=None, prowl_priority=None, event=common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD], message=ep_name + ": " + lang) + + def notify_sickrage_update(self, new_version = "??"): + if sickbeard.USE_PROWL: + update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT] + title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE] + self._sendProwl(prowl_api=None, prowl_priority=None, + event=title, message=update_text + new_version) def _sendProwl(self, prowl_api=None, prowl_priority=None, event=None, message=None, force=False): diff --git a/sickbeard/notifiers/pushalot.py b/sickbeard/notifiers/pushalot.py index b9cf86eb..e0003b49 100644 --- a/sickbeard/notifiers/pushalot.py +++ b/sickbeard/notifiers/pushalot.py @@ -45,6 +45,14 @@ class PushalotNotifier: self._sendPushalot(pushalot_authorizationtoken=None, event=common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD], message=ep_name + ": " + lang) + + def notify_sickrage_update(self, new_version = "??"): + if sickbeard.USE_PUSHALOT: + update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT] + title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE] + self._sendPushalot(pushalot_authorizationtoken=None, + event=title, + message=update_text + new_version) def _sendPushalot(self, pushalot_authorizationtoken=None, event=None, message=None, force=False): diff --git a/sickbeard/notifiers/pushbullet.py b/sickbeard/notifiers/pushbullet.py index d6bed96c..4c0bd84e 100644 --- a/sickbeard/notifiers/pushbullet.py +++ b/sickbeard/notifiers/pushbullet.py @@ -48,6 +48,12 @@ class PushbulletNotifier: if sickbeard.PUSHBULLET_NOTIFY_ONSUBTITLEDOWNLOAD: self._sendPushbullet(pushbullet_api=None, event=common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD] + " : " + ep_name + " : " + lang, message=ep_name + ": " + lang, notificationType="note", method="POST") + + def notify_sickrage_update(self, new_version = "??"): + if sickbeard.USE_PUSHBULLET: + update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT] + title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE] + self._sendPushbullet(pushbullet_api=None, event=title, message=update_text + new_version, method="POST") def _sendPushbullet(self, pushbullet_api=None, pushbullet_device=None, event=None, message=None, notificationType=None, method=None, force=False): diff --git a/sickbeard/notifiers/pushover.py b/sickbeard/notifiers/pushover.py index 39accd83..9458b18f 100644 --- a/sickbeard/notifiers/pushover.py +++ b/sickbeard/notifiers/pushover.py @@ -23,7 +23,7 @@ import time import sickbeard from sickbeard import logger -from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD +from sickbeard.common import notifyStrings, NOTIFY_SNATCH, NOTIFY_DOWNLOAD, NOTIFY_SUBTITLE_DOWNLOAD, NOTIFY_SICKRAGE_UPDATE, NOTIFY_SICKRAGE_UPDATE_TEXT from sickbeard.exceptions import ex API_URL = "https://api.pushover.net/1/messages.json" @@ -119,6 +119,12 @@ class PushoverNotifier: def notify_subtitle_download(self, ep_name, lang, title=notifyStrings[NOTIFY_SUBTITLE_DOWNLOAD]): if sickbeard.PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD: self._notifyPushover(title, ep_name + ": " + lang) + + def notify_sickrage_update(self, new_version = "??"): + if sickbeard.USE_PUSHOVER: + update_text=notifyStrings[NOTIFY_SICKRAGE_UPDATE_TEXT] + title=notifyStrings[NOTIFY_SICKRAGE_UPDATE] + self._notifyPushover(title, update_text + new_version) def _notifyPushover(self, title, message, userKey=None, apiKey=None, force=False): """ diff --git a/sickbeard/notifiers/pytivo.py b/sickbeard/notifiers/pytivo.py index 4b9aafb2..14a60268 100644 --- a/sickbeard/notifiers/pytivo.py +++ b/sickbeard/notifiers/pytivo.py @@ -36,6 +36,9 @@ class pyTivoNotifier: def notify_subtitle_download(self, ep_name, lang): pass + + def notify_sickrage_update(self, new_version): + pass def update_library(self, ep_obj): diff --git a/sickbeard/notifiers/synoindex.py b/sickbeard/notifiers/synoindex.py index 96ff111f..10c46636 100644 --- a/sickbeard/notifiers/synoindex.py +++ b/sickbeard/notifiers/synoindex.py @@ -37,6 +37,9 @@ class synoIndexNotifier: def notify_subtitle_download(self, ep_name, lang): pass + + def notify_sickrage_update(self, new_version): + pass def moveFolder(self, old_path, new_path): self.moveObject(old_path, new_path) diff --git a/sickbeard/notifiers/synologynotifier.py b/sickbeard/notifiers/synologynotifier.py index 54fc45ca..cb722e85 100644 --- a/sickbeard/notifiers/synologynotifier.py +++ b/sickbeard/notifiers/synologynotifier.py @@ -40,6 +40,12 @@ class synologyNotifier: def notify_subtitle_download(self, ep_name, lang): if sickbeard.SYNOLOGYNOTIFIER_NOTIFY_ONSUBTITLEDOWNLOAD: self._send_synologyNotifier(ep_name + ": " + lang, common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD]) + + def notify_sickrage_update(self, new_version = "??"): + if sickbeard.USE_SYNOLOGYNOTIFIER: + update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT] + title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE] + self._send_synologyNotifier(update_text + new_version, title) def _send_synologyNotifier(self, message, title): synodsmnotify_cmd = ["/usr/syno/bin/synodsmnotify", "@administrators", title, message] diff --git a/sickbeard/notifiers/trakt.py b/sickbeard/notifiers/trakt.py index 1e79fa25..890856a6 100644 --- a/sickbeard/notifiers/trakt.py +++ b/sickbeard/notifiers/trakt.py @@ -34,6 +34,9 @@ class TraktNotifier: def notify_subtitle_download(self, ep_name, lang): pass + + def notify_sickrage_update(self, new_version): + pass def update_library(self, ep_obj): """ diff --git a/sickbeard/notifiers/tweet.py b/sickbeard/notifiers/tweet.py index e010f7c0..ebfd2251 100644 --- a/sickbeard/notifiers/tweet.py +++ b/sickbeard/notifiers/tweet.py @@ -51,6 +51,12 @@ class TwitterNotifier: def notify_subtitle_download(self, ep_name, lang): if sickbeard.TWITTER_NOTIFY_ONSUBTITLEDOWNLOAD: self._notifyTwitter(common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD] + ' ' + ep_name + ": " + lang) + + def notify_sickrage_update(self, new_version = "??"): + if sickbeard.USE_TWITTER: + update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT] + title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE] + self._notifyTwitter(title + " - " + update_text + new_version) def test_notify(self): return self._notifyTwitter("This is a test notification from SickRage", force=True) diff --git a/sickbeard/notifiers/xbmc.py b/sickbeard/notifiers/xbmc.py index d1ce8adc..a433402b 100644 --- a/sickbeard/notifiers/xbmc.py +++ b/sickbeard/notifiers/xbmc.py @@ -512,6 +512,12 @@ class XBMCNotifier: def notify_subtitle_download(self, ep_name, lang): if sickbeard.XBMC_NOTIFY_ONSUBTITLEDOWNLOAD: self._notify_xbmc(ep_name + ": " + lang, common.notifyStrings[common.NOTIFY_SUBTITLE_DOWNLOAD]) + + def notify_sickrage_update(self, new_version = "??"): + if sickbeard.USE_XBMC: + update_text=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE_TEXT] + title=common.notifyStrings[common.NOTIFY_SICKRAGE_UPDATE] + self._notify_xbmc(update_text + new_version, title) def test_notify(self, host, username, password): return self._notify_xbmc("Testing XBMC notifications from SickRage", "Test Notification", host, username, diff --git a/sickbeard/versionChecker.py b/sickbeard/versionChecker.py index 59215eff..2aea8e25 100644 --- a/sickbeard/versionChecker.py +++ b/sickbeard/versionChecker.py @@ -30,7 +30,7 @@ import gh_api as github import threading import sickbeard -from sickbeard import helpers +from sickbeard import helpers, notifiers from sickbeard import version, ui from sickbeard import logger from sickbeard.exceptions import ex @@ -260,6 +260,9 @@ class WindowsUpdateManager(UpdateManager): new_update_path = os.path.join(sickbeard.PROG_DIR, u'updater.exe') logger.log(u"Copying new update.exe file from " + old_update_path + " to " + new_update_path) shutil.move(old_update_path, new_update_path) + + # Notify update successful + notifiers.notify_sickrage_update(sickbeard.NEWEST_VERSION_STRING) except Exception, e: logger.log(u"Error while trying to update: " + ex(e), logger.ERROR) @@ -412,7 +415,6 @@ class GitUpdateManager(UpdateManager): commit hash. If there is a newer version it sets _num_commits_behind. """ - self._newest_commit_hash = None self._num_commits_behind = 0 self._num_commits_ahead = 0 @@ -510,6 +512,8 @@ class GitUpdateManager(UpdateManager): output, err, exit_status = self._run_git(self._git_path, 'pull origin ' + self.branch) # @UnusedVariable if exit_status == 0: + # Notify update successful + notifiers.notify_sickrage_update(self._newest_commit_hash[:10]) return True return False @@ -715,4 +719,7 @@ class SourceUpdateManager(UpdateManager): logger.log(u"Traceback: " + traceback.format_exc(), logger.DEBUG) return False + # Notify update successful + notifiers.notify_sickrage_update(sickbeard.NEWEST_VERSION_STRING) + return True From 8f19e84a8011eeda13080990814e31b37381a2bf Mon Sep 17 00:00:00 2001 From: Mark Rawson Date: Thu, 3 Jul 2014 08:16:15 +0100 Subject: [PATCH 2/2] Add global option to disable SickRage update notifications via notifiers. --- gui/slick/interfaces/default/config_general.tmpl | 9 ++++++++- sickbeard/__init__.py | 5 ++++- sickbeard/notifiers/__init__.py | 5 +++-- sickbeard/webserve.py | 3 ++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gui/slick/interfaces/default/config_general.tmpl b/gui/slick/interfaces/default/config_general.tmpl index ab63a537..4973f89b 100644 --- a/gui/slick/interfaces/default/config_general.tmpl +++ b/gui/slick/interfaces/default/config_general.tmpl @@ -92,13 +92,20 @@ +
+ + +
diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py index 70ccffab..46491d9a 100644 --- a/sickbeard/__init__.py +++ b/sickbeard/__init__.py @@ -100,6 +100,7 @@ NEWEST_VERSION = None NEWEST_VERSION_STRING = None VERSION_NOTIFY = None AUTO_UPDATE = None +NOTIFY_ON_UPDATE = None CUR_COMMIT_HASH = None INIT_LOCK = Lock() @@ -457,7 +458,7 @@ def initialize(consoleLogging=True): USE_NMA, NMA_NOTIFY_ONSNATCH, NMA_NOTIFY_ONDOWNLOAD, NMA_NOTIFY_ONSUBTITLEDOWNLOAD, NMA_API, NMA_PRIORITY, \ USE_PUSHALOT, PUSHALOT_NOTIFY_ONSNATCH, PUSHALOT_NOTIFY_ONDOWNLOAD, PUSHALOT_NOTIFY_ONSUBTITLEDOWNLOAD, PUSHALOT_AUTHORIZATIONTOKEN, \ USE_PUSHBULLET, PUSHBULLET_NOTIFY_ONSNATCH, PUSHBULLET_NOTIFY_ONDOWNLOAD, PUSHBULLET_NOTIFY_ONSUBTITLEDOWNLOAD, PUSHBULLET_API, PUSHBULLET_DEVICE, \ - versionCheckScheduler, VERSION_NOTIFY, AUTO_UPDATE, PROCESS_AUTOMATICALLY, UNPACK, CPU_PRESET, \ + versionCheckScheduler, VERSION_NOTIFY, AUTO_UPDATE, NOTIFY_ON_UPDATE, PROCESS_AUTOMATICALLY, UNPACK, CPU_PRESET, \ KEEP_PROCESSED_DIR, PROCESS_METHOD, TV_DOWNLOAD_DIR, MIN_DAILYSEARCH_FREQUENCY, DEFAULT_UPDATE_FREQUENCY, MIN_UPDATE_FREQUENCY, UPDATE_FREQUENCY, \ showQueueScheduler, searchQueueScheduler, ROOT_DIRS, CACHE_DIR, ACTUAL_CACHE_DIR, TIMEZONE_DISPLAY, \ NAMING_PATTERN, NAMING_MULTI_EP, NAMING_FORCE_FOLDERS, NAMING_ABD_PATTERN, NAMING_CUSTOM_ABD, NAMING_SPORTS_PATTERN, NAMING_CUSTOM_SPORTS, NAMING_STRIP_YEAR, \ @@ -589,6 +590,7 @@ def initialize(consoleLogging=True): STATUS_DEFAULT = check_setting_int(CFG, 'General', 'status_default', SKIPPED) VERSION_NOTIFY = check_setting_int(CFG, 'General', 'version_notify', 1) AUTO_UPDATE = check_setting_int(CFG, 'General', 'auto_update', 0) + NOTIFY_ON_UPDATE = check_setting_int(CFG, 'General', 'notify_on_update', 1) FLATTEN_FOLDERS_DEFAULT = bool(check_setting_int(CFG, 'General', 'flatten_folders_default', 0)) INDEXER_DEFAULT = check_setting_int(CFG, 'General', 'indexer_default', 0) INDEXER_TIMEOUT = check_setting_int(CFG, 'General', 'indexer_timeout', 10) @@ -1388,6 +1390,7 @@ def save_config(): new_config['General']['provider_order'] = ' '.join(PROVIDER_ORDER) new_config['General']['version_notify'] = int(VERSION_NOTIFY) new_config['General']['auto_update'] = int(AUTO_UPDATE) + new_config['General']['notify_on_update'] = int(NOTIFY_ON_UPDATE) new_config['General']['naming_strip_year'] = int(NAMING_STRIP_YEAR) new_config['General']['naming_pattern'] = NAMING_PATTERN new_config['General']['naming_custom_abd'] = int(NAMING_CUSTOM_ABD) diff --git a/sickbeard/notifiers/__init__.py b/sickbeard/notifiers/__init__.py index 683cb72c..702e4100 100644 --- a/sickbeard/notifiers/__init__.py +++ b/sickbeard/notifiers/__init__.py @@ -103,5 +103,6 @@ def notify_snatch(ep_name): n.notify_snatch(ep_name) def notify_sickrage_update(new_version = ""): - for n in notifiers: - n.notify_sickrage_update(new_version) + if sickbeard.NOTIFY_ON_UPDATE: + for n in notifiers: + n.notify_sickrage_update(new_version) diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index d76199fd..a97b8304 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -1401,7 +1401,7 @@ class ConfigGeneral(MainHandler): update_shows_on_start=None, update_frequency=None, launch_browser=None, web_username=None, use_api=None, api_key=None, indexer_default=None, timezone_display=None, cpu_preset=None, web_password=None, version_notify=None, enable_https=None, https_cert=None, https_key=None, - handle_reverse_proxy=None, sort_article=None, auto_update=None, proxy_setting=None, + handle_reverse_proxy=None, sort_article=None, auto_update=None, notify_on_update=None, proxy_setting=None, anon_redirect=None, git_path=None, calendar_unprotected=None, fuzzy_dating=None, trim_zero=None, date_preset=None, date_preset_na=None, time_preset=None, indexer_timeout=None): @@ -1412,6 +1412,7 @@ class ConfigGeneral(MainHandler): sickbeard.LAUNCH_BROWSER = config.checkbox_to_value(launch_browser) config.change_VERSION_NOTIFY(config.checkbox_to_value(version_notify)) sickbeard.AUTO_UPDATE = config.checkbox_to_value(auto_update) + sickbeard.NOTIFY_ON_UPDATE = config.checkbox_to_value(notify_on_update) # sickbeard.LOG_DIR is set in config.change_LOG_DIR() sickbeard.UPDATE_SHOWS_ON_START = config.checkbox_to_value(update_shows_on_start)