kamctl's dbtextdb.py fails to build in a Python3-only environment. Update dbtextdb to Python3.
Can you provide more details? What are the errors, what is printed, etc ...
@amessina - any update on this?
@henningw unfortunately no, I have not had time to move this forward. The errors are those typical to others found when a library was written for Python2 and hasn't been ported to Python3--things like`print variable` changed to `print(var)`, etc. Feel free to close out and I can reopen in the future when I have time.
Patch for it was merged.
Closed #1747.
It seems that https://github.com/kamailio/kamailio/commit/bc8bdcaa726f375f6deea8228a1ab0cf... commit broke something:
the previous version was passing: ``` $ git checkout 9df9c6e10ffe0851b7f4f2f00697c5644aaf9faa utils/kamctl/dbtextdb $ python2 dbtextdb_test.py ... ---------------------------------------------------------------------- Ran 3 tests in 0.006s
OK ```
Now it fails for python2 and python3 (same errors): ``` python2 dbtextdb_test.py EEE ====================================================================== ERROR: testExecute (__main__.DBTextTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "dbtextdb_test.py", line 404, in testExecute result = db_conn.Execute(query, writethru) File "/home/vseva/data/projects/kamailio/utils/kamctl/dbtextdb/dbtextdb.py", line 403, in Execute self.ParseQuery(query) File "/home/vseva/data/projects/kamailio/utils/kamctl/dbtextdb/dbtextdb.py", line 453, in ParseQuery self._ParseCommand() File "/home/vseva/data/projects/kamailio/utils/kamctl/dbtextdb/dbtextdb.py", line 469, in _ParseCommand raise ParseError('Unsupported command: ' + self.command) ParseError: Unsupported command: '
====================================================================== ERROR: testOpenTable (__main__.DBTextTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "dbtextdb_test.py", line 342, in testOpenTable db_conn.ParseQuery(query) File "/home/vseva/data/projects/kamailio/utils/kamctl/dbtextdb/dbtextdb.py", line 453, in ParseQuery self._ParseCommand() File "/home/vseva/data/projects/kamailio/utils/kamctl/dbtextdb/dbtextdb.py", line 469, in _ParseCommand raise ParseError('Unsupported command: ' + self.command) ParseError: Unsupported command: t
====================================================================== ERROR: testParseQuery (__main__.DBTextTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "dbtextdb_test.py", line 27, in testParseQuery db_conn.ParseQuery(query_normal) File "/home/vseva/data/projects/kamailio/utils/kamctl/dbtextdb/dbtextdb.py", line 453, in ParseQuery self._ParseCommand() File "/home/vseva/data/projects/kamailio/utils/kamctl/dbtextdb/dbtextdb.py", line 469, in _ParseCommand raise ParseError('Unsupported command: ' + self.command) ParseError: Unsupported command: r
---------------------------------------------------------------------- Ran 3 tests in 0.000s
FAILED (errors=3) ```
Reopened #1747.
with https://github.com/kamailio/kamailio/commit/b722a48144ac9e029bdbc2968dedbe56... : ``` python2 dbtextdb_test.py ... ---------------------------------------------------------------------- Ran 3 tests in 0.006s
OK ```
But for python3: ``` python3 dbtextdb_test.py /home/vseva/data/projects/kamailio/utils/kamctl/dbtextdb/dbtextdb.py:1074: ResourceWarning: unclosed file <_io.TextIOWrapper name='./tests/subscriber' mode='r' encoding='UTF-8'> self.fd = open(os.path.join(self.location, self.table), 'r') ResourceWarning: Enable tracemalloc to get the object allocation traceback /home/vseva/data/projects/kamailio/utils/kamctl/dbtextdb/dbtextdb.py:1074: ResourceWarning: unclosed file <_io.TextIOWrapper name='./tests/test' mode='r' encoding='UTF-8'> self.fd = open(os.path.join(self.location, self.table), 'r') ResourceWarning: Enable tracemalloc to get the object allocation traceback /home/vseva/data/projects/kamailio/utils/kamctl/dbtextdb/dbtextdb.py:1074: ResourceWarning: unclosed file <_io.TextIOWrapper name='./tests/unsorted_table' mode='r' encoding='UTF-8'> self.fd = open(os.path.join(self.location, self.table), 'r') ResourceWarning: Enable tracemalloc to get the object allocation traceback /usr/lib/python3.7/unittest/case.py:615: ResourceWarning: unclosed file <_io.TextIOWrapper name='./tests/test' mode='r' encoding='UTF-8'> testMethod() ResourceWarning: Enable tracemalloc to get the object allocation traceback .dbtextdb_test.py:353: ResourceWarning: unclosed file <_io.TextIOWrapper name='./tests/test' mode='r' encoding='UTF-8'> db_conn = DBText('./tests') ResourceWarning: Enable tracemalloc to get the object allocation traceback dbtextdb_test.py:363: ResourceWarning: unclosed file <_io.TextIOWrapper name='./tests/test' mode='r' encoding='UTF-8'> db_conn = DBText('./tests') ResourceWarning: Enable tracemalloc to get the object allocation traceback dbtextdb_test.py:375: ResourceWarning: unclosed file <_io.TextIOWrapper name='./tests/bad_table_wrong_type' mode='r' encoding='UTF-8'> db_conn = DBText('./tests') ResourceWarning: Enable tracemalloc to get the object allocation traceback dbtextdb_test.py:381: ResourceWarning: unclosed file <_io.TextIOWrapper name='./tests/bad_table_short_row' mode='r' encoding='UTF-8'> db_conn = DBText('./tests') ResourceWarning: Enable tracemalloc to get the object allocation traceback dbtextdb_test.py:387: ResourceWarning: unclosed file <_io.TextIOWrapper name='./tests/bad_table_long_row' mode='r' encoding='UTF-8'> db_conn = DBText('./tests') ResourceWarning: Enable tracemalloc to get the object allocation traceback dbtextdb_test.py:393: ResourceWarning: unclosed file <_io.TextIOWrapper name='./tests/bad_table_null' mode='r' encoding='UTF-8'> db_conn = DBText('./tests') ResourceWarning: Enable tracemalloc to get the object allocation traceback /usr/lib/python3.7/unittest/case.py:615: ResourceWarning: unclosed file <_io.TextIOWrapper name='./tests/bad_table_int' mode='r' encoding='UTF-8'> testMethod() ResourceWarning: Enable tracemalloc to get the object allocation traceback .dbtextdb_test.py:28: DeprecationWarning: Please use assertTrue instead. self.assert_(db_conn.command == 'SELECT') .. ---------------------------------------------------------------------- Ran 3 tests in 0.008s
OK ```
now python2 and python3 pass the test:
``` python3 dbtextdb_test.py ... ---------------------------------------------------------------------- Ran 3 tests in 0.006s
OK ```
Closed #1747.
@linuxmaniac - thanks for working on this and I am not sure how you ended up with it, but probably python2 support can be completely dropped not to make it complex to maintain. I saw notifications on mailing list that you tested also with python2, but is no longer maintained/installed in many distros and python3 should be available in all distro for many years now.
@linuxmaniac sorry for those mistakes I made in the first patch and thank you for fixing.