2017-10-28 02:18:16 +00:00
|
|
|
from get_general_settings import *
|
|
|
|
|
2017-11-07 04:53:31 +00:00
|
|
|
import os
|
2017-12-06 04:07:37 +00:00
|
|
|
import logging
|
2017-12-23 03:40:14 +00:00
|
|
|
import sqlite3
|
2017-11-07 04:53:31 +00:00
|
|
|
|
2017-12-30 05:09:51 +00:00
|
|
|
import git
|
2017-12-05 20:02:08 +00:00
|
|
|
|
2017-12-30 05:09:51 +00:00
|
|
|
current_working_directory = os.path.dirname(__file__)
|
2017-11-21 21:09:33 +00:00
|
|
|
|
2018-01-16 04:00:29 +00:00
|
|
|
def gitconfig():
|
|
|
|
g = git.Repo.init(current_working_directory)
|
|
|
|
config_read = g.config_reader()
|
|
|
|
config_write = g.config_writer()
|
|
|
|
|
|
|
|
try:
|
|
|
|
username = config_read.get_value("user", "name")
|
|
|
|
except:
|
|
|
|
config_write.set_value("user", "name", "Bazarr")
|
|
|
|
|
|
|
|
try:
|
|
|
|
email = config_read.get_value("user", "email")
|
|
|
|
except:
|
|
|
|
config_write.set_value("user", "email", "bazarr@fake.email")
|
|
|
|
|
2017-12-30 05:09:51 +00:00
|
|
|
def check_and_apply_update():
|
2018-01-16 04:00:29 +00:00
|
|
|
gitconfig()
|
2017-12-30 05:09:51 +00:00
|
|
|
g = git.cmd.Git(current_working_directory)
|
|
|
|
result = g.pull('origin', branch)
|
2017-12-30 13:33:36 +00:00
|
|
|
if result.startswith('Already'):
|
|
|
|
logging.info('No new version of Bazarr available.')
|
2018-01-16 04:29:15 +00:00
|
|
|
elif result.startswith('Updating') or result.startswith('Merge made'):
|
2018-01-01 15:31:06 +00:00
|
|
|
logging.info('Bazarr updated to latest version and need to be restarted.')
|
2018-01-01 19:35:32 +00:00
|
|
|
updated()
|
2017-12-30 13:33:36 +00:00
|
|
|
else:
|
2017-12-30 13:23:45 +00:00
|
|
|
logging.info(result)
|
2017-12-23 03:40:14 +00:00
|
|
|
|
|
|
|
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()
|