Esempio n. 1
0
def test_smoke():
    # most of this is already tested in testGraph
    Services.addService("Profiling", None)
    mockup = FilterMockup(
        "pyfile://" + os.path.dirname(__file__) +
        "/../interface/SimpleDynamicFilter.py", "SimpleDynInFilter",
        PropertyCollectionImpl("mockup", None), None)
    mockup.createFilterAndUpdate()
    mockup.addDynamicPort("dynin", InputPortInterface)
    res = mockup.createFilter()
Esempio n. 2
0
def setupConsoleServices(config):
    """
    Adds services available in console mode.
    :param config: a nexxT.core.Configuration instance
    :return: None
    """
    Services.addService("Logging", ConsoleLogger())
    Services.addService("PlaybackControl", PlaybackControlConsole(config))
    Services.addService("RecordingControl", MVCRecordingControlBase(config))
    Services.addService("Configuration", MVCConfigurationBase(config))
    Services.addService("Profiling", ProfilingService())
Esempio n. 3
0
def exception_setup(python, thread, where, activeTime_s):
    logging.getLogger(__name__).info("------------------------------------------------------")
    logging.getLogger(__name__).info("Starting exception_setup %d %s %s %f", python, thread, where, activeTime_s)
    from nexxT.services.ConsoleLogger import ConsoleLogger
    logger = ConsoleLogger()
    Services.addService("Logging", logger)
    class LogCollector(logging.StreamHandler):
        def __init__(self):
            super().__init__()
            self.logs = []
        def emit(self, record):
            self.logs.append(record)
    # avoid warning flood about service profiling not found
    Services.addService("Profiling", None)
    collector = LogCollector()
    logging.getLogger().addHandler(collector)
    try:
        t = QTimer()
        t.setSingleShot(True)
        # timeout if test case hangs
        t2 = QTimer()
        t2.start((activeTime_s + 3)*1000)
        try:
            test_json = Path(__file__).parent / "test_except_constr.json"
            with test_json.open("r", encoding='utf-8') as fp:
                cfg = json.load(fp)
            if nexxT.useCImpl and not python:
                cfg["composite_filters"][0]["nodes"][2]["library"] = "binary://../binary/${NEXXT_PLATFORM}/${NEXXT_VARIANT}/test_plugins"
            cfg["composite_filters"][0]["nodes"][2]["thread"] = thread
            cfg["composite_filters"][0]["nodes"][2]["properties"]["whereToThrow"] = where
            mod_json = Path(__file__).parent / "test_except_constr_tmp.json"
            with mod_json.open("w", encoding="utf-8") as fp:
                json.dump(cfg, fp)

            config = Configuration()
            ConfigFileLoader.load(config, mod_json)
            config.activate("testApp")
            app.processEvents()

            aa = Application.activeApplication

            init = True
            def timeout():
                nonlocal init
                if init:
                    init = False
                    aa.stop()
                    aa.close()
                    aa.deinit()
                else:
                    app.exit(0)

            def timeout2():
                print("Application timeout hit!")
                nonlocal init
                if init:
                    init = False
                    aa.stop()
                    aa.close()
                    aa.deinit()
                else:
                    print("application exit!")
                    app.exit(1)
            t2.timeout.connect(timeout2)
            t.timeout.connect(timeout)
            def state_changed(state):
                if state == FilterState.ACTIVE:
                    t.setSingleShot(True)
                    t.start(activeTime_s*1000)
                elif not init and state == FilterState.CONSTRUCTED:
                    t.start(1000)
            aa.stateChanged.connect(state_changed)

            aa.init()
            aa.open()
            aa.start()

            app.exec_()
        finally:
            del t
            del t2
    finally:
        logging.getLogger().removeHandler(collector)
        Services.removeAll()
    return collector.logs
