Catch error in file remove process

Catch an error in the file removing process after a database dump for
windows users (issue #40)
This commit is contained in:
Lea Laux 2021-03-03 11:55:41 +01:00 committed by KDV Admin
parent f09602d5d3
commit 6e61a74250

View File

@ -73,12 +73,20 @@ class DatabaseDumper:
# If an exception occurs, for example triggered by a timeout, save a message in the log. # If an exception occurs, for example triggered by a timeout, save a message in the log.
except Exception as error: except Exception as error:
logging.error("An error occurred during the dumping process: {}".format(error)) logging.error("An error occurred during the dumping process: {}".format(error), exc_info=True)
# Use a finally block for a short clean up. # Use a finally block for a short clean up.
finally: finally:
# Try to remove the file. Use a try statement, because this block can cause errors for windows user.
try:
# Remove the file, which was used for submitting the password and is no longer necessary. # Remove the file, which was used for submitting the password and is no longer necessary.
os.remove(file_path) os.remove(file_path)
# Add the exception to the log.
except Exception as error:
logging.error("An error occurred during the clean up process of the database dump: {}".format(
error), exc_info=True)
# Return the result. # Return the result.
return result return result