Improve logging

This commit is contained in:
Bazarr user 2017-12-05 23:07:37 -05:00
parent fe5a480bca
commit 248b524b92
5 changed files with 20 additions and 9 deletions

View File

@ -290,6 +290,8 @@ def save_settings():
conn.commit()
c.close()
logging.info('Settings saved succefully. You must restart Bazarr.')
redirect(ref)
@ -297,8 +299,7 @@ def save_settings():
def check_update():
ref = request.environ['HTTP_REFERER']
result = check_and_apply_update()
logging.info(result)
check_and_apply_update()
redirect(ref)

View File

@ -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')

View File

@ -1,6 +1,7 @@
import os
import sqlite3
import requests
import logging
from get_general_settings import *
from list_subtitles import *
@ -60,10 +61,14 @@ 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

View File

@ -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.')

View File

@ -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:
@ -41,4 +42,6 @@ else:
c.executescript(script)
# Close database connection
db.close()
db.close()
logging.info('Database created successfully')