[sr-dev] git:5.2:4061a1d7: utils/kamctl: dbtextdb.py close previous opened file properly

Victor Seva linuxmaniac at torreviejawireless.org
Mon May 4 17:08:19 CEST 2020


Module: kamailio
Branch: 5.2
Commit: 4061a1d7cd130a5c3e4236c2abb999658ee02e36
URL: https://github.com/kamailio/kamailio/commit/4061a1d7cd130a5c3e4236c2abb999658ee02e36

Author: Victor Seva <linuxmaniac at torreviejawireless.org>
Committer: Victor Seva <linuxmaniac at torreviejawireless.org>
Date: 2020-05-04T17:07:58+02:00

utils/kamctl: dbtextdb.py close previous opened file properly

related #1747

(cherry picked from commit 5f52f9905bbdf63d636080f7d0340af4f71ed12a)
(cherry picked from commit e26e587f31eb23c431a2cfb149ec7a86b4f648bc)

---

Modified: utils/kamctl/dbtextdb/dbtextdb.py

---

Diff:  https://github.com/kamailio/kamailio/commit/4061a1d7cd130a5c3e4236c2abb999658ee02e36.diff
Patch: https://github.com/kamailio/kamailio/commit/4061a1d7cd130a5c3e4236c2abb999658ee02e36.patch

---

diff --git a/utils/kamctl/dbtextdb/dbtextdb.py b/utils/kamctl/dbtextdb/dbtextdb.py
index 7e1de04687..581496c309 100755
--- a/utils/kamctl/dbtextdb/dbtextdb.py
+++ b/utils/kamctl/dbtextdb/dbtextdb.py
@@ -60,6 +60,10 @@ def __init__(self, location):
         if not os.path.isdir(location):
             raise ParseError(location + ' is not a directory')
 
+    def __del__(self):
+        if getattr(self, 'fd', False):
+            self.fd.close()
+
     def _ParseOrderBy(self):
         """Parse out the column name to be used for ordering the dataset.
 
@@ -438,6 +442,8 @@ def CleanUp(self):
         self.command = ''     # which command are we executing
         self.strings = []     # list of string literals parsed from the query
         self.parens = []      # list of parentheses parsed from the query
+        if getattr(self, 'fd', False):
+            self.fd.close()
 
     def ParseQuery(self, query):
         """External wrapper for the query parsing routines.




More information about the sr-dev mailing list