<commit_before>import os, sys
import unittest
from trex import CTRexScenario
from stateful_tests.trex_general_test import CTRexGeneral_Test
from trex_stl_lib.api import *
import time
from nose.tools import nottest

class CStlGeneral_Test(CTRexGeneral_Test):
    """This class defines the general stateless testcase of the TRex traffic generator"""

    def setUp(self):
        self.stl_trex = CTRexScenario.stl_trex if CTRexScenario.stl_trex else 'mock'
        CTRexGeneral_Test.setUp(self)
        # check basic requirements, should be verified at test_connectivity, here only skip test
        if CTRexScenario.stl_init_error:
            self.skip(CTRexScenario.stl_init_error)

    def connect(self, timeout = 100):
        # need delay and check only because TRex process might be still starting
        sys.stdout.write('Connecting')
        for i in range(timeout):
            try:
                sys.stdout.write('.')
                sys.stdout.flush()
                self.stl_trex.connect()
                print('')
                return True
            except:
                time.sleep(0.1)
        print('')
        return False

    def map_ports(self, timeout = 100):
        sys.stdout.write('Mapping ports')
        for i in range(timeout):
            sys.stdout.write('.')
            sys.stdout.flush()
            CTRexScenario.stl_ports_map = stl_map_ports(self.stl_trex)
            if self.verify_bidirectional(CTRexScenario.stl_ports_map):
                print('')
                return True
            time.sleep(0.1)
        print('')
        return False
<commit_msg>Regression: handle exceptions during mapping to skip other tests<commit_after>import os, sys
import unittest
from trex import CTRexScenario
from stateful_tests.trex_general_test import CTRexGeneral_Test
from trex_stl_lib.api import *
import time
from nose.tools import nottest

class CStlGeneral_Test(CTRexGeneral_Test):
    """This class defines the general stateless testcase of the TRex traffic generator"""

    def setUp(self):
        self.stl_trex = CTRexScenario.stl_trex if CTRexScenario.stl_trex else 'mock'
        CTRexGeneral_Test.setUp(self)
        # check basic requirements, should be verified at test_connectivity, here only skip test
        if CTRexScenario.stl_init_error:
            self.skip(CTRexScenario.stl_init_error)

    def connect(self, tries = 10):
        # need delay and check only because TRex process might be still starting
        sys.stdout.write('Connecting')
        for i in range(tries):
            try:
                sys.stdout.write('.')
                sys.stdout.flush()
                self.stl_trex.connect()
                print('')
                return True
            except:
                time.sleep(0.5)
        print('')
        return False

    def map_ports(self, tries = 10):
        sys.stdout.write('Mapping ports')
        for i in range(tries):
            sys.stdout.write('.')
            sys.stdout.flush()
            try:
                CTRexScenario.stl_ports_map = stl_map_ports(self.stl_trex)
                if self.verify_bidirectional(CTRexScenario.stl_ports_map):
                    print('')
                    return True
            except Exception as e:
                print('\nException during mapping: %s' % e)
                return False
            time.sleep(0.5)
        print('')
        return False

{'fraction_non_alphanumeric': 0.07888563049853373, 'fraction_numerical': 0.005278592375366569, 'mean_word_length': 2.086877828054299, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3315577', 'n_tokens_mistral': 1009, 'n_tokens_neox': 965, 'n_words': 252}