Ejemplo n.º 1
0
    def setupUI(self):
        ui = TTY(self.concurrency.createLock())
        ui.configure()

        # Let ui prefix log lines with the worker name.
        ui.setCurrentWorkerNameFunction(self.concurrency.getCurrentWorkerNameFunction())
        # Apply CLI options.
        ui.enableDebugCategories(self.parser.get('debug'))
        ui.setInfoLevel(self.parser.get('info'))

        self.ui = ui
        set_module('ui', ui) # Export ui module.
Ejemplo n.º 2
0
        self.arc = EngineArchitect('Engine')

    def test_00_start_stop(self):
        self.arc.init()
        self.arc.start(self.runner, ())
        self.arc.stop()

    def test_01_start_kill(self):
        self.arc.init()
        self.arc.start(self.runner, ())
        self.arc.kill()

    def test_02_getEmitter(self):
        self.arc.init()
        emitter = self.arc.getLeftEmitter()
        self.assertIsInstance(emitter, Emitter)
        emitter = self.arc.getRightEmitter()
        self.assertIsInstance(emitter, Emitter)


if __name__ == '__main__':
    from imapfw.concurrency import Concurrency
    from imapfw.ui.tty import TTY

    runtime.set_module('concurrency', Concurrency('multiprocessing'))
    ui = TTY(runtime.concurrency.createLock())
    ui.configure()
    # ui.enableDebugCategories(['architects'])
    runtime.set_module('ui', ui)
    unittest.main(verbosity=2)
Ejemplo n.º 3
0
    # We catch exception since it's run as a test in travis.

    _DEBUG = True  # Set to True for more output and stack trace on error.

    import sys
    from imapfw.concurrency.concurrency import Concurrency
    from imapfw.ui.tty import TTY

    c = Concurrency("multiprocessing")
    ui = TTY(c.createLock())
    ui.configure()
    if _DEBUG:
        ui.enableDebugCategories(["emitters"])
    ui.setCurrentWorkerNameFunction(c.getCurrentWorkerNameFunction())

    runtime.set_module("ui", ui)
    runtime.set_module("concurrency", c)

    def run_async():
        ui.info("******** running run_async()")

        __REMOTE__ = "http://imapfw.github.io"
        __CONNECTED__ = "would be connected"
        driverReceiver, driverEmitter = newEmitterReceiver("driver")

        def connect(remote, port):
            print("would connect to %s:%s" % (remote, port))
            assert remote == __REMOTE__
            assert port == 80
            return __CONNECTED__
Ejemplo n.º 4
0
 def setupConcurrency(self):
     self.concurrency = Concurrency(self.parser.get('concurrency'))
     set_module('concurrency', self.concurrency) # Export concurrency module.
Ejemplo n.º 5
0
 def loadRascal(self):
     rascalFile = self.parser.get('rascalfile')
     if rascalFile is not None:
         self.rascal = Rascal()
         self.rascal.load(rascalFile)
     set_module('rascal', self.rascal) # Export the rascal.
Ejemplo n.º 6
0
    # We catch exception since it's run as a test in travis.

    _DEBUG = True # Set to True for more output and stack trace on error.

    import sys
    from imapfw.concurrency.concurrency import Concurrency
    from imapfw.ui.tty import TTY

    c = Concurrency('multiprocessing')
    ui = TTY(c.createLock())
    ui.configure()
    if _DEBUG:
        ui.enableDebugCategories(['emitters'])
    ui.setCurrentWorkerNameFunction(c.getCurrentWorkerNameFunction())

    runtime.set_module('ui', ui)
    runtime.set_module('concurrency', c)


    def run_async():
        ui.info("******** running run_async()")

        __REMOTE__ = 'http://imapfw.github.io'
        __CONNECTED__ = 'would be connected'
        driverReceiver, driverEmitter = newEmitterReceiver('driver')

        def connect(remote, port):
            print("would connect to %s:%s"% (remote, port))
            assert remote == __REMOTE__
            assert port == 80
            return __CONNECTED__
Ejemplo n.º 7
0
 def setUp(self):
     self.c = runtime.concurrency
     ui = NullUI()
     runtime.set_module('ui', ui)
Ejemplo n.º 8
0
 def setupConcurrency(self):
     self._concurrency = Concurrency(self._cli.get('concurrency'))
     set_module('concurrency',
                self._concurrency)  # Export concurrency module.
Ejemplo n.º 9
0
    # We catch exception since it's run as a test in travis.

    _DEBUG = True  # Set to True for more output and stack trace on error.

    import sys
    from imapfw.concurrency.concurrency import Concurrency
    from imapfw.ui.tty import TTY

    c = Concurrency('multiprocessing')
    ui = TTY(c.createLock())
    ui.configure()
    if _DEBUG:
        ui.enableDebugCategories(['emitters'])
    ui.setCurrentWorkerNameFunction(c.getCurrentWorkerNameFunction())

    runtime.set_module('ui', ui)
    runtime.set_module('concurrency', c)

    def run_async():
        ui.info("******** running run_async()")

        __REMOTE__ = 'http://imapfw.github.io'
        __CONNECTED__ = 'would be connected'
        driverReceiver, driverEmitter = newEmitterReceiver('driver')

        def connect(remote, port):
            print("would connect to %s:%s" % (remote, port))
            assert remote == __REMOTE__
            assert port == 80
            return __CONNECTED__
Ejemplo n.º 10
0
        self.arc = EngineArchitect('Engine')

    def test_00_start_stop(self):
        self.arc.init()
        self.arc.start(self.runner, ())
        self.arc.stop()

    def test_01_start_kill(self):
        self.arc.init()
        self.arc.start(self.runner, ())
        self.arc.kill()

    def test_02_getEmitter(self):
        self.arc.init()
        emitter = self.arc.getLeftEmitter()
        self.assertIsInstance(emitter, Emitter)
        emitter = self.arc.getRightEmitter()
        self.assertIsInstance(emitter, Emitter)


if __name__ == '__main__':
    from imapfw.concurrency import Concurrency
    from imapfw.ui.tty import TTY

    runtime.set_module('concurrency', Concurrency('multiprocessing'))
    ui = TTY(runtime.concurrency.createLock())
    ui.configure()
    # ui.enableDebugCategories(['architects'])
    runtime.set_module('ui', ui)
    unittest.main(verbosity=2)