Commit c8bc8443 authored by echel0n's avatar echel0n
Browse files

Merge branch 'release/10.0.22'

parents 117ee1f0 02d1e69a
......@@ -2,8 +2,14 @@
 
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
 
#### [10.0.22](https://git.sickrage.ca/SiCKRAGE/sickrage/compare/10.0.21...10.0.22)
- Moved websocket queue check function to webserver class [`18042f3`](https://git.sickrage.ca/SiCKRAGE/sickrage/commit/18042f35c632962689f8854d24c09422ceaf666c)
#### [10.0.21](https://git.sickrage.ca/SiCKRAGE/sickrage/compare/10.0.20...10.0.21)
 
> 1 August 2021
#### [10.0.20](https://git.sickrage.ca/SiCKRAGE/sickrage/compare/10.0.19...10.0.20)
 
> 31 July 2021
......
{
"name": "sickrage",
"version": "10.0.21",
"version": "10.0.22",
"private": true,
"repository": {
"type": "git",
......
[bumpversion]
current_version = 10.0.21
current_version = 10.0.22
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<dev>\d+))?
......
......@@ -19,7 +19,7 @@
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
__version__ = "10.0.21"
__version__ = "10.0.22"
__install_type__ = ""
import argparse
......
This diff is collapsed.
......@@ -80,7 +80,6 @@ from sickrage.core.updaters.tz_updater import TimeZoneUpdater
from sickrage.core.upnp import UPNPClient
from sickrage.core.version_updater import VersionUpdater, SourceUpdateManager
from sickrage.core.webserver import WebServer
from sickrage.core.websocket import check_web_socket_queue
from sickrage.metadata_providers import MetadataProviders
from sickrage.notification_providers import NotificationProviders
from sickrage.search_providers import SearchProviders
......@@ -567,9 +566,6 @@ class Core(object):
# shutdown trigger
PeriodicCallback(self.shutdown_trigger, 5 * 1000).start()
# watch websocket message queue
PeriodicCallback(check_web_socket_queue, 100).start()
# start ioloop
IOLoop.current().start()
......
......@@ -26,7 +26,6 @@ import subprocess
import sys
import tarfile
import tempfile
import threading
from distutils.version import LooseVersion
from time import sleep
......@@ -655,38 +654,43 @@ class SourceUpdateManager(UpdateManager):
if not self.install_requirements(self.current_branch):
return False
with tempfile.TemporaryFile() as update_tarfile:
sickrage.app.log.info(f"Downloading update from {tar_download_url!r}")
resp = WebSession().get(tar_download_url)
if not resp or not resp.content:
sickrage.app.log.warning('Failed to download SiCKRAGE update')
return False
update_tarfile.write(resp.content)
update_tarfile.seek(0)
with tempfile.TemporaryDirectory(prefix='sr_update_', dir=sickrage.app.data_dir) as unpack_dir:
sickrage.app.log.info("Extracting SiCKRAGE update file")
try:
tar = tarfile.open(fileobj=update_tarfile, mode='r:gz')
tar.extractall(unpack_dir)
tar.close()
except tarfile.TarError:
sickrage.app.log.warning("Invalid update data, update failed: not a gzip file")
return False
if len(os.listdir(unpack_dir)) != 1:
sickrage.app.log.warning("Invalid update data, update failed")
return False
update_dir = os.path.join(*[unpack_dir, os.listdir(unpack_dir)[0], 'sickrage'])
sickrage.app.log.info(f"Sync folder {update_dir} to {sickrage.PROG_DIR}")
dirsync.sync(update_dir, sickrage.PROG_DIR, 'sync', purge=True)
retry_count = 0
while retry_count < 3:
with tempfile.TemporaryFile() as update_tarfile:
sickrage.app.log.info(f"Downloading update from {tar_download_url!r}")
resp = WebSession().get(tar_download_url)
if not resp or not resp.content:
sickrage.app.log.warning('Failed to download SiCKRAGE update')
retry_count += 1
continue
update_tarfile.write(resp.content)
update_tarfile.seek(0)
with tempfile.TemporaryDirectory(prefix='sr_update_', dir=sickrage.app.data_dir) as unpack_dir:
sickrage.app.log.info("Extracting SiCKRAGE update file")
try:
tar = tarfile.open(fileobj=update_tarfile, mode='r:gz')
tar.extractall(unpack_dir)
tar.close()
except tarfile.TarError:
sickrage.app.log.warning("Invalid update data, update failed: not a gzip file")
retry_count += 1
continue
if len(os.listdir(unpack_dir)) != 1:
sickrage.app.log.warning("Invalid update data, update failed")
retry_count += 1
continue
update_dir = os.path.join(*[unpack_dir, os.listdir(unpack_dir)[0], 'sickrage'])
sickrage.app.log.info(f"Sync folder {update_dir} to {sickrage.PROG_DIR}")
dirsync.sync(update_dir, sickrage.PROG_DIR, 'sync', purge=True)
# Notify update successful
NotificationProvider.mass_notify_version_update(latest_version)
return True
except Exception as e:
sickrage.app.log.error(f"Error while trying to update: {e!r}")
return False
# Notify update successful
NotificationProvider.mass_notify_version_update(latest_version)
return True
......@@ -23,19 +23,19 @@ import os
import shutil
import socket
import ssl
import threading
import tornado.autoreload
import tornado.locale
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.x509.extensions import ExtensionNotFound
from cryptography.x509 import ExtensionNotFound
from mako.lookup import TemplateLookup
from tornado.httpserver import HTTPServer
from tornado.ioloop import PeriodicCallback
from tornado.web import Application, RedirectHandler, StaticFileHandler
import sickrage
from sickrage.core.helpers import create_https_certificates, launch_browser, get_internal_ip
from sickrage.core.helpers import create_https_certificates
from sickrage.core.webserver.handlers.account import AccountLinkHandler, AccountUnlinkHandler, AccountIsLinkedHandler
from sickrage.core.webserver.handlers.announcements import AnnouncementsHandler, MarkAnnouncementSeenHandler, AnnouncementCountHandler
from sickrage.core.webserver.handlers.api import ApiSwaggerDotJsonHandler, ApiPingHandler, ApiProfileHandler
......@@ -139,6 +139,9 @@ class WebServer(object):
def start(self):
self.started = True
# watch websocket message queue
PeriodicCallback(self.check_web_socket_queue, 100).start()
# load languages
tornado.locale.load_gettext_translations(sickrage.LOCALE_DIR, 'messages')
......@@ -495,6 +498,11 @@ class WebServer(object):
sickrage.app.log.warning(e.strerror)
raise SystemExit
def check_web_socket_queue(self):
if not WebSocketUIHandler.message_queue.empty():
message = WebSocketUIHandler.message_queue.get()
WebSocketUIHandler.broadcast(message)
def load_ssl_certificate(self):
if os.path.exists(sickrage.app.config.general.https_key) and os.path.exists(sickrage.app.config.general.https_cert):
if self.is_certificate_valid() and not self.certificate_needs_renewal():
......
......@@ -19,7 +19,6 @@
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
import functools
import html
import time
import traceback
import types
......@@ -31,7 +30,8 @@ import bleach
from jose import ExpiredSignatureError
from keycloak.exceptions import KeycloakClientError
from mako.exceptions import RichTraceback
from tornado import locale, escape
from tornado import locale
from tornado.escape import utf8
from tornado.ioloop import IOLoop
from tornado.web import RequestHandler
......@@ -164,7 +164,15 @@ class BaseHandler(RequestHandler):
def redirect(self, url, permanent=True, status=None):
if sickrage.app.config.general.web_root not in url:
url = urljoin(sickrage.app.config.general.web_root + '/', url.lstrip('/'))
super(BaseHandler, self).redirect(url, permanent, status)
if self._headers_written:
raise Exception("Cannot redirect after headers have been written")
if status is None:
status = 301 if permanent else 302
else:
assert isinstance(status, int) and 300 <= status <= 399
self.set_status(status)
self.set_header("Location", utf8(url))
def previous_url(self):
url = urlparse(self.request.headers.get("referer", "/{}/".format(sickrage.app.config.general.default_page.value)))
......
......@@ -1003,7 +1003,6 @@ class TogglePauseHandler(BaseHandler):
def get(self, *args, **kwargs):
show = self.get_argument('show')
session = sickrage.app.main_db.session()
show_obj = find_show(int(show))
if show_obj is None:
......
......@@ -7,12 +7,6 @@ from tornado.websocket import WebSocketHandler
import sickrage
def check_web_socket_queue():
if not WebSocketUIHandler.message_queue.empty():
message = WebSocketUIHandler.message_queue.get()
WebSocketUIHandler.broadcast(message)
class WebSocketUIHandler(WebSocketHandler):
"""WebSocket handler to send and receive data to and from a web client."""
......@@ -26,8 +20,6 @@ class WebSocketUIHandler(WebSocketHandler):
def open(self, *args, **kwargs):
"""Client connected to the WebSocket."""
WebSocketUIHandler.clients.add(self)
# while not WebSocketUIHandler.message_queue.empty():
# self.write_message(WebSocketUIHandler.message_queue.get())
def on_message(self, message):
"""Received a message from the client."""
......@@ -61,7 +53,7 @@ class WebSocketUIHandler(WebSocketHandler):
@classmethod
def broadcast(cls, msg):
for client in cls.clients:
client.write_message(json.dumps(msg))
client.write_message(msg)
def __repr__(self):
"""Client representation."""
......
10.0.21
\ No newline at end of file
10.0.22
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment