bazarr/check_update.py

26 lines
730 B
Python
Raw Normal View History

2017-10-28 10:18:16 +08:00
from get_general_settings import *
2017-11-07 12:53:31 +08:00
import os
2017-12-06 12:07:37 +08:00
import logging
import sqlite3
2017-11-07 12:53:31 +08:00
2017-12-30 13:09:51 +08:00
import git
2017-12-06 04:02:08 +08:00
2017-12-30 13:09:51 +08:00
current_working_directory = os.path.dirname(__file__)
2017-11-22 05:09:33 +08:00
2017-12-30 13:09:51 +08:00
def check_and_apply_update():
g = git.cmd.Git(current_working_directory)
result = g.pull('origin', branch)
2017-12-30 21:33:36 +08:00
if result.startswith('Already'):
logging.info('No new version of Bazarr available.')
else:
2017-12-30 21:23:45 +08:00
#logging.info('Bazarr updated to latest version and need to be restarted.')
logging.info(result)
2017-12-30 13:09:51 +08:00
updated()
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()