mirror of
https://github.com/morpheus65535/bazarr
synced 2025-01-02 21:15:41 +00:00
Improve logging
This commit is contained in:
parent
fe5a480bca
commit
248b524b92
5 changed files with 20 additions and 9 deletions
|
@ -291,14 +291,15 @@ def save_settings():
|
|||
conn.commit()
|
||||
c.close()
|
||||
|
||||
logging.info('Settings saved succefully. You must restart Bazarr.')
|
||||
|
||||
redirect(ref)
|
||||
|
||||
@route(base_url + 'check_update')
|
||||
def check_update():
|
||||
ref = request.environ['HTTP_REFERER']
|
||||
|
||||
result = check_and_apply_update()
|
||||
logging.info(result)
|
||||
check_and_apply_update()
|
||||
|
||||
redirect(ref)
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ from get_general_settings import *
|
|||
|
||||
import os
|
||||
import pygit2
|
||||
import logging
|
||||
|
||||
current_working_directory = os.path.dirname(__file__)
|
||||
repository_path = pygit2.discover_repository(current_working_directory)
|
||||
|
@ -20,7 +21,7 @@ def check_and_apply_update(repo=local_repo, remote_name='origin'):
|
|||
merge_result, _ = repo.merge_analysis(remote_id)
|
||||
# Up to date, do nothing
|
||||
if merge_result & pygit2.GIT_MERGE_ANALYSIS_UP_TO_DATE:
|
||||
result = 'No new version of Bazarr available.'
|
||||
logging.info('No new version of Bazarr available.')
|
||||
pass
|
||||
# We can just fastforward
|
||||
elif merge_result & pygit2.GIT_MERGE_ANALYSIS_FASTFORWARD:
|
||||
|
@ -28,7 +29,7 @@ def check_and_apply_update(repo=local_repo, remote_name='origin'):
|
|||
master_ref = repo.lookup_reference('refs/remotes/origin/' + str(branch))
|
||||
master_ref.set_target(remote_id)
|
||||
repo.head.set_target(remote_id)
|
||||
result = 'Bazarr updated to latest version and restarting.'
|
||||
logging.info('Bazarr updated to latest version and restarting.')
|
||||
os.execlp('python', 'python', os.path.join(os.path.dirname(__file__), 'bazarr.py'))
|
||||
# We can just do it normally
|
||||
elif merge_result & pygit2.GIT_MERGE_ANALYSIS_NORMAL:
|
||||
|
@ -45,10 +46,8 @@ def check_and_apply_update(repo=local_repo, remote_name='origin'):
|
|||
tree,
|
||||
[repo.head.target, remote_id])
|
||||
repo.state_cleanup()
|
||||
result = 'Conflict detected when trying to update.'
|
||||
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:
|
||||
result = 'Bazarr cannot be updated: Unknown merge analysis result'
|
||||
|
||||
return result
|
||||
logging.error('Bazarr cannot be updated: Unknown merge analysis result')
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import sqlite3
|
||||
import requests
|
||||
import logging
|
||||
|
||||
from get_general_settings import *
|
||||
from list_subtitles import *
|
||||
|
@ -61,9 +62,13 @@ def update_all_episodes():
|
|||
# Close database connection
|
||||
c.close()
|
||||
|
||||
logging.info('All episodes updated in database.')
|
||||
|
||||
# Store substitles for all episodes
|
||||
full_scan_subtitles()
|
||||
logging.info('All existing subtitles indexed from disk.')
|
||||
list_missing_subtitles()
|
||||
logging.info('All missing subtitles updated in database.')
|
||||
|
||||
def add_new_episodes():
|
||||
# Open database connection
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import sqlite3
|
||||
import ast
|
||||
import logging
|
||||
from babelfish import *
|
||||
from subliminal import *
|
||||
from pycountry import *
|
||||
|
@ -79,3 +80,5 @@ def wanted_search_missing_subtitles():
|
|||
|
||||
for episode in data:
|
||||
wanted_download_subtitles(episode[0])
|
||||
|
||||
logging.info('Finished searching for missing subtitles. Check history for more information.')
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import sqlite3
|
||||
import logging
|
||||
|
||||
# Check if database exist
|
||||
if os.path.exists(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) == True:
|
||||
|
@ -42,3 +43,5 @@ else:
|
|||
|
||||
# Close database connection
|
||||
db.close()
|
||||
|
||||
logging.info('Database created successfully')
|
Loading…
Reference in a new issue