limitations under the License.
"""
from __future__ import print_function
+
import subprocess
import cmd
import json
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
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)
# 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))
# 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)
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'])
return int(input)
except:
return None
+
+def list_intersect(l1, l2):
+ return list(filter(lambda x: x in l2, l1))
+
exit -1
}
-function find_python3 {
- MACHINE_PYTHON=python3
- PYTHON3=$MACHINE_PYTHON
- PCHECK=`$PYTHON3 -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34)"`
- if [ $? -eq 0 ]; then
- return
- fi
- PYTHON3=
-
-}
-
if [ -z "$PYTHON" ]; then
- find_python
+ # for development here - move us to python 3 for now
+ if [ "$USER" == "imarom" ] || [ "$USER" == "hhaim" ] || [ "$USER" == "ybrustin" ] || [ "$USER" == "ibarnea" ]; then
+ PYTHON=/auto/proj-pcube-b/apps/PL-b/tools/python3.4/bin/python3
+ else
+ find_python
+ fi
fi
-if [ -z "$PYTHON3" ]; then
- find_python3
-fi
#!/bin/bash
-source find_python.sh
+#source find_python.sh
cd automation/regression
-if [ -z "$PYTHON" ]; then
- echo "*** $PYTHON - python version is too old, 2.7 at least is required"
-else
- $PYTHON trex_unit_test.py --functional $@
- if [ $? -eq 0 ]; then
- printf "\n$PYTHON test succeeded\n\n"
- else
- printf "\n*** $PYTHON test failed\n\n"
- exit -1
- fi
-fi
+PYTHON=/usr/bin/python2
+PYTHON3=/auto/proj-pcube-b/apps/PL-b/tools/python3.4/bin/python3
-if [ -z "$PYTHON3" ]; then
- echo "*** $PYTHON3 - python3 version required is 3.4 - skipping python3 test"
+# Python 2
+$PYTHON trex_unit_test.py --functional $@
+if [ $? -eq 0 ]; then
+ printf "\n$PYTHON test succeeded\n\n"
else
- $PYTHON3 trex_unit_test.py --functional $@
- if [ $? -eq 0 ]; then
- printf "\n$PYTHON3 test succeeded\n\n"
- else
- printf "\n*** $PYTHON3 test failed\n\n"
- exit -1
- fi
+ printf "\n*** $PYTHON test failed\n\n"
+ exit -1
+fi
+# Python 3
+$PYTHON3 trex_unit_test.py --functional $@
+if [ $? -eq 0 ]; then
+ printf "\n$PYTHON3 test succeeded\n\n"
+else
+ printf "\n*** $PYTHON3 test failed\n\n"
+ exit -1
fi
+
source find_python.sh
export PYTHONPATH=automation/trex_control_plane/stl
+
+printf "\nUsing '$PYTHON' as Python interpeter\n\n"
+
$PYTHON -m console.trex_console $@