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
notifications:
irc: "irc.freenode.net#sickrage"
irc: "irc.freenode.net#sickrage-updates"

View File

@ -18,6 +18,7 @@
from __future__ import with_statement
import os
import re
import sys
import logging
import logging.handlers
@ -25,8 +26,7 @@ import threading
import platform
import sickbeard
from sickbeard import classes
from sickbeard.encodingKludge import ek
from sickbeard import classes, encodingKludge as ek
from github import Github
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,
user_agent="SiCKRAGE").get_organization(gh_org).get_repo(gh_repo)
pastebin_url = None
try:
if self.logFile and os.path.isfile(self.logFile):
with ek(open, self.logFile) as f:
data = f.readlines()
data = "".join(data[len(data) - 100:])
pastebin_url = PastebinAPI().paste('f59b8e9fa1fc2d033e399e6c7fb09d19', data)
with ek.ek(open, self.logFile) as f:
log_data = f.readlines()
except Exception as e:
pass
@ -162,6 +159,19 @@ class Logger(object):
if not curError.title:
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"Python Version: **" + sys.version[:120] + "**\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)
if issue:
ui.notifications.message('Your issue ticket #%s was submitted successfully!' % issue.number)
classes.ErrorViewer.clear()
self.log('Your issue ticket #%s was submitted successfully!' % issue.number)
if not sickbeard.GIT_AUTOISSUES:
ui.notifications.message('Your issue ticket #%s was submitted successfully!' % issue.number)
classes.ErrorViewer.clear()
except Exception as e:
self.log(sickbeard.exceptions.ex(e), logger.ERROR)
pass
class Wrapper(object):

View File

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

View File

@ -72,7 +72,7 @@ class SRWebServer(threading.Thread):
gzip=True,
xheaders=sickbeard.HANDLE_REVERSE_PROXY,
cookie_secret='61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=',
login_url='/login/',
login_url='%s/login/' % self.options['web_root'],
)
# 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/'}),
# webui login/logout handlers
(r'%s/login(/?.*)' % self.options['web_root'], LoginHandler),
(r'%s/logout(/?.*)' % self.options['web_root'], LogoutHandler),
# webui redirect
(r'/', RedirectHandler, {"url": self.options['web_root'] + '/home/'}),
(r'%s/login(/?)' % self.options['web_root'], LoginHandler),
(r'%s/logout(/?)' % self.options['web_root'], LogoutHandler),
# webui handlers
] + route.get_routes(self.options['web_root']))