diff --git a/bazarr.py b/bazarr.py index ff5231f9a..e7025bebf 100644 --- a/bazarr.py +++ b/bazarr.py @@ -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.') diff --git a/check_update.py b/check_update.py index 53878d754..123691dd6 100644 --- a/check_update.py +++ b/check_update.py @@ -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() \ No newline at end of file diff --git a/update_db.py b/update_db.py index 7b757e187..f5d0912ee 100644 --- a/update_db.py +++ b/update_db.py @@ -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() diff --git a/views/menu.tpl b/views/menu.tpl index 853d32a5e..c036fad25 100644 --- a/views/menu.tpl +++ b/views/menu.tpl @@ -18,10 +18,19 @@ color: white !important; border-radius: 3px !important; } + .search.icon { + color: white !important; + }
-