<commit_before>import logging
from configparser import NoOptionError

# import library components
from lib.config import Config
from lib.avsource import AVSource
from lib.avrawoutput import AVRawOutput
from lib.avpreviewoutput import AVPreviewOutput
from lib.videomix import VideoMix
from lib.audiomix import AudioMix
from lib.streamblanker import StreamBlanker


class Pipeline(object):
    """mixing, streaming and encoding pipeline constuction and control"""

    def __init__(self):
        self.log = logging.getLogger('Pipeline')
        self.log.info('Video-Caps configured to: %s',
                      Config.get('mix', 'videocaps'))
        self.log.info('Audio-Caps configured to: %s',
                      Config.get('mix', 'audiocaps'))

        names = Config.getlist('mix', 'sources')
        if len(names) < 1:
            raise RuntimeError("At least one AVSource must be configured!")

        self.sources = []
        self.mirrors = []
        self.previews = []
        self.sbsources = []

        self.log.info('Creating %u Creating AVSources: %s', len(names), names)
        for idx, name in enumerate(names):
            port = 10000 + idx
            self.log.info('Creating AVSource %s at tcp-port %u', name, port)

            outputs = [name + '_mixer']
            if Config.getboolean('previews', 'enabled'):
                outputs.append(name + '_preview')
            if Config.getboolean('mirrors', 'enabled'):
                outputs.append(name + '_mirror')

            source = AVSource(name, port, outputs=outputs)
            self.sources.append(source)

            if Config.getboolean('mirrors', 'enabled'):
                port = 13000 + idx
                self.log.info('Creating Mirror-Output for AVSource %s '
                              'at tcp-port %u', name, port)

                mirror = AVRawOutput('%s_mirror' % name, port)
                self.mirrors.append(mirror)

            if Config.getboolean('previews', 'enabled'):
                port = 14000 + idx
                self.log.info('Creating Preview-Output for AVSource %s '
                              'at tcp-port %u', name, port)

                preview = AVPreviewOutput('%s_preview' % name, port)
                self.previews.append(preview)

        self.log.info('Creating Videmixer')
        self.vmix = VideoMix()

        # check if there is an audio source preconfigured
        try:
            audiosource = names.index(Config.get('mix', 'audiosource'))<commit_msg>voctocore: Check the configured audiosource exists<commit_after>import logging
from configparser import NoOptionError

# import library components
from lib.config import Config
from lib.avsource import AVSource
from lib.avrawoutput import AVRawOutput
from lib.avpreviewoutput import AVPreviewOutput
from lib.videomix import VideoMix
from lib.audiomix import AudioMix
from lib.streamblanker import StreamBlanker


class Pipeline(object):
    """mixing, streaming and encoding pipeline constuction and control"""

    def __init__(self):
        self.log = logging.getLogger('Pipeline')
        self.log.info('Video-Caps configured to: %s',
                      Config.get('mix', 'videocaps'))
        self.log.info('Audio-Caps configured to: %s',
                      Config.get('mix', 'audiocaps'))

        names = Config.getlist('mix', 'sources')
        if len(names) < 1:
            raise RuntimeError("At least one AVSource must be configured!")

        self.sources = []
        self.mirrors = []
        self.previews = []
        self.sbsources = []

        self.log.info('Creating %u Creating AVSources: %s', len(names), names)
        for idx, name in enumerate(names):
            port = 10000 + idx
            self.log.info('Creating AVSource %s at tcp-port %u', name, port)

            outputs = [name + '_mixer']
            if Config.getboolean('previews', 'enabled'):
                outputs.append(name + '_preview')
            if Config.getboolean('mirrors', 'enabled'):
                outputs.append(name + '_mirror')

            source = AVSource(name, port, outputs=outputs)
            self.sources.append(source)

            if Config.getboolean('mirrors', 'enabled'):
                port = 13000 + idx
                self.log.info('Creating Mirror-Output for AVSource %s '
                              'at tcp-port %u', name, port)

                mirror = AVRawOutput('%s_mirror' % name, port)
                self.mirrors.append(mirror)

            if Config.getboolean('previews', 'enabled'):
                port = 14000 + idx
                self.log.info('Creating Preview-Output for AVSource %s '
                              'at tcp-port %u', name, port)

                preview = AVPreviewOutput('%s_preview' % name, port)
                self.previews.append(preview)

        self.log.info('Creating Videmixer')
        self.vmix = VideoMix()

        # check if there is an audio source preconfigured
        try:
            audiosource_str = Config.get('mix', 'audiosource')
            audiosource = names.index(audiosource_str)
        except ValueError:
            self.log.warn('Audiosource "%s" does not exist, '
                          'defaulting to "%s"', audiosource_str, names[0])
            audiosource = 0
{'fraction_non_alphanumeric': 0.10854328471301383, 'fraction_numerical': 0.0064406137526046596, 'mean_word_length': 2.1040564373897706, 'pattern_counts': {'":': 0, '<': 5, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1430356', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1405, 'n_words': 380}