Add status page and fix for #160

pull/249/head
Halali 6 years ago
parent bdbfde3b46
commit ac640e4054

@ -5,6 +5,8 @@ from get_settings import get_general_settings
import os
import logging
import sqlite3
import json
import requests
import git
@ -29,6 +31,7 @@ def gitconfig():
def check_and_apply_update():
gitconfig()
check_releases()
branch = get_general_settings()[5]
g = git.cmd.Git(current_working_directory)
g.fetch('origin')
@ -43,6 +46,28 @@ def check_and_apply_update():
logging.info('BAZARR Updated to latest version. Restart required. ' + result)
updated()
def check_releases():
releases = []
url_releases = 'https://api.github.com/repos/morpheus65535/Bazarr/releases'
try:
r = requests.get(url_releases, timeout=15)
r.raise_for_status()
except requests.exceptions.HTTPError as errh:
logging.exception("Error trying to get releases from Github. Http error.")
except requests.exceptions.ConnectionError as errc:
logging.exception("Error trying to get releases from Github. Connection Error.")
except requests.exceptions.Timeout as errt:
logging.exception("Error trying to get releases from Github. Timeout Error.")
except requests.exceptions.RequestException as err:
logging.exception("Error trying to get releases from Github.")
else:
for release in r.json():
releases.append([release['name'], release['body']])
with open(os.path.join(config_dir, 'config', 'releases.txt'), 'w') as f:
json.dump(releases, f)
def updated():
conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
c = conn.cursor()

@ -24,6 +24,11 @@ if os.path.exists(os.path.join(config_dir, 'db')) is False:
if os.path.exists(os.path.join(config_dir, 'log')) is False:
os.mkdir(os.path.join(config_dir, 'log'))
logging.debug("BAZARR Created log folder")
if not os.path.exists(os.path.join(config_dir, 'config', 'releases.txt')):
from check_update import check_releases
check_releases()
logging.debug("BAZARR Created releases file")
config_file = os.path.normpath(os.path.join(config_dir, 'config/config.ini'))

@ -1465,24 +1465,33 @@ def system():
page_size = int(get_general_settings()[21])
max_page = int(math.ceil(row_count / (page_size + 0.0)))
releases = []
url_releases = 'https://api.github.com/repos/morpheus65535/Bazarr/releases'
with open(os.path.join(config_dir, 'config', 'releases.txt'), 'r') as f:
releases = ast.literal_eval(f.read())
import platform
url_sonarr = get_sonarr_settings()[6]
apikey_sonarr = get_sonarr_settings()[4]
sv = url_sonarr + "/api/system/status?apikey=" + apikey_sonarr
try:
r = requests.get(url_releases, timeout=15)
r.raise_for_status()
except requests.exceptions.HTTPError as errh:
logging.exception("BAZARR Error trying to get releases from Github. Http error.")
except requests.exceptions.ConnectionError as errc:
logging.exception("BAZARR Error trying to get releases from Github. Connection Error.")
except requests.exceptions.Timeout as errt:
logging.exception("BAZARR Error trying to get releases from Github. Timeout Error.")
except requests.exceptions.RequestException as err:
logging.exception("BAZARR Error trying to get releases from Github.")
else:
for release in r.json():
releases.append([release['name'],release['body']])
sonarr_version = requests.get(sv, timeout=15, verify=False)
except:
sonarr_version = ''
url_radarr = get_radarr_settings()[6]
apikey_radarr = get_radarr_settings()[4]
sv = url_radarr + "/api/system/status?apikey=" + apikey_radarr
try:
radarr_version = requests.get(sv, timeout=15, verify=False)
except:
radarr_version = ''
return template('system', __file__=__file__, bazarr_version=bazarr_version,
sonarr_version=sonarr_version.json()['version'], radarr_version=radarr_version.json()['version'],
operation_system=platform.platform(), python_version=platform.python_version(),
config_dir=config_dir, bazarr_dir=os.getcwd(),
base_url=base_url, task_list=task_list, row_count=row_count, max_page=max_page, page_size=page_size,
releases=releases, current_port=port)
return template('system', __file__=__file__, bazarr_version=bazarr_version, base_url=base_url, task_list=task_list, row_count=row_count, max_page=max_page, page_size=page_size, releases=releases, current_port=port)
@route(base_url + 'logs/<page:int>')
@custom_auth_basic(check_credentials)

