summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-03-23 16:11:53 +0200
committerimarom <imarom@cisco.com>2016-03-23 16:11:53 +0200
commit709eda3b4ea0385da009932df3eba457e955e887 (patch)
tree6dc28821bdd3089be9cf837400fc12ff10f66992 /scripts/automation/trex_control_plane
parente9ab260a5fa47604406e1e9432d0036dc8fd9928 (diff)
moving us to python 3 by default (console)
Diffstat (limited to 'scripts/automation/trex_control_plane')
-rwxr-xr-xscripts/automation/trex_control_plane/stl/console/trex_console.py14
-rw-r--r--scripts/automation/trex_control_plane/stl/console/trex_tui.py2
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py7
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py6
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py4
5 files changed, 22 insertions, 11 deletions
diff --git a/scripts/automation/trex_control_plane/stl/console/trex_console.py b/scripts/automation/trex_control_plane/stl/console/trex_console.py
index 2f6744cc..8c71065c 100755
--- a/scripts/automation/trex_control_plane/stl/console/trex_console.py
+++ b/scripts/automation/trex_control_plane/stl/console/trex_console.py
@@ -17,6 +17,7 @@ See the License for the specific language governing permissions and
limitations under the License.
"""
from __future__ import print_function
+
import subprocess
import cmd
import json
@@ -67,20 +68,25 @@ class ConsoleLogger(LoggerApi):
def set_window_always_on_top (title):
# we need the GDK module, if not available - ignroe this command
try:
- import gtk.gdk
+ if sys.version_info < (3,0):
+ from gtk import gdk
+ else:
+ #from gi.repository import Gdk as gdk
+ return
+
except ImportError:
return
# search the window and set it as above
- root = gtk.gdk.get_default_root_window()
+ root = gdk.get_default_root_window()
for id in root.property_get('_NET_CLIENT_LIST')[2]:
- w = gtk.gdk.window_foreign_new(id)
+ w = gdk.window_foreign_new(id)
if w:
name = w.property_get('WM_NAME')[2]
if name == title:
w.set_keep_above(True)
- gtk.gdk.window_process_all_updates()
+ gdk.window_process_all_updates()
break
diff --git a/scripts/automation/trex_control_plane/stl/console/trex_tui.py b/scripts/automation/trex_control_plane/stl/console/trex_tui.py
index bd1eca74..88c53d10 100644
--- a/scripts/automation/trex_control_plane/stl/console/trex_tui.py
+++ b/scripts/automation/trex_control_plane/stl/console/trex_tui.py
@@ -409,7 +409,7 @@ class TrexTUI():
def handle_key_input (self):
# try to read a single key
- ch = os.read(sys.stdin.fileno(), 1)
+ ch = os.read(sys.stdin.fileno(), 1).decode()
if ch != None and len(ch) > 0:
return (self.pm.handle_key(ch), True)
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
index 0f3cd65c..25e35423 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
@@ -826,9 +826,10 @@ class STLClient(object):
# stats
def _get_formatted_stats(self, port_id_list, stats_mask = trex_stl_stats.COMPACT):
- stats_opts = trex_stl_stats.ALL_STATS_OPTS.intersection(stats_mask)
- stats_obj = {}
+ stats_opts = common.list_intersect(trex_stl_stats.ALL_STATS_OPTS, stats_mask)
+
+ stats_obj = OrderedDict()
for stats_type in stats_opts:
stats_obj.update(self.stats_generator.generate_single_statistic(port_id_list, stats_type))
@@ -2148,7 +2149,7 @@ class STLClient(object):
# set to show all stats if no filter was given
mask = trex_stl_stats.ALL_STATS_OPTS
- stats_opts = trex_stl_stats.ALL_STATS_OPTS.intersection(mask)
+ stats_opts = common.list_intersect(trex_stl_stats.ALL_STATS_OPTS, mask)
stats = self._get_formatted_stats(opts.ports, mask)
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
index 64e8688f..18c49d4e 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
@@ -20,9 +20,9 @@ PORT_STATS = 'p'
PORT_STATUS = 'ps'
STREAMS_STATS = 's'
-ALL_STATS_OPTS = {GLOBAL_STATS, PORT_STATS, PORT_STATUS, STREAMS_STATS}
-COMPACT = {GLOBAL_STATS, PORT_STATS}
-SS_COMPAT = {GLOBAL_STATS, STREAMS_STATS}
+ALL_STATS_OPTS = [GLOBAL_STATS, PORT_STATS, PORT_STATUS, STREAMS_STATS]
+COMPACT = [GLOBAL_STATS, PORT_STATS]
+SS_COMPAT = [GLOBAL_STATS, STREAMS_STATS]
ExportableStats = namedtuple('ExportableStats', ['raw_data', 'text_table'])
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py
index 9490c1b0..ae74e932 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/common.py
@@ -54,3 +54,7 @@ def get_number(input):
return int(input)
except:
return None
+
+def list_intersect(l1, l2):
+ return list(filter(lambda x: x in l2, l1))
+