Commit 9c4df906 authored by echel0n's avatar echel0n

Merge branch 'release-v9.4.158'

parents 04bb8203 5db54c4b
# Changelog # Changelog
- * 67b328efe - 2019-07-31: Refactored requirements.txt to replace package hachoir3 with hachoir, hachoir3 was removed from PyPi.
- * a7367cfd6 - 2019-07-30: Refactored SiCKRAGE API web session requests to retry 3 times with 1s pause between retries.
- * c8b25004d - 2019-07-30: Added passing of database session for scene number function calls in display show web handler.
- * eb3a91213 - 2019-07-28: Added exception handling for tarfile extraction in version updater.
- * cfbeee1ab - 2019-07-28: Fixed attribute error `'str' object has no attribute 'decode'` in version updater. Fixes SICKRAGE-APP-PY3-1B9
- * c7a14c81a - 2019-07-28: Pre-Release v9.4.158.dev1
- * dad896a55 - 2019-07-28: Release v9.4.157
- * 90fe2d3d3 - 2019-07-28: Refactored dynamic loading of metadata providers. Refactored dynamic loading of notifier providers. Refactored dynamic loading of NZB providers. Refactored dynamic loading of Torrent providers. Refactored metadata provider config property and added default value. Refactored web handler arguments to return string instead of None for default value. - * 90fe2d3d3 - 2019-07-28: Refactored dynamic loading of metadata providers. Refactored dynamic loading of notifier providers. Refactored dynamic loading of NZB providers. Refactored dynamic loading of Torrent providers. Refactored metadata provider config property and added default value. Refactored web handler arguments to return string instead of None for default value.
- * c5ca8dae3 - 2019-07-26: Added Sentry tag to gather Python version to help debug issues. - * c5ca8dae3 - 2019-07-26: Added Sentry tag to gather Python version to help debug issues.
- * e1a4bc05e - 2019-07-24: Added `--disable_updates` startup option to allow disabling of application updates both auto and manual. - * e1a4bc05e - 2019-07-24: Added `--disable_updates` startup option to allow disabling of application updates both auto and manual.
......
...@@ -6,7 +6,7 @@ cfscrape == 1.9.7 ...@@ -6,7 +6,7 @@ cfscrape == 1.9.7
configobj == 5.0.6 configobj == 5.0.6
feedparser == 5.2.1 feedparser == 5.2.1
guessit == 3.0.3 guessit == 3.0.3
hachoir3 == 3.0a2 hachoir == 3.0a5
Mako == 1.0.9 Mako == 1.0.9
markdown2 == 2.3.6 markdown2 == 2.3.6
oauth2 == 1.9.0.post1 oauth2 == 1.9.0.post1
......
...@@ -5,6 +5,7 @@ from urllib.parse import urljoin ...@@ -5,6 +5,7 @@ from urllib.parse import urljoin
from oauthlib.oauth2 import MissingTokenError, InvalidClientIdError, TokenExpiredError, InvalidGrantError from oauthlib.oauth2 import MissingTokenError, InvalidClientIdError, TokenExpiredError, InvalidGrantError
from raven.utils.json import JSONDecodeError from raven.utils.json import JSONDecodeError
from requests import RequestException
from requests_oauthlib import OAuth2Session from requests_oauthlib import OAuth2Session
import sickrage import sickrage
...@@ -54,27 +55,33 @@ class API(object): ...@@ -54,27 +55,33 @@ class API(object):
return self._request('POST', 'account/private-key', data=dict({'privatekey': privatekey})) return self._request('POST', 'account/private-key', data=dict({'privatekey': privatekey}))
def _request(self, method, url, **kwargs): def _request(self, method, url, **kwargs):
try: latest_exception = None
resp = self.session.request(method, urljoin(self.api_url, url), timeout=30,
hooks={'response': self.throttle_hook}, **kwargs) for i in range(3):
try:
if resp.status_code in [401, 403]: resp = self.session.request(method, urljoin(self.api_url, url), timeout=30, hooks={'response': self.throttle_hook}, **kwargs)
if not self.token_refreshed: if resp.status_code in [401, 403]:
raise TokenExpiredError if not self.token_refreshed:
if 'error' in resp.json(): raise TokenExpiredError
raise ApiError(resp.json()['error']) if 'error' in resp.json():
elif resp.status_code >= 400: raise ApiError(resp.json()['error'])
if 'error' in resp.json(): elif resp.status_code >= 400:
raise ApiError(resp.json()['error']) if 'error' in resp.json():
elif resp.status_code == 204: raise ApiError(resp.json()['error'])
return elif resp.status_code == 204:
return
return resp.json()
except TokenExpiredError: return resp.json()
self.refresh_token() except TokenExpiredError:
return self._request(method, url, **kwargs) self.refresh_token()
except (InvalidClientIdError, MissingTokenError) as e: except (InvalidClientIdError, MissingTokenError) as e:
sickrage.app.log.warning("SiCKRAGE token issue, please try logging out and back in again to the web-ui") latest_exception = "SiCKRAGE token issue, please try logging out and back in again to the web-ui"
except RequestException as e:
latest_exception = e
time.sleep(1)
sickrage.app.log.warning('{!r}'.format(latest_exception))
def exchange_token(self, token, scope='offline_access'): def exchange_token(self, token, scope='offline_access'):
exchange = {'scope': scope, 'subject_token': token['access_token']} exchange = {'scope': scope, 'subject_token': token['access_token']}
...@@ -87,7 +94,7 @@ class API(object): ...@@ -87,7 +94,7 @@ class API(object):
try: try:
self.token = self.session.refresh_token(self.token_url, **extras) self.token = self.session.refresh_token(self.token_url, **extras)
except InvalidGrantError as e: except InvalidGrantError:
self.token = {} self.token = {}
return self.token return self.token
......
...@@ -307,7 +307,7 @@ class UpdateManager(object): ...@@ -307,7 +307,7 @@ class UpdateManager(object):
exit_status = p.returncode exit_status = p.returncode
if output: if output:
output = output.decode("utf-8", "ignore").strip() output = output.decode("utf-8", "ignore").strip() if isinstance(output, bytes) else output.strip()
except OSError: except OSError:
sickrage.app.log.info("Command " + ' '.join(cmd) + " didn't work") sickrage.app.log.info("Command " + ' '.join(cmd) + " didn't work")
exit_status = 1 exit_status = 1
...@@ -363,7 +363,7 @@ class UpdateManager(object): ...@@ -363,7 +363,7 @@ class UpdateManager(object):
exit_status = 1 exit_status = 1
if output: if output:
output = output.decode("utf-8", "ignore").strip() output = output.decode("utf-8", "ignore").strip() if isinstance(output, bytes) else output.strip()
return output, err, exit_status return output, err, exit_status
...@@ -400,7 +400,7 @@ class UpdateManager(object): ...@@ -400,7 +400,7 @@ class UpdateManager(object):
sickrage.app.log.warning('Unable to update requirements') sickrage.app.log.warning('Unable to update requirements')
if output: if output:
output = output.decode("utf-8", "ignore").strip() output = output.decode("utf-8", "ignore").strip() if isinstance(output, bytes) else output.strip()
sickrage.app.log.debug("PIP CMD OUTPUT: {}".format(output)) sickrage.app.log.debug("PIP CMD OUTPUT: {}".format(output))
requirements_file.close() requirements_file.close()
...@@ -631,9 +631,13 @@ class SourceUpdateManager(UpdateManager): ...@@ -631,9 +631,13 @@ class SourceUpdateManager(UpdateManager):
with tempfile.TemporaryDirectory(prefix='sr_update_', dir=sickrage.app.data_dir) as unpack_dir: with tempfile.TemporaryDirectory(prefix='sr_update_', dir=sickrage.app.data_dir) as unpack_dir:
sickrage.app.log.info("Extracting SiCKRAGE update file") sickrage.app.log.info("Extracting SiCKRAGE update file")
tar = tarfile.open(fileobj=update_tarfile, mode='r:gz') try:
tar.extractall(unpack_dir) tar = tarfile.open(fileobj=update_tarfile, mode='r:gz')
tar.close() tar.extractall(unpack_dir)
tar.close()
except tarfile.ReadError:
sickrage.app.log.warning("Invalid update data, update failed: not a gzip file")
return False
# find update dir name # find update dir name
update_dir_contents = [x for x in os.listdir(unpack_dir) if os.path.isdir(os.path.join(unpack_dir, x))] update_dir_contents = [x for x in os.listdir(unpack_dir) if os.path.isdir(os.path.join(unpack_dir, x))]
......
...@@ -947,10 +947,10 @@ class DisplayShowHandler(BaseHandler, ABC): ...@@ -947,10 +947,10 @@ class DisplayShowHandler(BaseHandler, ABC):
epCounts=ep_counts, epCounts=ep_counts,
epCats=ep_cats, epCats=ep_cats,
all_scene_exceptions=show_obj.exceptions, all_scene_exceptions=show_obj.exceptions,
scene_numbering=get_scene_numbering_for_show(indexer_id, indexer), scene_numbering=get_scene_numbering_for_show(indexer_id, indexer, session=self.db_session),
xem_numbering=get_xem_numbering_for_show(indexer_id, indexer), xem_numbering=get_xem_numbering_for_show(indexer_id, indexer, session=self.db_session),
scene_absolute_numbering=get_scene_absolute_numbering_for_show(indexer_id, indexer), scene_absolute_numbering=get_scene_absolute_numbering_for_show(indexer_id, indexer, session=self.db_session),
xem_absolute_numbering=get_xem_absolute_numbering_for_show(indexer_id, indexer), xem_absolute_numbering=get_xem_absolute_numbering_for_show(indexer_id, indexer, session=self.db_session),
title=show_obj.name, title=show_obj.name,
controller='home', controller='home',
action="display_show" action="display_show"
......
9.4.157 9.4.158
\ No newline at end of file \ No newline at end of file
Markdown is supported
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