Module: kamailio
Branch: 5.2
Commit: 4061a1d7cd130a5c3e4236c2abb999658ee02e36
URL: https://github.com/kamailio/kamailio/commit/4061a1d7cd130a5c3e4236c2abb9996…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)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/4061a1d7cd130a5c3e4236c2abb9996…
Patch: https://github.com/kamailio/kamailio/commit/4061a1d7cd130a5c3e4236c2abb9996…
---
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.
Module: kamailio
Branch: 5.2
Commit: a2660fbe2e974553f0146c9ee84fcc6fa2f8f705
URL: https://github.com/kamailio/kamailio/commit/a2660fbe2e974553f0146c9ee84fcc6…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-05-04T17:07:05+02:00
utils/kamctl: fix dbtestdb
some indentantion errors introduced at https://github.com/kamailio/kamailio/commit/bc8bdcaa726f375f6deea8228a1ab0c…
related #1747
(cherry picked from commit b722a48144ac9e029bdbc2968dedbe56966a3f7c)
(cherry picked from commit c4dd3218e6b723c688762a5c4253fa70f3f588bc)
---
Modified: utils/kamctl/dbtextdb/dbtextdb.py
---
Diff: https://github.com/kamailio/kamailio/commit/a2660fbe2e974553f0146c9ee84fcc6…
Patch: https://github.com/kamailio/kamailio/commit/a2660fbe2e974553f0146c9ee84fcc6…
---
diff --git a/utils/kamctl/dbtextdb/dbtextdb.py b/utils/kamctl/dbtextdb/dbtextdb.py
index 3d5ee7ecc5..7e1de04687 100755
--- a/utils/kamctl/dbtextdb/dbtextdb.py
+++ b/utils/kamctl/dbtextdb/dbtextdb.py
@@ -146,11 +146,11 @@ def _ParseColumns(self):
# check if there is a function modifier on the columns
if self.tokens[0] == 'COUNT':
self.count = True
- if col_end == 1:
- raise ParseError('COUNT must be followed by column name[s]')
- if not self.tokens[1].startswith(self._paren_placeholder):
- raise ParseError('COUNT must be followed by ()')
- cols_str = self._ReplaceParens(self.tokens[1])
+ if col_end == 1:
+ raise ParseError('COUNT must be followed by column name[s]')
+ if not self.tokens[1].startswith(self._paren_placeholder):
+ raise ParseError('COUNT must be followed by ()')
+ cols_str = self._ReplaceParens(self.tokens[1])
cols = cols_str.split(',')
for col in cols:
@@ -300,7 +300,7 @@ def _ParseTargets(self):
if self.tokens.pop(0) != 'SET':
raise ParseError('UPDATE command must be followed by SET')
- self.targets = self._ParsePairs(' '.join(self.tokens), ',')
+ self.targets = self._ParsePairs(' '.join(self.tokens), ',')
# INSERT
if self.command == 'INSERT':
@@ -570,19 +570,19 @@ def _ParseOutHelper(self, placeholder, delims, mode):
string = '%s%s' % (string, c)
continue # wait for matching delim
- started -= 1
- if not started:
- values.append(string)
- new_args = '%s %s' % (new_args, '%s%d' % (placeholder,
- my_id))
- my_id += 1
- string = ''
+ started -= 1
+ if not started:
+ values.append(string)
+ new_args = '%s %s' % (new_args, '%s%d' % (placeholder,
+ my_id))
+ my_id += 1
+ string = ''
- else:
- if not started:
- new_args = '%s%s' % (new_args, c)
else:
- string = '%s%s' % (string, c)
+ if not started:
+ new_args = '%s%s' % (new_args, c)
+ else:
+ string = '%s%s' % (string, c)
if started:
if mode == 'parens':
@@ -714,8 +714,8 @@ def _RunInsert(self):
elif self.header[col]['auto']:
new_row[col] = self._GetNextAuto(col)
- else:
- raise ExecuteError(col + ' cannot be empty or null')
+ else:
+ raise ExecuteError(col + ' cannot be empty or null')
self.data.append(new_row)
return [1]
Module: kamailio
Branch: 5.2
Commit: 23062ed50ea4e6b6e00468cc7f8ec57ccc613429
URL: https://github.com/kamailio/kamailio/commit/23062ed50ea4e6b6e00468cc7f8ec57…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-05-04T17:07:04+02:00
utils/kamctl: fix handling of Exceptions
> Traceback (most recent call last):
> File "/usr/lib/x86_64-linux-gnu/kamailio/kamctl/dbtextdb/dbtextdb.py", line 1239, in <module>
> main(sys.argv)
> File "/usr/lib/x86_64-linux-gnu/kamailio/kamctl/dbtextdb/dbtextdb.py", line 1233, in main
> except (Error, e):
> NameError: name 'e' is not defined
(cherry picked from commit 1aca79c43cb8dbd920c1eb81c0c30cf89f0985b9)
(cherry picked from commit 5f6f4331811e654e75b49263f8fb823bea9874a3)
---
Modified: utils/kamctl/dbtextdb/dbtextdb.py
---
Diff: https://github.com/kamailio/kamailio/commit/23062ed50ea4e6b6e00468cc7f8ec57…
Patch: https://github.com/kamailio/kamailio/commit/23062ed50ea4e6b6e00468cc7f8ec57…
---
diff --git a/utils/kamctl/dbtextdb/dbtextdb.py b/utils/kamctl/dbtextdb/dbtextdb.py
index 3a35554013..3d5ee7ecc5 100755
--- a/utils/kamctl/dbtextdb/dbtextdb.py
+++ b/utils/kamctl/dbtextdb/dbtextdb.py
@@ -356,7 +356,7 @@ def _EscapeChars(self, value):
# test that the value is string, if not return it as is
try:
value.find('a')
- except:
+ except Exception:
return value
escaped = value
@@ -377,7 +377,7 @@ def _UnEscapeChars(self, value):
# test that the value is string, if not return it as is
try:
value.find('a')
- except:
+ except Exception:
return value
escaped = value
@@ -988,21 +988,19 @@ def _TypeCheck(self, val, col):
if not val and not self.header[col]['null']:
raise ExecuteError(col + ' cannot be empty or null')
- if (self.header[col]['type'].lower() == 'int' or
- self.header[col]['type'].lower() == 'double'):
+ hdr_t = self.header[col]['type'].lower()
+ if hdr_t == 'int' or hdr_t == 'double':
try:
if val:
val = eval(val)
- except (NameError, e):
+ except NameError as e:
raise ExecuteError('Failed to parse %s in %s '
'(unable to convert to type %s): %s' %
- (col, self.table, self.header[col]['type'],
- e))
- except (SyntaxError, e):
+ (col, self.table, hdr_t, e))
+ except SyntaxError as e:
raise ExecuteError('Failed to parse %s in %s '
'(unable to convert to type %s): %s' %
- (col, self.table, self.header[col]['type'],
- e))
+ (col, self.table, hdr_t, e))
return val
@@ -1083,7 +1081,7 @@ def OpenTable(self):
# save a copy of the data before modifying
self.orig_data = self.data[:]
- except (IOError, e):
+ except IOError as e:
raise ExecuteError('Unable to open table %s: %s' % (self.table, e))
Debug('Header is: %s' % self.header)
@@ -1230,7 +1228,7 @@ def main(argv):
print('Updated %s, rows affected: %d' % (conn.table, row))
else:
print(row)
- except (Error, e):
+ except Error as e:
print(e)
sys.exit(1)
Module: kamailio
Branch: 5.3
Commit: e26e587f31eb23c431a2cfb149ec7a86b4f648bc
URL: https://github.com/kamailio/kamailio/commit/e26e587f31eb23c431a2cfb149ec7a8…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-05-04T17:01:53+02:00
utils/kamctl: dbtextdb.py close previous opened file properly
related #1747
(cherry picked from commit 5f52f9905bbdf63d636080f7d0340af4f71ed12a)
---
Modified: utils/kamctl/dbtextdb/dbtextdb.py
---
Diff: https://github.com/kamailio/kamailio/commit/e26e587f31eb23c431a2cfb149ec7a8…
Patch: https://github.com/kamailio/kamailio/commit/e26e587f31eb23c431a2cfb149ec7a8…
---
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.
Module: kamailio
Branch: 5.3
Commit: c4dd3218e6b723c688762a5c4253fa70f3f588bc
URL: https://github.com/kamailio/kamailio/commit/c4dd3218e6b723c688762a5c4253fa7…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-05-04T17:01:19+02:00
utils/kamctl: fix dbtestdb
some indentantion errors introduced at https://github.com/kamailio/kamailio/commit/bc8bdcaa726f375f6deea8228a1ab0c…
related #1747
(cherry picked from commit b722a48144ac9e029bdbc2968dedbe56966a3f7c)
---
Modified: utils/kamctl/dbtextdb/dbtextdb.py
---
Diff: https://github.com/kamailio/kamailio/commit/c4dd3218e6b723c688762a5c4253fa7…
Patch: https://github.com/kamailio/kamailio/commit/c4dd3218e6b723c688762a5c4253fa7…
---
diff --git a/utils/kamctl/dbtextdb/dbtextdb.py b/utils/kamctl/dbtextdb/dbtextdb.py
index 3d5ee7ecc5..7e1de04687 100755
--- a/utils/kamctl/dbtextdb/dbtextdb.py
+++ b/utils/kamctl/dbtextdb/dbtextdb.py
@@ -146,11 +146,11 @@ def _ParseColumns(self):
# check if there is a function modifier on the columns
if self.tokens[0] == 'COUNT':
self.count = True
- if col_end == 1:
- raise ParseError('COUNT must be followed by column name[s]')
- if not self.tokens[1].startswith(self._paren_placeholder):
- raise ParseError('COUNT must be followed by ()')
- cols_str = self._ReplaceParens(self.tokens[1])
+ if col_end == 1:
+ raise ParseError('COUNT must be followed by column name[s]')
+ if not self.tokens[1].startswith(self._paren_placeholder):
+ raise ParseError('COUNT must be followed by ()')
+ cols_str = self._ReplaceParens(self.tokens[1])
cols = cols_str.split(',')
for col in cols:
@@ -300,7 +300,7 @@ def _ParseTargets(self):
if self.tokens.pop(0) != 'SET':
raise ParseError('UPDATE command must be followed by SET')
- self.targets = self._ParsePairs(' '.join(self.tokens), ',')
+ self.targets = self._ParsePairs(' '.join(self.tokens), ',')
# INSERT
if self.command == 'INSERT':
@@ -570,19 +570,19 @@ def _ParseOutHelper(self, placeholder, delims, mode):
string = '%s%s' % (string, c)
continue # wait for matching delim
- started -= 1
- if not started:
- values.append(string)
- new_args = '%s %s' % (new_args, '%s%d' % (placeholder,
- my_id))
- my_id += 1
- string = ''
+ started -= 1
+ if not started:
+ values.append(string)
+ new_args = '%s %s' % (new_args, '%s%d' % (placeholder,
+ my_id))
+ my_id += 1
+ string = ''
- else:
- if not started:
- new_args = '%s%s' % (new_args, c)
else:
- string = '%s%s' % (string, c)
+ if not started:
+ new_args = '%s%s' % (new_args, c)
+ else:
+ string = '%s%s' % (string, c)
if started:
if mode == 'parens':
@@ -714,8 +714,8 @@ def _RunInsert(self):
elif self.header[col]['auto']:
new_row[col] = self._GetNextAuto(col)
- else:
- raise ExecuteError(col + ' cannot be empty or null')
+ else:
+ raise ExecuteError(col + ' cannot be empty or null')
self.data.append(new_row)
return [1]
kamctl's dbtextdb.py fails to build in a Python3-only environment. Update dbtextdb to Python3.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1747
Module: kamailio
Branch: master
Commit: 5f52f9905bbdf63d636080f7d0340af4f71ed12a
URL: https://github.com/kamailio/kamailio/commit/5f52f9905bbdf63d636080f7d0340af…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-05-04T15:22:36+02:00
utils/kamctl: dbtextdb.py close previous opened file properly
related #1747
---
Modified: utils/kamctl/dbtextdb/dbtextdb.py
---
Diff: https://github.com/kamailio/kamailio/commit/5f52f9905bbdf63d636080f7d0340af…
Patch: https://github.com/kamailio/kamailio/commit/5f52f9905bbdf63d636080f7d0340af…
---
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.