diff options
author | imarom <imarom@cisco.com> | 2016-03-23 09:19:46 +0200 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-03-23 13:01:08 +0200 |
commit | 5e727474efe18b3800df6130c068e668fadd2e0b (patch) | |
tree | 1c9bce9e6367b892830df6a49798cd14bbe434d8 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py | |
parent | 46f110d0c728ba9299156cf92a59c27c2d0348fa (diff) |
Python 3 - another drop (package fixups)
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py')
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py index c258c749..16ffad43 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py @@ -525,8 +525,15 @@ class STLStream(object): if payload: payload.remove_payload() # fcs etc. data = payload.fields.get('load', '') - replchars = re.compile('(\s|/|\'|\\\|[^' + re.escape(string.printable) + '])') # convert bad chars to hex - new_data = replchars.sub(self.__replchars_to_hex, data) + + good_printable = [c for c in string.printable if ord(c) not in range(32)] + good_printable.remove("'") + + if type(data) is str: + new_data = ''.join([c if c in good_printable else r'\x{0:02x}'.format(ord(c)) for c in x]) + else: + new_data = ''.join([chr(c) if chr(c) in good_printable else r'\x{0:02x}'.format(c) for c in x]) + payload_start = packet_command.find("Raw(load='") if payload_start != -1: packet_command = packet_command[:payload_start-1] @@ -931,7 +938,7 @@ class STLProfile(object): raise STLError("file '{0}' does not exists".format(pcap_file)) # make sure IPG is not less than 1 usec - if ipg_usec < 1: + if ipg_usec is not None and ipg_usec < 1: raise STLError("ipg_usec cannot be less than 1 usec: '{0}'".format(ipg_usec)) if loop_count < 0: |