<commit_before>#!/usr/bin/env python # syntax highlightning

import os, sys

from twisted.python import log
from twisted.python.log import ILogObserver
from twisted.application import internet, service

from opennsa import setup, event, logging
from opennsa.backends import dud


DEBUG = False

TOPOLOGY = 'test-topology.owl'
MAPPING  = 'test-mapping.nrm'

HOST = 'localhost'

SERVICES = [ ('Aruba', 9080), ('Bonaire', 9081), ('Curacao',9082) ]

WSDL_DIR = os.path.join(os.getcwd(), 'wsdl')

## Log messages before "real" logging infrastructure comes up
#earlyObserver = logging.EarlyObserver()
#log.startLoggingWithObserver(earlyObserver.emit, setStdout=0)
#log.defaultObserver = earlyObserver # This will make the log system plug it out when the real logging starts

logObserver = logging.DebugLogObserver(sys.stdout, DEBUG)

application = service.Application("OpenNSA")
application.setComponent(ILogObserver, logObserver.emit)

for network, port in SERVICES:

    backend = dud.DUDNSIBackend(network)
    es = event.EventHandlerRegistry()
    factory = setup.createService(network, [ open(TOPOLOGY) ], backend, es, HOST, port, WSDL_DIR, open(MAPPING) )

    internet.TCPServer(port, factory, interface='localhost').setServiceParent(application)
<commit_msg>setup mapping on test service properly<commit_after>#!/usr/bin/env python # syntax highlightning

import os, sys

from twisted.python import log
from twisted.python.log import ILogObserver
from twisted.application import internet, service

from opennsa import setup, event, logging
from opennsa.backends import dud


DEBUG = False

TOPOLOGY = 'test-topology.owl'
MAPPING  = 'test-mapping.nrm'

HOST = 'localhost'

SERVICES = [ ('Aruba', 9080), ('Bonaire', 9081), ('Curacao',9082) ]

WSDL_DIR = os.path.join(os.getcwd(), 'wsdl')

## Log messages before "real" logging infrastructure comes up
#earlyObserver = logging.EarlyObserver()
#log.startLoggingWithObserver(earlyObserver.emit, setStdout=0)
#log.defaultObserver = earlyObserver # This will make the log system plug it out when the real logging starts

logObserver = logging.DebugLogObserver(sys.stdout, DEBUG)

application = service.Application("OpenNSA")
application.setComponent(ILogObserver, logObserver.emit)

for network, port in SERVICES:

    backend = dud.DUDNSIBackend(network)
    es = event.EventHandlerRegistry()
    factory = setup.createService(network, [ open(TOPOLOGY) ], backend, es, HOST, port, WSDL_DIR, nrm_map_source=open(MAPPING) )

    internet.TCPServer(port, factory, interface='localhost').setServiceParent(application)

{'fraction_non_alphanumeric': 0.108203125, 'fraction_numerical': 0.01015625, 'mean_word_length': 5.8111702127659575, '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': '6295963', 'n_tokens_mistral': 815, 'n_tokens_neox': 770, 'n_words': 211}