S15qkd/splicer.py
def _splice_pipe_digest(qkd_protocol, config_file_name: str = qkd_globals.config_file):
    '''
    Digests the text written into splicepipe and genlog.
    Runs until the splicer process closes.
    '''
    logger.info(f'Starting _splice_pipe_digest thread.')
    fd_genlog = os.open(PipesQKD.GENLOG, os.O_RDONLY |
                        os.O_NONBLOCK)  # non-blocking
    f_genlog = os.fdopen(fd_genlog, 'rb', 0)  # non-blocking

    logger.info(f'Thread started.')
    sleep_time = 0.1  # sleep time before next read file attempt
    with open(config_file_name, 'r') as f:
        config = json.load(f, object_hook=lambda d: SimpleNamespace(**d))
    if config.do_polarization_compensation is True:
        polarization_compensator = PolarizationDriftCompensation(
            config.LCR_polarization_compensator_path)
    while is_running():
        time.sleep(sleep_time)
        try:
            message = (f_genlog.readline().decode().rstrip(
                '\n')).lstrip('\x00')
            if len(message) != 0:
                logger.debug(f'[genlog] {message}')
                if qkd_protocol == QKDProtocol.BBM92:
                    logger.debug(f'Add {message} to error correction queue')
                    error_correction.ec_queue.put(message)
                elif qkd_protocol == QKDProtocol.SERVICE:
                    controller.qkd_engine_state = QKDEngineState.SERVICE_MODE
                    diagnosis = rawkey_diagnosis.RawKeyDiagnosis(
                        FoldersQKD.RAWKEYS + '/' + message)
                    logger.debug(
                        f'Service mode, QBER: {diagnosis.quantum_bit_error}, Epoch: {message}')
                    if config.do_polarization_compensation is True:
                        polarization_compensator.update_QBER(
                            diagnosis.quantum_bit_error)
        except OSError:
            pass
        except Exception as a:
            logger.error(a)
    logger.info(f'Thread finished.')

    Digests the text written into splicepipe and genlog.
    Runs until the splicer process closes.
    
Digests the text written into splicepipe and genlog.
Runs until the splicer process closes.
Digests the text written into splicepipe and genlog . Runs until the splicer process closes .
def _splice_pipe_digest(qkd_protocol, config_file_name: str = qkd_globals.config_file):
    logger.info(f'Starting _splice_pipe_digest thread.')
    fd_genlog = os.open(PipesQKD.GENLOG, os.O_RDONLY |
                        os.O_NONBLOCK)  
    f_genlog = os.fdopen(fd_genlog, 'rb', 0)  
    logger.info(f'Thread started.')
    sleep_time = 0.1  
    with open(config_file_name, 'r') as f:
        config = json.load(f, object_hook=lambda d: SimpleNamespace(**d))
    if config.do_polarization_compensation is True:
        polarization_compensator = PolarizationDriftCompensation(
            config.LCR_polarization_compensator_path)
    while is_running():
        time.sleep(sleep_time)
        try:
            message = (f_genlog.readline().decode().rstrip(
                '\n')).lstrip('\x00')
            if len(message) != 0:
                logger.debug(f'[genlog] {message}')
                if qkd_protocol == QKDProtocol.BBM92:
                    logger.debug(f'Add {message} to error correction queue')
                    error_correction.ec_queue.put(message)
                elif qkd_protocol == QKDProtocol.SERVICE:
                    controller.qkd_engine_state = QKDEngineState.SERVICE_MODE
                    diagnosis = rawkey_diagnosis.RawKeyDiagnosis(
                        FoldersQKD.RAWKEYS + '/' + message)
                    logger.debug(
                        f'Service mode, QBER: {diagnosis.quantum_bit_error}, Epoch: {message}')
                    if config.do_polarization_compensation is True:
                        polarization_compensator.update_QBER(
                            diagnosis.quantum_bit_error)
        except OSError:
            pass
        except Exception as a:
            logger.error(a)
    logger.info(f'Thread finished.')
def _splice_pipe_digest ( qkd_protocol , config_file_name : str = qkd_globals . config_file ) : logger . info ( f'Starting _splice_pipe_digest thread.' ) fd_genlog = os . open ( PipesQKD . GENLOG , os . O_RDONLY | os . O_NONBLOCK ) f_genlog = os . fdopen ( fd_genlog , 'rb' , 0 ) logger . info ( f'Thread started.' ) sleep_time = 0.1 with open ( config_file_name , 'r' ) as f : config = json . load ( f , object_hook = lambda d : SimpleNamespace ( ** d ) ) if config . do_polarization_compensation is True : polarization_compensator = PolarizationDriftCompensation ( config . LCR_polarization_compensator_path ) while is_running ( ) : time . sleep ( sleep_time ) try : message = ( f_genlog . readline ( ) . decode ( ) . rstrip ( '\n' ) ) . lstrip ( '\x00' ) if len ( message ) != 0 : logger . debug ( f'[genlog] {message}' ) if qkd_protocol == QKDProtocol . BBM92 : logger . debug ( f'Add {message} to error correction queue' ) error_correction . ec_queue . put ( message ) elif qkd_protocol == QKDProtocol . SERVICE : controller . qkd_engine_state = QKDEngineState . SERVICE_MODE diagnosis = rawkey_diagnosis . RawKeyDiagnosis ( FoldersQKD . RAWKEYS + '/' + message ) logger . debug ( f'Service mode, QBER: {diagnosis.quantum_bit_error}, Epoch: {message}' ) if config . do_polarization_compensation is True : polarization_compensator . update_QBER ( diagnosis . quantum_bit_error ) except OSError : pass except Exception as a : logger . error ( a ) logger . info ( f'Thread finished.' )
Digests the text written into splicepipe and genlog.
Digests the text written into splicepipe and genlog .
'''
    Digests the text written into splicepipe and genlog.
    Runs until the splicer process closes.
    ''' # non-blocking # non-blocking # sleep time before next read file attempt
qkd_protocol
config_file_name
str