aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2017-12-22 22:40:14 -0500
committermorpheus65535 <[email protected]>2017-12-22 22:40:14 -0500
commit4a6c2e8e230243c4ef5c865d7732fcc4dbb462c9 (patch)
tree73593ab1e011558d09c581f314445f057a43b2e9
parentcf22583c327ed1733632420f5f0270f7fb83fd8d (diff)
downloadbazarr-4a6c2e8e230243c4ef5c865d7732fcc4dbb462c9.tar.gz
bazarr-4a6c2e8e230243c4ef5c865d7732fcc4dbb462c9.zip
Display message id restart is required and show wanted count on icon.
-rw-r--r--bazarr.py24
-rw-r--r--check_update.py11
-rw-r--r--update_db.py6
-rw-r--r--views/menu.tpl28
4 files changed, 64 insertions, 5 deletions
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;
+ }
</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>