Browse Source

Silenced exception for dispose_engine

ogert 4 years ago
parent
commit
ee2def1fea
3 changed files with 35 additions and 2 deletions
  1. 5 2
      cdplib/db_handlers/SQLHandler.py
  2. 13 0
      hooks/README.txt
  3. 17 0
      hooks/pre-commit

+ 5 - 2
cdplib/db_handlers/SQLHandler.py

@@ -642,5 +642,8 @@ class SQLHandler:
         try:
             self._engine.dispose()
         except Exception as e:
-            print(('An error occured when trying to dispose the SQL engine. Error: {}').format(e))
-            raise Exception(e)
+            #print(('An error occured when trying to dispose the SQL engine. Error: {}').format(e))
+            #raise Exception(e)
+            # Exception occures rather frequently, but doesnt seem to affect the execution of the script
+            # Exception is thrown when trying to dispose of a engine that no longer exists.
+            # The exception has been silenced since no way of seeing if the engine still exists before disposing of it has been found.

+ 13 - 0
hooks/README.txt

@@ -0,0 +1,13 @@
+These files are GIT HOOKS.
+
+A git hook is a a script which is executed when a git command is run.
+The hook in this folder is executed when commiting (pre-commit).
+
+pre-commit executes the unit tests before commiting the changes.
+
+ACHTUNG!
+Changes will still be commited and pushed even if there are errors in the test (for now at least).
+So please pay attention to the tests an make sure that they ran without any problems. If the test
+failed, please fix the issue before pushing the changes!
+
+To use it please copy the files into your .git/hooks folder.

+ 17 - 0
hooks/pre-commit

@@ -0,0 +1,17 @@
+#!/bin/bash
+#
+# Runs test pipeline before commiting
+#
+# To enable this hook, rename this file to "pre-commit".
+echo
+echo "Running unit tests"
+echo
+
+python cdplib/unit_tests/TestFlattenData.py
+python cdplib/unit_tests/TestLog.py
+python cdplib/unit_tests/TestMongodbHandler.py
+
+echo 
+echo
+echo -e "\033 Unit tests have been run and your data commited, in case any of the tests failed, please correct this before pushing changes"
+echo