Summary:ASTERISK-27811: [patch] sip_to_pjsip: Enable python3 compatibility.
Reporter:Alexander Traud (traud)Labels:patch pjsip
Date Opened:2018-04-18 02:18:43Date Closed:2018-05-09 19:01:57
Versions:13.20.0 15.3.0 Frequency of
Environment:Python 3.6 Python 2.7Attachments:( 0) python3.patch
Description:In {{contrib/scripts}}, there is the Python script {{sip_to_pjsip}}, which converts an existing configuration file from the old SIP channel driver {{chan_sip}} to the new {{chan_pjsip}}, see the [Wiki...|https://wiki.asterisk.org/wiki/display/AST/Migrating+from+chan_sip+to+res_pjsip]

In the year 2013, the last big change to that script happened (ASTERISK-22374). Although then, Python 3 existed already, that script works only with Python 2.7 as of today. Even the Shebang is not in line with the other Python scripts in Asterisk and not the [recommended one|https://stackoverflow.com/a/19305076].

Luckily, the changes for Python 3 are not much: The biggest change is {{print()}} and the import statements. ASTERISK-27333 introduced white-space errors, which Python 3 is picky about. Finally, the analyzer [pyflakes3|https://pypi.org/project/pyflakes/] hinted that the function {{cmp()}} must be replaced to be Python 3 compatible.

With ASTERISK-27348, a new script was added. That imported {{cli_options()}} from the existing script but re-defined just later. pyflakes3 was not happy about that, therefore I removed that import. Furthermore, that script tries to catch an {{Exception,e}} - looks like a typo for me. Finally, I enhanced that script not only to require MySQLdb but allow as alternative also the external library pymysql.

The final script is still compatible with Python 2 and created the same output with a rather complex {{sip.conf}}, both in Python 2.7 and Python 3.6. This change here is part of a series of three changes to get the scripts within Asterisk compatible with Python 3:
1. [Build System...|https://gerrit.asterisk.org/8641]
3. Test Framework, see ASTERISK-27787
Comments:By: Asterisk Team (asteriskteam) 2018-04-18 02:18:45.001-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: Friendly Automation (friendly-automation) 2018-05-09 19:01:58.105-0500

Change 8806 merged by Joshua Colp:
sip_to_pjsip: Enable python3 compatibility.


By: Friendly Automation (friendly-automation) 2018-05-09 19:23:11.801-0500

Change 8807 merged by Joshua Colp:
sip_to_pjsip: Enable python3 compatibility.


By: Friendly Automation (friendly-automation) 2018-05-09 19:26:51.034-0500

Change 8805 merged by Joshua Colp:
sip_to_pjsip: Enable python3 compatibility.