sip_to_pjsip: Enable python3 compatibility.

The script remains compatible with Python 2.7 but now also works with
Python 3.3 and newer; to ease the migration from chan_sip to chan_pjsip.

ASTERISK-27811

Change-Id: I59cc6b52a1a89777eebcf25b3023bdf93babf835
This commit is contained in:
Alexander Traud
2018-04-18 09:27:51 +02:00
committed by Corey Farrell
parent 9f1e1d153a
commit 2d81709ab1
5 changed files with 69 additions and 63 deletions

View File

@@ -1,6 +1,13 @@
from astconfigparser import MultiOrderedConfigParser
import MySQLdb
try:
import pymysql as MySQLdb
MySQLdb.install_as_MySQLdb()
except ImportError:
# MySQLdb is compatible with Python 2 only. Try it as a
# fallback if pymysql is unavailable.
import MySQLdb
import traceback
class SqlConfigParser(MultiOrderedConfigParser):
@@ -61,9 +68,6 @@ class SqlConfigParser(MultiOrderedConfigParser):
"""Write configuration information out to a file"""
try:
self.write_dicts(config_file, self._sections)
except Exception,e:
print "Could not open file ", config_file, " for writing"
except:
print("Could not open file " + config_file + " for writing")
traceback.print_exc()