mirror of
https://github.com/moparisthebest/SickRage
synced 2024-11-16 14:25:02 -05:00
Merge remote-tracking branch 'origin/dev'
This commit is contained in:
commit
c62245b5a3
@ -14,10 +14,10 @@ function check_notifications() {
|
||||
poll_interval = 5000;
|
||||
$.each(data, function (name, data) {
|
||||
$.pnotify({
|
||||
type: data.type,
|
||||
hide: data.type == 'notice',
|
||||
title: data.title,
|
||||
text: data.message
|
||||
pnotify_type: data.type,
|
||||
pnotify_hide: data.type == 'notice',
|
||||
pnotify_title: data.title,
|
||||
pnotify_text: data.message
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -123,7 +123,6 @@ HANDLE_REVERSE_PROXY = None
|
||||
PROXY_SETTING = None
|
||||
|
||||
LOCALHOST_IP = None
|
||||
REMOTE_IP = None
|
||||
|
||||
CPU_PRESET = None
|
||||
|
||||
@ -476,7 +475,7 @@ def initialize(consoleLogging=True):
|
||||
GUI_NAME, HOME_LAYOUT, HISTORY_LAYOUT, DISPLAY_SHOW_SPECIALS, COMING_EPS_LAYOUT, COMING_EPS_SORT, COMING_EPS_DISPLAY_PAUSED, COMING_EPS_MISSED_RANGE, FUZZY_DATING, TRIM_ZERO, DATE_PRESET, TIME_PRESET, TIME_PRESET_W_SECONDS, \
|
||||
METADATA_WDTV, METADATA_TIVO, METADATA_MEDE8ER, IGNORE_WORDS, CALENDAR_UNPROTECTED, CREATE_MISSING_SHOW_DIRS, \
|
||||
ADD_SHOWS_WO_DIR, USE_SUBTITLES, SUBTITLES_LANGUAGES, SUBTITLES_DIR, SUBTITLES_SERVICES_LIST, SUBTITLES_SERVICES_ENABLED, SUBTITLES_HISTORY, SUBTITLES_FINDER_FREQUENCY, subtitlesFinderScheduler, \
|
||||
USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, REMOTE_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, \
|
||||
USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, TMDB_API_KEY, DEBUG, PROXY_SETTING, \
|
||||
AUTOPOSTPROCESSER_FREQUENCY, DEFAULT_AUTOPOSTPROCESSER_FREQUENCY, MIN_AUTOPOSTPROCESSER_FREQUENCY, \
|
||||
ANIME_DEFAULT, NAMING_ANIME, ANIMESUPPORT, USE_ANIDB, ANIDB_USERNAME, ANIDB_PASSWORD, ANIDB_USE_MYLIST, \
|
||||
ANIME_SPLIT_HOME, maintenanceScheduler, SCENE_DEFAULT, RES
|
||||
|
@ -19,17 +19,13 @@
|
||||
import datetime
|
||||
import sickbeard
|
||||
|
||||
from tornado.web import RequestHandler
|
||||
|
||||
MESSAGE = 'notice'
|
||||
ERROR = 'error'
|
||||
|
||||
|
||||
class Notifications(object):
|
||||
"""
|
||||
A queue of Notification objects.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self._messages = []
|
||||
self._errors = []
|
||||
@ -52,7 +48,7 @@ class Notifications(object):
|
||||
"""
|
||||
self._errors.append(Notification(title, message, ERROR))
|
||||
|
||||
def get_notifications(self):
|
||||
def get_notifications(self, remote_ip='127.0.0.1'):
|
||||
"""
|
||||
Return all the available notifications in a list. Marks them all as seen
|
||||
as it returns them. Also removes timed out Notifications from the queue.
|
||||
@ -65,7 +61,7 @@ class Notifications(object):
|
||||
self._messages = [x for x in self._messages if not x.is_expired()]
|
||||
|
||||
# return any notifications that haven't been shown to the client already
|
||||
return [x.see() for x in self._errors + self._messages if x.is_new()]
|
||||
return [x.see(remote_ip) for x in self._errors + self._messages if x.is_new(remote_ip)]
|
||||
|
||||
# static notification queue object
|
||||
notifications = Notifications()
|
||||
@ -76,7 +72,6 @@ class Notification(object):
|
||||
Represents a single notification. Tracks its own timeout and a list of which clients have
|
||||
seen it before.
|
||||
"""
|
||||
|
||||
def __init__(self, title, message='', type=None, timeout=None):
|
||||
self.title = title
|
||||
self.message = message
|
||||
@ -94,11 +89,11 @@ class Notification(object):
|
||||
else:
|
||||
self._timeout = datetime.timedelta(minutes=1)
|
||||
|
||||
def is_new(self):
|
||||
def is_new(self, remote_ip='127.0.0.1'):
|
||||
"""
|
||||
Returns True if the notification hasn't been displayed to the current client (aka IP address).
|
||||
"""
|
||||
return sickbeard.REMOTE_IP not in self._seen
|
||||
return remote_ip not in self._seen
|
||||
|
||||
def is_expired(self):
|
||||
"""
|
||||
@ -107,20 +102,19 @@ class Notification(object):
|
||||
return datetime.datetime.now() - self._when > self._timeout
|
||||
|
||||
|
||||
def see(self):
|
||||
def see(self, remote_ip='127.0.0.1'):
|
||||
"""
|
||||
Returns this notification object and marks it as seen by the client ip
|
||||
"""
|
||||
self._seen.append(sickbeard.REMOTE_IP)
|
||||
self._seen.append(remote_ip)
|
||||
return self
|
||||
|
||||
|
||||
class ProgressIndicator():
|
||||
|
||||
def __init__(self, percentComplete=0, currentStatus={'title': ''}):
|
||||
self.percentComplete = percentComplete
|
||||
self.currentStatus = currentStatus
|
||||
|
||||
|
||||
class ProgressIndicators():
|
||||
_pi = {'massUpdate': [],
|
||||
'massAdd': [],
|
||||
@ -144,12 +138,10 @@ class ProgressIndicators():
|
||||
def setIndicator(name, indicator):
|
||||
ProgressIndicators._pi[name].append(indicator)
|
||||
|
||||
|
||||
class QueueProgressIndicator():
|
||||
"""
|
||||
A class used by the UI to show the progress of the queue or a part of it.
|
||||
"""
|
||||
|
||||
def __init__(self, name, queueItemList):
|
||||
self.queueItemList = queueItemList
|
||||
self.name = name
|
||||
@ -164,8 +156,7 @@ class QueueProgressIndicator():
|
||||
return len([x for x in self.queueItemList if x.isInQueue()])
|
||||
|
||||
def nextName(self):
|
||||
for curItem in [
|
||||
sickbeard.showQueueScheduler.action.currentItem] + sickbeard.showQueueScheduler.action.queue: #@UndefinedVariable
|
||||
for curItem in [sickbeard.showQueueScheduler.action.currentItem]+sickbeard.showQueueScheduler.action.queue: #@UndefinedVariable
|
||||
if curItem in self.queueItemList:
|
||||
return curItem.name
|
||||
|
||||
@ -178,12 +169,9 @@ class QueueProgressIndicator():
|
||||
if numTotal == 0:
|
||||
return 0
|
||||
else:
|
||||
return int(float(numFinished) / float(numTotal) * 100)
|
||||
|
||||
return int(float(numFinished)/float(numTotal)*100)
|
||||
|
||||
class LoadingTVShow():
|
||||
def __init__(self, dir):
|
||||
self.dir = dir
|
||||
self.show = None
|
||||
|
||||
|
||||
|
@ -1450,7 +1450,7 @@ class CMD_SickBeardGetMessages(ApiCall):
|
||||
|
||||
def run(self):
|
||||
messages = []
|
||||
for cur_notification in ui.notifications.get_notifications():
|
||||
for cur_notification in ui.notifications.get_notifications(self.handler.request.remote_ip):
|
||||
messages.append({"title": cur_notification.title,
|
||||
"message": cur_notification.message,
|
||||
"type": cur_notification.type})
|
||||
|
@ -144,10 +144,6 @@ def redirect(url, permanent=False, status=None):
|
||||
|
||||
@authenticated
|
||||
class MainHandler(RequestHandler):
|
||||
def __init__(self, application, request, **kwargs):
|
||||
super(MainHandler, self).__init__(application, request, **kwargs)
|
||||
sickbeard.REMOTE_IP = self.request.headers.get('X-Forwarded-For', self.request.headers.get('X-Real-Ip', self.request.remote_ip))
|
||||
|
||||
def http_error_401_handler(self):
|
||||
""" Custom handler for 401 error """
|
||||
return r'''<!DOCTYPE html>
|
||||
@ -4305,7 +4301,7 @@ class UI(MainHandler):
|
||||
def get_messages(self):
|
||||
messages = {}
|
||||
cur_notification_num = 1
|
||||
for cur_notification in ui.notifications.get_notifications():
|
||||
for cur_notification in ui.notifications.get_notifications(self.request.remote_ip):
|
||||
messages['notification-' + str(cur_notification_num)] = {'title': cur_notification.title,
|
||||
'message': cur_notification.message,
|
||||
'type': cur_notification.type}
|
||||
|
Loading…
Reference in New Issue
Block a user