Improved gdrive error messages (#554)

pull/530/merge
Ozzie Isaacs 6 years ago
parent 6a76dce870
commit 4d6299f0d5

@ -1,6 +1,7 @@
try: try:
from pydrive.auth import GoogleAuth from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive from pydrive.drive import GoogleDrive
from pydrive.auth import RefreshError
from apiclient import errors from apiclient import errors
except ImportError: except ImportError:
pass pass
@ -132,8 +133,10 @@ def getDrive(drive=None, gauth=None):
# Refresh them if expired # Refresh them if expired
try: try:
gauth.Refresh() gauth.Refresh()
except: except RefreshError as e:
web.app.logger.error("Google Drive gdrive_credentials file not present, reauthenticate in config section") web.app.logger.error("Google Drive error: " + e.message)
except Exception as e:
web.app.logger.exception(e)
else: else:
# Initialize the saved creds # Initialize the saved creds
gauth.Authorize() gauth.Authorize()

@ -1800,7 +1800,8 @@ def get_cover(cover_path):
app.logger.error(cover_path + '/cover.jpg not found on Google Drive') app.logger.error(cover_path + '/cover.jpg not found on Google Drive')
return send_from_directory(os.path.join(os.path.dirname(__file__), "static"), "generic_cover.jpg") return send_from_directory(os.path.join(os.path.dirname(__file__), "static"), "generic_cover.jpg")
except Exception as e: except Exception as e:
app.logger.error("Message "+e.message) app.logger.error("Error Message: "+e.message)
app.logger.exception(e)
# traceback.print_exc() # traceback.print_exc()
return send_from_directory(os.path.join(os.path.dirname(__file__), "static"),"generic_cover.jpg") return send_from_directory(os.path.join(os.path.dirname(__file__), "static"),"generic_cover.jpg")
else: else:
@ -2721,7 +2722,7 @@ def configuration_helper(origin):
config.loadSettings() config.loadSettings()
app.logger.setLevel(config.config_log_level) app.logger.setLevel(config.config_log_level)
logging.getLogger("book_formats").setLevel(config.config_log_level) logging.getLogger("book_formats").setLevel(config.config_log_level)
except e: except Exception as e:
flash(e, category="error") flash(e, category="error")
return render_title_template("config_edit.html", content=config, origin=origin, gdrive=gdrive_support, return render_title_template("config_edit.html", content=config, origin=origin, gdrive=gdrive_support,
gdriveError=gdriveError, goodreads=goodreads_support, gdriveError=gdriveError, goodreads=goodreads_support,
@ -2846,7 +2847,7 @@ def edit_mailsettings():
try: try:
ub.session.commit() ub.session.commit()
flash(_(u"Mail settings updated"), category="success") flash(_(u"Mail settings updated"), category="success")
except e: except Exception as e:
flash(e, category="error") flash(e, category="error")
if "test" in to_save and to_save["test"]: if "test" in to_save and to_save["test"]:
if current_user.kindle_mail: if current_user.kindle_mail:

Loading…
Cancel
Save