Esempio n. 4
0
def setupGuiServices(config):
    """
    Adds services available in console mode.
    :param config: a nexxT.core.Configuration instance
    :return: None
    """
    mainWindow = MainWindow(config)
    Services.addService("MainWindow", mainWindow)
    Services.addService("Logging", GuiLogger())
    Services.addService("PlaybackControl", MVCPlaybackControlGUI(config))
    Services.addService("RecordingControl", MVCRecordingControlGUI(config))
    Services.addService("Configuration", MVCConfigurationGUI(config))
    Services.addService("Profiling", Profiling())
Esempio n. 5
0
def test_smoke():
    class DummySubConfig(object):
        def __init__(self):
            self.pc = PropertyCollectionImpl("root", None)

        def getPropertyCollection(self):
            return self.pc

    Services.addService("Profiling", None)
    fg = FilterGraph(DummySubConfig())
    n1 = fg.addNode(
        "pyfile://" + os.path.dirname(__file__) +
        "/../interface/SimpleStaticFilter.py", "SimpleStaticFilter")
    n2 = fg.addNode(
        "pyfile://" + os.path.dirname(__file__) +
        "/../interface/SimpleDynamicFilter.py", "SimpleDynInFilter")
    n3 = fg.addNode(
        "pyfile://" + os.path.dirname(__file__) +
        "/../interface/SimpleDynamicFilter.py", "SimpleDynOutFilter")
    n3_2 = fg.addNode(
        "pyfile://" + os.path.dirname(__file__) +
        "/../interface/SimpleDynamicFilter.py", "SimpleDynOutFilter")
    assert n3_2 == "SimpleDynOutFilter2"
    n3_3 = fg.addNode(
        "pyfile://" + os.path.dirname(__file__) +
        "/../interface/SimpleDynamicFilter.py", "SimpleDynOutFilter")
    assert n3_3 == "SimpleDynOutFilter3"
    fg.deleteNode(n3_2)
    fg.deleteNode(n3_3)

    fg.addDynamicInputPort(n2, "inPort")
    fg.addDynamicInputPort(n2, "din1")
    fg.addDynamicInputPort(n2, "din2")
    fg.deleteDynamicInputPort(n2, "din2")
    fg.addDynamicInputPort(n2, "din2")

    fg.addDynamicOutputPort(n3, "dout1")
    fg.addDynamicOutputPort(n3, "dout2")
    fg.deleteDynamicOutputPort(n3, "dout2")
    fg.addDynamicOutputPort(n3, "dout2")

    app.processEvents()

    fg.addConnection(n1, "outPort", n2, "inPort")
    fg.addConnection(n3, "outPort", n2, "din1")
    fg.addConnection(n3, "dout1", n2, "din2")
    fg.addConnection(n3, "dout2", n1, "inPort")
    fg.addConnection(n2, "outPort", n3, "inPort")

    fg.renameDynamicInputPort(n2, "din2", "din3")
    fg.renameDynamicInputPort(n2, "din3", "din2")

    expect_exception(fg.renameDynamicInputPort, n2, "din2", "din1")

    fg.renameDynamicOutputPort(n3, "dout2", "dout3")
    fg.renameDynamicOutputPort(n3, "dout3", "dout2")

    fg.renameNode(n1, "static")
    fg.renameNode(n2, "dynin")
    fg.renameNode(n3, "dynout")

    assert set(fg._nodes.keys()) == set(["static", "dynin", "dynout"])
    assert fg._nodes["static"]["inports"] == [
        "inPort"
    ] and fg._nodes["static"]["outports"] == ["outPort"]
    assert fg._nodes["dynin"]["inports"] == [
        "inPort", "din1", "din2"
    ] and fg._nodes["dynin"]["outports"] == ["outPort"]
    assert fg._nodes["dynout"]["inports"] == [
        "inPort"
    ] and fg._nodes["dynout"]["outports"] == ["outPort", "dout1", "dout2"]

    assert ("static", "outPort", "dynin", "inPort") in fg._connections
    assert ("dynout", "outPort", "dynin", "din1") in fg._connections
    assert ("dynout", "dout1", "dynin", "din2") in fg._connections
    assert ("dynout", "dout2", "static", "inPort") in fg._connections
    assert ("dynin", "outPort", "dynout", "inPort") in fg._connections