Display message id restart is required and show wanted count on icon.

pull/26/head
morpheus65535 7 years ago
parent cf22583c32
commit 4a6c2e8e23

@ -23,6 +23,13 @@ import urllib
from init_db import *
import update_db
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
c = conn.cursor()
c.execute("UPDATE table_settings_general SET configured = 0, updated = 0")
conn.commit()
c.close()
from get_languages import *
from get_providers import *
@ -306,7 +313,13 @@ def save_settings():
settings_general_automatic = 'False'
else:
settings_general_automatic = 'True'
c.execute("UPDATE table_settings_general SET ip = ?, port = ?, base_url = ?, path_mapping = ?, log_level = ?, branch=?, auto_update=?", (settings_general_ip, settings_general_port, settings_general_baseurl, str(settings_general_pathmapping), settings_general_loglevel, settings_general_branch, settings_general_automatic))
before = c.execute("SELECT ip, port, base_url FROM table_settings_general").fetchone()
after = (unicode(settings_general_ip), int(settings_general_port), unicode(settings_general_baseurl))
c.execute("UPDATE table_settings_general SET ip = ?, port = ?, base_url = ?, path_mapping = ?, log_level = ?, branch=?, auto_update=?", (unicode(settings_general_ip), int(settings_general_port), unicode(settings_general_baseurl), unicode(settings_general_pathmapping), unicode(settings_general_loglevel), unicode(settings_general_branch), unicode(settings_general_automatic)))
conn.commit()
if after != before:
configured()
get_general_settings()
settings_sonarr_ip = request.forms.get('settings_sonarr_ip')
@ -343,7 +356,7 @@ def save_settings():
conn.commit()
c.close()
logging.info('Settings saved succefully. You must restart Bazarr.')
logging.info('Settings saved succefully.')
redirect(ref)
@ -534,6 +547,13 @@ def get_subtitle():
except OSError:
pass
def configured():
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
c = conn.cursor()
c.execute("UPDATE table_settings_general SET configured = 1")
conn.commit()
c.close()
logging.info('Bazarr is started and waiting for request on http://' + str(ip) + ':' + str(port) + str(base_url))
run(host=ip, port=port, server='waitress')
logging.info('Bazarr has been stopped.')

@ -3,6 +3,7 @@ from get_general_settings import *
import os
import pygit2
import logging
import sqlite3
current_working_directory = os.path.dirname(__file__)
repository_path = pygit2.discover_repository(current_working_directory)
@ -30,7 +31,7 @@ def check_and_apply_update(repo=local_repo, remote_name='origin'):
master_ref.set_target(remote_id)
repo.head.set_target(remote_id)
logging.info('Bazarr updated to latest version and need to be restarted.')
#os.execlp('python', 'python', os.path.join(os.path.dirname(__file__), 'bazarr.py'))
updated()
# We can just do it normally
elif merge_result & pygit2.GIT_MERGE_ANALYSIS_NORMAL:
repo.merge(remote_id)
@ -47,7 +48,13 @@ def check_and_apply_update(repo=local_repo, remote_name='origin'):
[repo.head.target, remote_id])
repo.state_cleanup()
logging.error('Conflict detected when trying to update.')
#os.execlp('python', 'python', os.path.join(os.path.dirname(__file__), 'bazarr.py'))
# We can't do it
else:
logging.error('Bazarr cannot be updated: Unknown merge analysis result')
def updated():
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
c = conn.cursor()
c.execute("UPDATE table_settings_general SET updated = 1")
conn.commit()
c.close()

@ -25,6 +25,12 @@ if os.path.exists(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
except:
pass
try:
c.execute('alter table table_settings_general add column "configured" "integer"')
c.execute('alter table table_settings_general add column "updated" "integer"')
except:
pass
# Commit change to db
db.commit()

@ -18,10 +18,19 @@
color: white !important;
border-radius: 3px !important;
}
.search.icon {
color: white !important;
}
</style>
</head>
<body>
<div id="divmenu" class="ui container">
% import sqlite3
% conn = sqlite3.connect('data/db/bazarr.db', timeout=30)
% c = conn.cursor()
% wanted = c.execute("SELECT COUNT(*) FROM table_episodes WHERE missing_subtitles != '[]'").fetchone()
<div id="divmenu" class="ui container">
<div class="ui grid">
<div class="middle aligned row">
<div class="three wide column">
@ -44,6 +53,11 @@
</a>
<a class="item" href="{{base_url}}wanted">
<i class="warning sign icon"></i>
% if wanted[0] > 0:
<div class="floating ui tiny yellow label">
{{wanted[0]}}
</div>
% end
Wanted
</a>
<a class="item" href="{{base_url}}settings">
@ -78,6 +92,18 @@
</div>
</div>
</div>
% restart_required = c.execute("SELECT updated, configured FROM table_settings_general").fetchone()
% conn.commit()
% c.close()
% if restart_required[0] == 1 and restart_required[1] == 1:
<div class='ui center aligned grid'><div class='fifteen wide column'><div class="ui red message">Bazarr need to be restarted to apply last update and changes to general settings.</div></div></div>
% elif restart_required[0] == 1:
<div class='ui center aligned grid'><div class='fifteen wide column'><div class="ui red message">Bazarr need to be restarted to apply last update.</div></div></div>
% elif restart_required[1] == 1:
<div class='ui center aligned grid'><div class='fifteen wide column'><div class="ui red message">Bazarr need to be restarted to apply changes to general settings.</div></div></div>
% end
</body>
</html>

Loading…
Cancel
Save