[Asterisk-code-review] Try construct.legacy as Python module first. (testsuite[14])

Alexander Traud asteriskteam at digium.com
Wed Jun 6 07:55:03 CDT 2018


Alexander Traud has uploaded this change for review. ( https://gerrit.asterisk.org/9123


Change subject: Try construct.legacy as Python module first.
......................................................................

Try construct.legacy as Python module first.

Since version 2.6, the Python module 'construct' is not forward compatible. Some
disitributions still offer version 2.5 via
 import construct_legacy

Until the Asterisk Test Suite is updated, let us first try to import the legacy
version. For example since Ubuntu 18.04 LTS, you go for
 sudo apt install python-construct.legacy

ASTERISK-27893

Change-Id: Ia5a6b205e222156bb9f0adca4611fbe879d2bd1c
---
M lib/python/asterisk/pcap.py
M tests/channels/SIP/pcap_demo/run-test
M tests/channels/pjsip/rtp/rtp_keepalive/base/rtp.py
M tests/hep/hep_capture_node.py
4 files changed, 18 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/23/9123/1

diff --git a/lib/python/asterisk/pcap.py b/lib/python/asterisk/pcap.py
index ee1020d..d39574a 100644
--- a/lib/python/asterisk/pcap.py
+++ b/lib/python/asterisk/pcap.py
@@ -19,8 +19,12 @@
 
 from twisted.internet.protocol import DatagramProtocol
 from twisted.internet import reactor
-from construct import *
-from construct.protocols.ipstack import ip_stack
+try:
+    from construct_legacy import *
+    from construct_legacy.protocols.ipstack import ip_stack
+except ImportError:
+    from construct import *
+    from construct.protocols.ipstack import ip_stack
 try:
     from yappcap import PcapOffline
     PCAP_AVAILABLE = True
diff --git a/tests/channels/SIP/pcap_demo/run-test b/tests/channels/SIP/pcap_demo/run-test
index bc0f27c..7b3122b 100755
--- a/tests/channels/SIP/pcap_demo/run-test
+++ b/tests/channels/SIP/pcap_demo/run-test
@@ -11,7 +11,10 @@
 from sip_message import SIPMessage, SIPMessageTest
 
 from twisted.internet import reactor
-from construct.protocols.ipstack import ip_stack
+try:
+    from construct_legacy.protocols.ipstack import ip_stack
+except ImportError:
+    from construct.protocols.ipstack import ip_stack
 
 logger = logging.getLogger(__name__)
 test1 = [
diff --git a/tests/channels/pjsip/rtp/rtp_keepalive/base/rtp.py b/tests/channels/pjsip/rtp/rtp_keepalive/base/rtp.py
index 38ff430..2e325f5 100644
--- a/tests/channels/pjsip/rtp/rtp_keepalive/base/rtp.py
+++ b/tests/channels/pjsip/rtp/rtp_keepalive/base/rtp.py
@@ -13,7 +13,10 @@
 from twisted.internet.protocol import DatagramProtocol
 from twisted.internet import reactor
 
-from construct import *
+try:
+    from construct_legacy import *
+except ImportError:
+    from construct import *
 
 sys.path.append('lib/python')
 
diff --git a/tests/hep/hep_capture_node.py b/tests/hep/hep_capture_node.py
index 8170213..f663056 100644
--- a/tests/hep/hep_capture_node.py
+++ b/tests/hep/hep_capture_node.py
@@ -21,7 +21,10 @@
 from twisted.internet.protocol import DatagramProtocol
 from twisted.internet import reactor
 
-from construct import *
+try:
+    from construct_legacy import *
+except ImportError:
+    from construct import *
 
 LOGGER = logging.getLogger(__name__)
 

-- 
To view, visit https://gerrit.asterisk.org/9123
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 14
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia5a6b205e222156bb9f0adca4611fbe879d2bd1c
Gerrit-Change-Number: 9123
Gerrit-PatchSet: 1
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180606/867ab4ff/attachment-0001.html>


More information about the asterisk-code-review mailing list