1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-10-31 15:35:01 -04:00

Merge branch 'release/4.0.6'

This commit is contained in:
echel0n 2014-12-19 14:09:29 -08:00
commit 1be07e5672
4 changed files with 36 additions and 31 deletions

View File

@ -17,4 +17,4 @@ script:
- ./tests/all_tests.py - ./tests/all_tests.py
notifications: notifications:
irc: "irc.freenode.net#sickrage" irc: "irc.freenode.net#sickrage-updates"

View File

@ -18,6 +18,7 @@
from __future__ import with_statement from __future__ import with_statement
import os import os
import re
import sys import sys
import logging import logging
import logging.handlers import logging.handlers
@ -25,8 +26,7 @@ import threading
import platform import platform
import sickbeard import sickbeard
from sickbeard import classes from sickbeard import classes, encodingKludge as ek
from sickbeard.encodingKludge import ek
from github import Github from github import Github
from pastebin import PastebinAPI from pastebin import PastebinAPI
@ -147,13 +147,10 @@ class Logger(object):
self.gh_issues = Github(login_or_token=sickbeard.GIT_USERNAME, password=sickbeard.GIT_PASSWORD, self.gh_issues = Github(login_or_token=sickbeard.GIT_USERNAME, password=sickbeard.GIT_PASSWORD,
user_agent="SiCKRAGE").get_organization(gh_org).get_repo(gh_repo) user_agent="SiCKRAGE").get_organization(gh_org).get_repo(gh_repo)
pastebin_url = None
try: try:
if self.logFile and os.path.isfile(self.logFile): if self.logFile and os.path.isfile(self.logFile):
with ek(open, self.logFile) as f: with ek.ek(open, self.logFile) as f:
data = f.readlines() log_data = f.readlines()
data = "".join(data[len(data) - 100:])
pastebin_url = PastebinAPI().paste('f59b8e9fa1fc2d033e399e6c7fb09d19', data)
except Exception as e: except Exception as e:
pass pass
@ -162,6 +159,19 @@ class Logger(object):
if not curError.title: if not curError.title:
continue continue
regex = "^(%s)\s*([A-Z]+)\s*(.+?)\s*\:\:\s*(.*)$" % curError.time
pastebin_url = None
for i, x in enumerate(reversed(log_data)):
x = ek.ss(x)
match = re.match(regex, x)
if match:
level = match.group(2)
if reverseNames[level] >= ERROR:
paste_data = "".join(log_data[len(log_data) - i - 50:])
pastebin_url = PastebinAPI().paste('f59b8e9fa1fc2d033e399e6c7fb09d19', paste_data)
break
message = u"### INFO\n" message = u"### INFO\n"
message += u"Python Version: **" + sys.version[:120] + "**\n" message += u"Python Version: **" + sys.version[:120] + "**\n"
message += u"Operating System: **" + platform.platform() + "**\n" message += u"Operating System: **" + platform.platform() + "**\n"
@ -178,11 +188,14 @@ class Logger(object):
issue = self.gh_issues.create_issue(title + curError.title, message) issue = self.gh_issues.create_issue(title + curError.title, message)
if issue: if issue:
ui.notifications.message('Your issue ticket #%s was submitted successfully!' % issue.number) self.log('Your issue ticket #%s was submitted successfully!' % issue.number)
classes.ErrorViewer.clear()
if not sickbeard.GIT_AUTOISSUES:
ui.notifications.message('Your issue ticket #%s was submitted successfully!' % issue.number)
classes.ErrorViewer.clear()
except Exception as e: except Exception as e:
self.log(sickbeard.exceptions.ex(e), logger.ERROR) pass
class Wrapper(object): class Wrapper(object):

View File