@ -7,7 +7,9 @@ from get_movies import update_movies
from list_subtitles import store_subtitles
from get_subtitle import wanted_search_missing_subtitles
if no_update is False:
from check_update import check_and_apply_update
from check_update import check_and_apply_update, check_releases
else:
from check_update import check_releases
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers.interval import IntervalTrigger
@ -66,6 +68,10 @@ if no_update is False:
scheduler.add_job(check_and_apply_update, IntervalTrigger(hours=6), max_instances=1, coalesce=True, misfire_grace_time=15, id='update_bazarr', name='Update bazarr from source on Github')
else:
scheduler.add_job(check_and_apply_update, CronTrigger(year='2100'), hour=4, id='update_bazarr', name='Update bazarr from source on Github')
scheduler.add_job(check_releases, IntervalTrigger(hours=6), max_instances=1, coalesce=True, misfire_grace_time=15, id='update_release', name='Update release info')
else:
scheduler.add_job(check_releases, IntervalTrigger(hours=6), max_instances=1, coalesce=True, misfire_grace_time=15,
id='update_release', name='Update release info')
if integration[12] is True:
scheduler.add_job(update_series, IntervalTrigger(minutes=1), max_instances=1, coalesce=True, misfire_grace_time=15, id='update_series', name='Update series list from Sonarr')

@ -53,6 +53,7 @@
<div class="ui top attached tabular menu">
<a class="tabs item active" data-tab="tasks">Tasks</a>
<a class="tabs item" data-tab="logs">Logs</a>
<a class="tabs item" data-tab="status">Status</a>
<a class="tabs item" data-tab="releases">Releases</a>
</div>
<div class="ui bottom attached tab segment active" data-tab="tasks">
@ -115,6 +116,144 @@
%end
</div>
</div>
<div class="ui bottom attached tab segment" data-tab="status">
<div class="ui dividing header">About</div>
<div class="twelve wide column">
<div class="ui grid">
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Version</label>
</div>
<div class="five wide column">
<div class='field'>
<div class="ui fluid input">
{{bazarr_version}}
</div>
</div>
</div>
</div>
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Operation system</label>
</div>
<div class="five wide column">
<div class='field'>
<div class="ui fluid input">
{{operation_system}}
</div>
</div>
</div>
</div>
% from get_settings import get_general_settings
% if get_general_settings()[12]:
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Sonarr version</label>
</div>
<div class="five wide column">
<div class='field'>
<div class="ui fluid input">
{{sonarr_version}}
</div>
</div>
</div>
</div>
% end
% if get_general_settings()[13]:
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Radarr version</label>
</div>
<div class="five wide column">
<div class='field'>
<div class="ui fluid input">
{{radarr_version}}
</div>
</div>
</div>
</div>
% end
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Python version</label>
</div>
<div class="five wide column">
<div class='field'>
<div class="ui fluid input">
{{python_version}}
</div>
</div>
</div>
</div>
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Bazarr config dir</label>
</div>
<div class="five wide column">
<div class='field'>
<div class="ui fluid input">
{{config_dir}}
</div>
</div>
</div>
</div>
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Bazarr directory</label>
</div>
<div class="five wide column">
<div class='field'>
<div class="ui fluid input">
{{bazarr_dir}}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="ui dividing header">More info</div>
<div class="twelve wide column">
<div class="ui grid">
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Source</label>
</div>
<div class="five wide column">
<div class='field'>
<div class="ui fluid input">
<i class="github icon"></i><a href="https://github.com/morpheus65535/bazarr">Bazarr on GitHub</a>
</div>
</div>
</div>
</div>
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Wiki</label>
</div>
<div class="five wide column">
<div class='field'>
<div class="ui fluid input">
<i class="wikipedia w icon"></i><a href=https://github.com/morpheus65535/bazarr/wiki">Bazarr Wiki</a>
</div>
</div>
</div>
</div>
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Discord</label>
</div>
<div class="five wide column">
<div class='field'>
<div class="ui fluid input">
<i class="discord icon"></i><a href="https://discord.gg/MH2e2eb">Bazarr on Discord</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="ui bottom attached tab segment" data-tab="releases">
%for release in releases:

Loading…
Cancel
Save