Avoid !r format appending u on unicode 58/19558/4
authorVratko Polak <vrpolak@cisco.com>
Tue, 14 May 2019 08:51:15 +0000 (10:51 +0200)
committerJan Gelety <jgelety@cisco.com>
Thu, 16 May 2019 12:16:26 +0000 (12:16 +0000)
Change-Id: I2c0877f4d8b6cad2694c43a4350998cd2b830680
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
resources/libraries/python/TrafficGenerator.py
resources/tools/trex/trex_stateless_profile.py

index 35a701f..9e0a1d2 100644 (file)
@@ -422,6 +422,14 @@ class TrafficGenerator(AbstractMeasurer):
         ssh.connect(self._node)
         reorder = self._ifaces_reordered  # Just to make the next line fit.
         p_0, p_1 = (rx_port, tx_port) if reorder else (tx_port, rx_port)
+        # Values from Robot can introduce type unicode,
+        # we need to encode them, so that repr() does not lead with 'u'.
+        if isinstance(rate, unicode):
+            rate = rate.encode("utf-8")
+        if isinstance(duration, unicode):
+            duration = duration.encode("utf-8")
+        if isinstance(warmup_time, unicode):
+            warmup_time = warmup_time.encode("utf-8")
         command = (
             "sh -c '{tool}/resources/tools/trex/trex_stateless_profile.py"
             " --profile {prof}/resources/traffic_profiles/trex/{traffic}.py"
index 9b62975..aa68a01 100755 (executable)
@@ -245,6 +245,10 @@ def simple_burst(profile_file, duration, framesize, rate, warmup_time, port_0,
         else:
             if client:
                 client.disconnect()
+            if isinstance(rate, unicode):
+                rate = rate.encode("utf-8")
+            if isinstance(duration, unicode):
+                duration = duration.encode("utf-8")
             print("rate={0!r}, totalReceived={1}, totalSent={2}, "
                   "frameLoss={3}, latencyStream0(usec)={4}, "
                   "latencyStream1(usec)={5}, targetDuration={d!r}".

©2016 FD.io a Linux Foundation Collaborative Project. All Rights Reserved.
Linux Foundation is a registered trademark of The Linux Foundation. Linux is a registered trademark of Linus Torvalds.
Please see our privacy policy and terms of use.