Module: kamailio Branch: master Commit: 1aca79c43cb8dbd920c1eb81c0c30cf89f0985b9 URL: https://github.com/kamailio/kamailio/commit/1aca79c43cb8dbd920c1eb81c0c30cf8...
Author: Victor Seva linuxmaniac@torreviejawireless.org Committer: Victor Seva linuxmaniac@torreviejawireless.org Date: 2020-05-04T11:33:12+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
---
Modified: utils/kamctl/dbtextdb/dbtextdb.py
---
Diff: https://github.com/kamailio/kamailio/commit/1aca79c43cb8dbd920c1eb81c0c30cf8... Patch: https://github.com/kamailio/kamailio/commit/1aca79c43cb8dbd920c1eb81c0c30cf8...
---
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)