@ -159,7 +159,7 @@ class BaseHandler(RequestHandler):
url = url[len(sickbeard.WEB_ROOT) + 1:] url = url[len(sickbeard.WEB_ROOT) + 1:]
if url[:3] != 'api': if url[:3] != 'api':
return self.redirect(url) return self.redirect('/')
else: else:
self.finish('Wrong API key used') self.finish('Wrong API key used')
@ -201,7 +201,8 @@ class WebHandler(BaseHandler):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(WebHandler, self).__init__(*args, **kwargs) super(WebHandler, self).__init__(*args, **kwargs)
self.io_loop = IOLoop.current() self.io_loop = IOLoop.current()
self.executor = ThreadPoolExecutor(50)
executor = ThreadPoolExecutor(50)
@coroutine @coroutine
@asynchronous @asynchronous
@ -209,13 +210,13 @@ class WebHandler(BaseHandler):
def get(self, route, *args, **kwargs): def get(self, route, *args, **kwargs):
try: try:
# route -> method obj # route -> method obj
route = route.strip('/').replace('.', '_') route = route.strip('/').replace('.', '_') or 'index'
method = getattr(self, route, self.index) method = getattr(self, route)
# process request async # process request async
self.async_call(method, callback=self.async_done) self.async_call(method, callback=self.async_done)
except: except:
logger.log('Failed doing webui request "%s": %s' % (route, traceback.format_exc()), logger.ERROR) logger.log('Failed doing webui request "%s": %s' % (route, traceback.format_exc()), logger.DEBUG)
raise HTTPError(404) raise HTTPError(404)
@run_on_executor @run_on_executor
@ -242,14 +243,12 @@ class WebHandler(BaseHandler):
logger.log('Failed sending webui reponse: %s' % (traceback.format_exc()), logger.DEBUG) logger.log('Failed sending webui reponse: %s' % (traceback.format_exc()), logger.DEBUG)
raise raise
# post uses get method # post uses get method
post = get post = get
class LoginHandler(BaseHandler): class LoginHandler(BaseHandler):
def __init__(self, *args, **kwargs):
super(LoginHandler, self).__init__(*args, **kwargs)
def get(self, *args, **kwargs): def get(self, *args, **kwargs):
if self.get_current_user(): if self.get_current_user():
self.redirect('/home/') self.redirect('/home/')
@ -276,15 +275,11 @@ class LoginHandler(BaseHandler):
class LogoutHandler(BaseHandler): class LogoutHandler(BaseHandler):
def __init__(self, *args, **kwargs):
super(LogoutHandler, self).__init__(*args, **kwargs)
def get(self, *args, **kwargs): def get(self, *args, **kwargs):
self.clear_cookie("user") self.clear_cookie("user")
self.redirect('/login/') self.redirect('/login/')
class KeyHandler(RequestHandler):
class KeyHandler(BaseHandler):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(KeyHandler, self).__init__(*args, **kwargs) super(KeyHandler, self).__init__(*args, **kwargs)
@ -1818,7 +1813,7 @@ class Home(WebRoot):
# Finished Searches # Finished Searches
searchstatus = 'finished' searchstatus = 'finished'
for searchThread in sickbeard.search_queue.MANUAL_SEARCH_HISTORY: for searchThread in sickbeard.search_queue.MANUAL_SEARCH_HISTORY:
if not int(searchThread.show.indexerid) == int(show or 0): if not str(searchThread.show.indexerid) == show:
continue continue
if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem): if isinstance(searchThread, sickbeard.search_queue.ManualSearchQueueItem):

View File

@ -72,7 +72,7 @@ class SRWebServer(threading.Thread):
gzip=True, gzip=True,
xheaders=sickbeard.HANDLE_REVERSE_PROXY, xheaders=sickbeard.HANDLE_REVERSE_PROXY,
cookie_secret='61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=', cookie_secret='61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=',
login_url='/login/', login_url='%s/login/' % self.options['web_root'],
) )
# Main Handlers # Main Handlers
@ -87,11 +87,8 @@ class SRWebServer(threading.Thread):
(r'%s/api/builder' % self.options['web_root'], RedirectHandler, {"url": self.options['web_root'] + '/apibuilder/'}), (r'%s/api/builder' % self.options['web_root'], RedirectHandler, {"url": self.options['web_root'] + '/apibuilder/'}),
# webui login/logout handlers # webui login/logout handlers
(r'%s/login(/?.*)' % self.options['web_root'], LoginHandler), (r'%s/login(/?)' % self.options['web_root'], LoginHandler),
(r'%s/logout(/?.*)' % self.options['web_root'], LogoutHandler), (r'%s/logout(/?)' % self.options['web_root'], LogoutHandler),
# webui redirect
(r'/', RedirectHandler, {"url": self.options['web_root'] + '/home/'}),
# webui handlers # webui handlers
] + route.get_routes(self.options['web_root'])) ] + route.get_routes(self.options['web_root']))