From 7bb5b79901ca0172f679ec6c28d6927dd6bd7f15 Mon Sep 17 00:00:00 2001
From: Alexey Stratulat <alexey.stratulat@demlabs.net>
Date: Mon, 10 Jun 2019 17:25:08 +0700
Subject: [PATCH] =?UTF-8?q?Added=20check=20of=20return=20values=20?=
 =?UTF-8?q?=E2=80=8B=E2=80=8Band=20call=20exceptions.=20The=20call=20to=20?=
 =?UTF-8?q?the=20install=20logging=20level=20function=20from=20libdap=5Fpy?=
 =?UTF-8?q?thon=5Fmod=20is=20also=20executed.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/libdapConnector.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/libdapConnector.py b/src/libdapConnector.py
index 03c03b43..44500540 100644
--- a/src/libdapConnector.py
+++ b/src/libdapConnector.py
@@ -1,6 +1,9 @@
 import json
 import libdap_python_module
 
+class DapIniException(Exception):
+    pass
+
 class Dap:
     def __init__(self, data):
         res = json.loads(data)
@@ -8,8 +11,14 @@ class Dap:
         self.config_dir=res['dap']['config_dir']
         self.log_level=res['dap']['log_level']
         self.application_name=res['dap']['application_name']
-#        dap.init('/opt/var/ler\njaryt\ndebug')
-        libdap_python_module.init(res['dap']['config_dir']+"\n"+res['dap']['application_name']+"\n")
+        res_init = libdap_python_module.init(res['dap']['config_dir']+"\n"+res['dap']['application_name']+"\n")
+        if res_init == -1 or res_init == -2:
+            raise DapIniException("Initialization erorr")
     def __del__(self):
         libdap_python_module.deinit()
+    def setLogLevel(self, data):
+        self.log_level=data
+        res_setLogLevel = libdap_python_module.setLogLevel(data)
+        if res_setLogLevel == -1:
+            raise DapIniException("Failed to set the logging level, perhaps you did correctly specify the name of the level")
 
-- 
GitLab