예제 #1
0
		def main(self): 
			mylagger = Lagger(0.1)
			mysourcestream = RateControlledFileReader("streamingfile.mpg", "bytes", rate=1280000, chunksize=100000) #ReducedConsoleReader()
			mychunkifier = Chunkifier(5000000)
			mydistributor = ChunkDistributor("chunks/")
			myfilewriter = WholeFileWriter()
			mytorrentmakerthread = TorrentMaker( "http://localhost:6969/announce", "chunks/" )
			mytorrentmaker = pipeline( mytorrentmakerthread )
			myoutputconsole = consoleEchoer()
			"""
				mysourcestream -> mychunkifier -> mydistributor -> myfilewriter -> mytorrentmaker -> myoutputconsole
			"""

			self.link( (mysourcestream, "outbox"), (mychunkifier, "inbox") )
			self.link( (mychunkifier, "outbox"), (mydistributor, "inbox") )

			self.link( (mydistributor, "outbox"), (myfilewriter, "inbox") )
			#self.link( (myfilewriter, "outbox"), (mydistributor, "filecompletion") )
			#self.link( (mydistributor, "torrentmaker"), (mytorrentmaker, "inbox") )
			self.link ( (myfilewriter, "outbox"), (mytorrentmaker, "inbox") )
			self.link( (mytorrentmaker, "outbox"), (myoutputconsole, "inbox") )

			self.addChildren(mylagger, mysourcestream, mychunkifier, 
							mydistributor, myfilewriter, mytorrentmaker, 
							myoutputconsole) 
			yield Axon.Ipc.newComponent(*(self.children))
			while 1:
				self.pause()
				yield 1
예제 #2
0
        def main(self):
            mylagger = Lagger(0.1)
            mysourcestream = RateControlledFileReader(
                "streamingfile.mpg", "bytes", rate=1280000,
                chunksize=100000)  #ReducedConsoleReader()
            mychunkifier = Chunkifier(5000000)
            mydistributor = ChunkDistributor("chunks/")
            myfilewriter = WholeFileWriter()
            mytorrentmakerthread = TorrentMaker(
                "http://localhost:6969/announce", "chunks/")
            mytorrentmaker = pipeline(mytorrentmakerthread)
            myoutputconsole = consoleEchoer()
            """
				mysourcestream -> mychunkifier -> mydistributor -> myfilewriter -> mytorrentmaker -> myoutputconsole
			"""

            self.link((mysourcestream, "outbox"), (mychunkifier, "inbox"))
            self.link((mychunkifier, "outbox"), (mydistributor, "inbox"))

            self.link((mydistributor, "outbox"), (myfilewriter, "inbox"))
            #self.link( (myfilewriter, "outbox"), (mydistributor, "filecompletion") )
            #self.link( (mydistributor, "torrentmaker"), (mytorrentmaker, "inbox") )
            self.link((myfilewriter, "outbox"), (mytorrentmaker, "inbox"))
            self.link((mytorrentmaker, "outbox"), (myoutputconsole, "inbox"))

            self.addChildren(mylagger, mysourcestream, mychunkifier,
                             mydistributor, myfilewriter, mytorrentmaker,
                             myoutputconsole)
            yield Axon.Ipc.newComponent(*(self.children))
            while 1:
                self.pause()
                yield 1
예제 #3
0
 def __init__(self):
    super(testHarness, self).__init__() # I wonder if this can get forced to be called automagically?
    import random
    self.serverport = random.randint(4000,8000)
    self.server = SimpleServer(protocol=FortuneCookieProtocol, port=self.serverport)
    self.client = None
    self.display = consoleEchoer()
예제 #4
0
        def main(self):
            chargen = Chargen("testTest!")
            display = consoleEchoer()

            self.link((chargen, "outbox"), (display, "inbox"))
            self.addChildren(chargen, display)
            yield Axon.Ipc.newComponent(*(self.children))
            while 1:
                self.pause()
                yield 1
예제 #5
0
      def main(self):
        chargen= Chargen("testTest!")
        display = consoleEchoer()

        self.link((chargen,"outbox"), (display,"inbox"))
        self.addChildren(chargen, display)
        yield Axon.Ipc.newComponent(*(self.children))
        while 1:
           self.pause()
           yield 1
예제 #6
0
    def __init__(self, noServer = False, serverPort = None, **dictArgs):
        """particleTypes = dictionary mapping names to particle classes
        
           All remaining named arguments are passed onto the TopologyViewerComponent
        """
        
        from Kamaelia.SingleServer import SingleServer
        from Kamaelia.Util.ConsoleEcho import consoleEchoer
        
        pipe = [chunks_to_lines(),
                lines_to_tokenlists(),
                TopologyViewerComponent(**dictArgs),
                consoleEchoer() ]
                
        if not noServer:
            if serverPort == None:
                serverPort = 1500
            pipe.insert(0, SingleServer(port=serverPort))
            

        super(TopologyViewerServer, self).__init__(*pipe)
예제 #7
0
    def __init__(self, noServer=False, serverPort=None, **dictArgs):
        """particleTypes = dictionary mapping names to particle classes
        
           All remaining named arguments are passed onto the TopologyViewerComponent
        """

        from Kamaelia.SingleServer import SingleServer
        from Kamaelia.Util.ConsoleEcho import consoleEchoer

        pipe = [
            chunks_to_lines(),
            lines_to_tokenlists(),
            TopologyViewerComponent(**dictArgs),
            consoleEchoer()
        ]

        if not noServer:
            if serverPort == None:
                serverPort = 1500
            pipe.insert(0, SingleServer(port=serverPort))

        super(TopologyViewerServer, self).__init__(*pipe)
예제 #8
0
   from Axon.Scheduler import scheduler
   from Kamaelia.Util.ConsoleEcho import consoleEchoer
   from InfiniteChooser import InfiniteChooser


#   test = "RateControlledReadFileAdapter"
   test = "PerFileRateReadMultiFileAdapter"
#   test = "FixedRateReadMultiFileAdapter"

   if test == "RateControlledReadFileAdapter":
   
        pipeline( RateControlledReadFileAdapter("./Carousel.py",
                                                readmode = "lines",
                                                rate=20,
                                                chunksize=1),
                  consoleEchoer()
                ).activate()

   elif test == "PerFileRateReadMultiFileAdapter":
        def filelist():
        #       while 1:
                yield ( "./Carousel.py", {"rate":500, "chunkrate":1} )
                yield ( "./Carousel.py", {"rate":400, "chunkrate":20} )
                yield ( "./Carousel.py", {"rate":1000, "chunkrate":100} )
        
        pipeline( JoinChooserToCarousel(
                      InfiniteChooser(filelist()),
                      RateControlledReadFileAdapter_Carousel(readmode="bytes")
                    ),
                  consoleEchoer()
                ).activate()
예제 #9
0
                x += dx
                y += dy
                z += dz
                if abs(x) > 5: dx = -dx
                if abs(y) > 5: dy = -dy
                if abs(z + 20) > 10: dz = -dz
                print x, y, abs(x), abs(y)

    from Kamaelia.Util.ConsoleEcho import consoleEchoer
    from Kamaelia.Util.Graphline import Graphline

    Graphline(CUBEC=Object3D(pos=Vector(0, 0, -12), name="Center cube"),
              CUBET=Object3D(pos=Vector(0, 4, -20), name="Top cube"),
              CUBER=Object3D(pos=Vector(4, 0, -22), name="Right cube"),
              CUBEB=Object3D(pos=Vector(0, -4, -18), name="Bottom cube"),
              CUBEL=Object3D(pos=Vector(-4, 0, -15), name="Left cube"),
              ROTATOR=CubeRotator(),
              MOVER=CubeMover(),
              ECHO=consoleEchoer(),
              linkages={
                  ("CUBEC", "outbox"): ("ECHO", "inbox"),
                  ("CUBET", "outbox"): ("ECHO", "inbox"),
                  ("CUBER", "outbox"): ("ECHO", "inbox"),
                  ("CUBEB", "outbox"): ("ECHO", "inbox"),
                  ("CUBEL", "outbox"): ("ECHO", "inbox"),
                  ("ROTATOR", "outbox"): ("CUBEC", "3dcontrol"),
                  ("MOVER", "outbox"): ("CUBEC", "3dcontrol"),
              }).run()

    Axon.Scheduler.scheduler.run.runThreads()
예제 #10
0
            def main(self):
                yield 1
                yield 1
                # check the first thing the introspector sends is a "DEL ALL" command
                expectedmsgs = ['DEL ALL']
                self.ut.assert_(self.dataReady("inbox"),
                                "Receiving initial message from Introspector")
                data = self.recv("inbox")
                data = data.split("\n")
                for line in data:
                    line = line.strip()
                    if line != "":
                        self.ut.assert_(line in expectedmsgs,
                                        "Didn't expect message: " + line)
                        expectedmsgs.remove(line)
                yield 1
                self.ut.assert_(
                    expectedmsgs == [],
                    "All messages received, post Introspector and IntrospectorExaminer creation"
                )

                components, postboxes, linkages = self.i.introspect()

                # check no linkages found
                self.ut.assert_(
                    linkages == {
                        (i.id, "o", "outbox"): (self.id, "i", "inbox")
                    }, "runtime, found linkage from i/outbox to self/inbox")

                # check the components found are self and i, only
                self.ut.assert_(
                    len(components) == 2,
                    "Runtime, found components: only 2 components")
                for c in [i, self]:
                    self.ut.assert_(
                        components[c.id] == c.name,
                        "Runtime, found component: component " + str(c.id) +
                        " with name " + str(components[c.id]))

                # check the postboxes found are the 4 belonging to i only and 1 to self
                for p in [(self.id, "i", "inbox"), (i.id, "i", "inbox"),
                          (i.id, "i", "control"), (i.id, "o", "outbox"),
                          (i.id, "o", "signal")]:
                    self.ut.assert_(p in postboxes,
                                    "Runtime, found postbox: " + str(p))
                    postboxes.remove(p)
                self.ut.assert_(
                    len(postboxes) == 0,
                    "Runtime, only the intended postboxes found")

                # check the first stream of data to come out of Introspector
                yield 1
                yield 1
                _s = '"' + str(self.id) + '"'
                _i = '"' + str(i.id) + '"'
                _si = '"' + str((self.id, "i", "inbox")) + '"'
                _ii = '"' + str((i.id, "i", "inbox")) + '"'
                _ic = '"' + str((i.id, "i", "control")) + '"'
                _io = '"' + str((i.id, "o", "outbox")) + '"'
                _is = '"' + str((i.id, "o", "signal")) + '"'
                expectedmsgs = [
                    'ADD NODE ' + _i + ' "' + str(i.name) +
                    '" randompos component', 'ADD NODE ' + _s + ' "' +
                    str(self.name) + '" randompos component',
                    'ADD NODE ' + _ii + ' "inbox" randompos inbox',
                    'ADD NODE ' + _ic + ' "control" randompos inbox',
                    'ADD NODE ' + _io + ' "outbox" randompos outbox',
                    'ADD NODE ' + _is + ' "signal" randompos outbox',
                    'ADD NODE ' + _si + ' "inbox" randompos inbox',
                    'ADD LINK ' + _i + ' ' + _ii, 'ADD LINK ' + _i + ' ' + _io,
                    'ADD LINK ' + _i + ' ' + _is, 'ADD LINK ' + _i + ' ' + _ic,
                    'ADD LINK ' + _s + ' ' + _si, 'ADD LINK ' + _io + ' ' + _si
                ]
                while self.dataReady("inbox"):
                    data = self.recv("inbox")
                    data = data.split("\n")
                    for line in data:
                        line = line.strip()
                        if line != "":
                            self.ut.assert_(line in expectedmsgs,
                                            "Didn't expect message: " + line)
                            expectedmsgs.remove(line)
                    yield 1
                self.ut.assert_(
                    expectedmsgs == [],
                    "All messages received, post Introspector and IntrospectorExaminer creation"
                )

                # check thats all
                yield 1
                yield 1
                self.ut.assert_(
                    not self.dataReady("inbox"),
                    "No more messages, post Introspector and IntrospectorExaminer creation."
                )

                # create and activate another component
                e = consoleEchoer()
                e.activate()
                # check for new messages
                yield 1
                yield 1
                _e = '"' + str(e.id) + '"'
                _ei = '"' + str((e.id, "i", "inbox")) + '"'
                _ec = '"' + str((e.id, "i", "control")) + '"'
                _eo = '"' + str((e.id, "o", "outbox")) + '"'
                _es = '"' + str((e.id, "o", "signal")) + '"'
                expectedmsgs = [
                    'ADD NODE ' + _e + ' "' + str(e.name) +
                    '" randompos component',
                    'ADD NODE ' + _ei + ' "inbox" randompos inbox',
                    'ADD NODE ' + _ec + ' "control" randompos inbox',
                    'ADD NODE ' + _eo + ' "outbox" randompos outbox',
                    'ADD NODE ' + _es + ' "signal" randompos outbox',
                    'ADD LINK ' + _e + ' ' + _ei, 'ADD LINK ' + _e + ' ' + _eo,
                    'ADD LINK ' + _e + ' ' + _es, 'ADD LINK ' + _e + ' ' + _ec
                ]
                while self.dataReady("inbox"):
                    data = self.recv("inbox")
                    data = data.split("\n")
                    for line in data:
                        line = line.strip()
                        if line != "":
                            self.ut.assert_(line in expectedmsgs,
                                            "Didn't expect message: " + line)
                            expectedmsgs.remove(line)
                self.ut.assert_(
                    expectedmsgs == [],
                    "All messages received, post consoleEchoer creation")

                # check thats all
                yield 1
                yield 1
                self.ut.assert_(
                    not self.dataReady("inbox"),
                    "No more messages, post Introspector and IntrospectorExaminer creation."
                )

                # create link to console echoer
                i.link((i, "signal"), (e, "inbox"))
                # check for new messages
                yield 1
                yield 1
                expectedmsgs = ['ADD LINK ' + _is + ' ' + _ei]
                while self.dataReady("inbox"):
                    data = self.recv("inbox")
                    data = data.split("\n")
                    for line in data:
                        line = line.strip()
                        if line != "":
                            self.ut.assert_(line in expectedmsgs,
                                            "Didn't expect message: " + line)
                            expectedmsgs.remove(line)
                self.ut.assert_(
                    expectedmsgs == [],
                    "All messages received, post linking Introspector/signal to consoleEchoer/inbox"
                )

                # check thats all
                yield 1
                yield 1
                self.ut.assert_(
                    not self.dataReady("inbox"),
                    "No more messages, post Introspector and IntrospectorExaminer creation."
                )

                # disconnect Introspector from consoleEchoer
                for l in i.postoffice.linkages:
                    if ((l.source, l.sourcebox),
                        (l.sink, l.sinkbox)) == ((i, "signal"), (e, "inbox")):
                        i.postoffice.deregisterlinkage(thecomponent=None,
                                                       thelinkage=l)

                # check for new messages
                yield 1
                yield 1
                expectedmsgs = ['DEL LINK ' + _is + ' ' + _ei]
                while self.dataReady("inbox"):
                    data = self.recv("inbox")
                    data = data.split("\n")
                    for line in data:
                        line = line.strip()
                        if line != "":
                            self.ut.assert_(line in expectedmsgs,
                                            "Didn't expect message: " + line)
                            expectedmsgs.remove(line)
                self.ut.assert_(
                    expectedmsgs == [],
                    "All messages received, post unlinking Introspector/signal from consoleEchoer/inbox"
                )

                # check thats all
                yield 1
                yield 1
                self.ut.assert_(
                    not self.dataReady("inbox"),
                    "No more messages, post Introspector and IntrospectorExaminer creation."
                )

                # terminate console echoer
                e._deliver(message=shutdownMicroprocess(), boxname="control")
                yield 1
                yield 1

                # check for new messages
                yield 1
                yield 1
                expectedmsgs = [
                    'DEL NODE ' + _e, 'DEL NODE ' + _ei, 'DEL NODE ' + _ec,
                    'DEL NODE ' + _eo, 'DEL NODE ' + _es
                ]
                while self.dataReady("inbox"):
                    data = self.recv("inbox")
                    data = data.split("\n")
                    for line in data:
                        line = line.strip()
                        if line != "":
                            self.ut.assert_(line in expectedmsgs,
                                            "Didn't expect message: " + line)
                            expectedmsgs.remove(line)
                self.ut.assert_(
                    expectedmsgs == [],
                    "All messages received, post termination of consoleEchoer")

                # check thats all
                yield 1
                yield 1
                self.ut.assert_(
                    not self.dataReady("inbox"),
                    "No more messages, post Introspector and IntrospectorExaminer creation."
                )

                # terminate
                self.i._deliver(message=shutdownMicroprocess(),
                                boxname="control")
예제 #11
0
def dumping_client():
    return pipeline(
        ConsoleReader("Connected to Mixer >> "),
        TCPClient("127.0.0.1", controlport),
        consoleEchoer(),
    )
예제 #12
0
            if self.dataReady("inbox"):
                plaintext = self.recv("inbox")

                ciphertext = self.encrypt(plaintext)

                self.send(ciphertext, "outbox")
            yield 1


class Decryptor(BasicEncryption):
    def __init__(self, key, algorithm="AES", mode="ECB"):

        super(Decryptor, self).__init__(key, algorithm, mode)

    def main(self):

        while 1:

            if self.dataReady("inbox"):
                ciphertext = self.recv("inbox")

                plaintext = self.decrypt(ciphertext)

                self.send(plaintext, "outbox")
            yield 1


if __name__ == "__main__":
    pipeline(SerialChargen(), Encryptor("1234567812345678"),
             Decryptor("1234567812345678"), consoleEchoer()).run()
예제 #13
0
        LineSplit(),
        lines_to_tokenlists(),
    ),
    CONTROLLER=pipeline(
        source(commands),
        LineSplit(),
        lines_to_tokenlists(),
    ),
    EXPECTED=pipeline(
        source(dataRecorderExpected),
        LineSplit(),
        lines_to_tokenlists(),
    ),
    MUXER=muxTwo(),
    DR=dataRecorder(),
    DISPLAY=consoleEchoer(),
    TRACE=consoleEchoer(forwarder=True),
    RESULT=Comparator(),
    linkages={
        ("SOURCE", "outbox"): ("DR", "inbox"),
        ("CONTROLLER", "outbox"): ("DR", "control"),
        ("DR", "outbox"): ("MUXER", "primary"),
        ("EXPECTED", "outbox"): ("MUXER", "secondary"),
        ("MUXER", "outbox"): ("RESULT", "inbox"),
        ("RESULT", "outbox"): ("DISPLAY", "inbox"),
    })

NonInteractiveTopologyTester = Graphline(
    SOURCE=pipeline(
        source(topology),
        LineSplit(),
예제 #14
0
NonInteractiveDataTester = Graphline(
    SOURCE = pipeline(source(topology),
                       LineSplit(),
                       lines_to_tokenlists(),
              ),
    CONTROLLER = pipeline(source(commands),
                       LineSplit(),
                       lines_to_tokenlists(),
              ),
    EXPECTED = pipeline(source(dataRecorderExpected),
                        LineSplit(),
                        lines_to_tokenlists(),
              ),
    MUXER = muxTwo(),
    DR = dataRecorder(),
    DISPLAY = consoleEchoer(),
    TRACE = consoleEchoer(forwarder=True),
    RESULT = Comparator(),
    linkages = {
        ("SOURCE", "outbox") : ("DR", "inbox"),
        ("CONTROLLER", "outbox") : ("DR", "control"),
        ("DR", "outbox") : ("MUXER", "primary"),
        ("EXPECTED", "outbox") : ("MUXER", "secondary"),
        ("MUXER", "outbox") : ("RESULT", "inbox"),
        ("RESULT", "outbox") : ("DISPLAY", "inbox"),
    }
)

NonInteractiveTopologyTester = Graphline(
    SOURCE = pipeline(source(topology),
                       LineSplit(),
예제 #15
0
    audiencemix = printer()  # SimpleFileWriter("bingle.raw")

if livecontrol:
    Graphline(CONTROL=SingleServer(port=controlport),
              TOKENISER=lines_to_tokenlists(),
              MIXER=MatrixMixer(),
              AUDIENCEMIX=audiencemix,
              linkages={
                  ("CONTROL", "outbox"): ("TOKENISER", "inbox"),
                  ("TOKENISER", "outbox"): ("MIXER", "mixcontrol"),
                  ("MIXER", "mixcontrolresponse"): ("CONTROL", "inbox"),
                  ("MIXER", "outbox"): ("AUDIENCEMIX", "inbox"),
              }).run()
else:
    Graphline(CONTROL=ConsoleReader("mixer desk >> "),
              CONTROL_=consoleEchoer(),
              TOKENISER=lines_to_tokenlists(),
              MIXER=MatrixMixer(),
              AUDIENCEMIX=audiencemix,
              linkages={
                  ("CONTROL", "outbox"): ("TOKENISER", "inbox"),
                  ("TOKENISER", "outbox"): ("MIXER", "mixcontrol"),
                  ("MIXER", "mixcontrolresponse"): ("CONTROL_", "inbox"),
                  ("MIXER", "outbox"): ("AUDIENCEMIX", "inbox"),
              }).run()

if 0:
    audienceout = pipeline(MatrixMixer(),
                           SingleServer(port=mockserverport)).run()

    def dumping_server():
예제 #16
0
    from Movement3D import *
    path1 = LinearPath3D([
        Vector(3, 3, -20),
        Vector(4, 0, -20),
        Vector(3, -3, -20),
        Vector(0, -4, -20),
        Vector(-3, -3, -20),
        Vector(-4, 0, -20),
        Vector(-3, 3, -20),
        Vector(0, 4, -20),
        Vector(3, 3, -20)
    ], 1000)

    Display3D.overridePygameDisplay()

    ECHO = consoleEchoer().activate()
    BUTTON1 = Button3D(caption="<<", msg="Previous",
                       pos=Vector(-3, 0, -10)).activate()
    BUTTON2 = Button3D(caption=">>", msg="Next", pos=Vector(3, 0,
                                                            -10)).activate()
    BUTTON3 = Button3D(caption="Play", msg="Play", pos=Vector(-1, 0,
                                                              -10)).activate()
    BUTTON4 = Button3D(caption="Stop", msg="Stop", pos=Vector(1, 0,
                                                              -10)).activate()
    PATHMOVER = PathMover(path1).activate()
    CUBE = SimpleCube().activate()

    BUTTON1.link((BUTTON1, "outbox"), (PATHMOVER, "inbox"))
    BUTTON2.link((BUTTON2, "outbox"), (PATHMOVER, "inbox"))
    BUTTON3.link((BUTTON3, "outbox"), (PATHMOVER, "inbox"))
    BUTTON4.link((BUTTON4, "outbox"), (PATHMOVER, "inbox"))
예제 #17
0
    from Kamaelia.UI.Pygame.Ticker import Ticker
    from Kamaelia.UI.Pygame.Button import Button
    from SimpleCube import *
    import sys;
    sys.path.append("../pygame/")
    from MagnaDoodle import *
    sys.path.append("../../MPS/Systems/Paint/")
    from Paint import *

    Display3D.getDisplayService()[0].overridePygameDisplay()
   
    TEXT = datasource().activate()
    TICKER1 = Ticker(position = (400, 300), render_left = 0, render_right=350, render_top=0, render_bottom=250).activate()
    TICKER1WRAPPER = PygameWrapperPlane(wrap=TICKER1, pos=Vector(-2, 1,-10), name="1st Wrapper Plane").activate()
    TICKER2 = Ticker(position = (400, 300), render_left = 0, render_right=350, render_top=0, render_bottom=250).activate()
    TICKER2WRAPPER = PygameWrapperPlane(wrap=TICKER2, pos=Vector(2, 1,-10),  name="2nd Wrapper Plane").activate()
    BUTTON = Button(caption="This button...",msg="...can be moved AND activated!", key=pygame.K_SPACE).activate()
    BUTTONWRAPPER = PygameWrapperPlane(wrap=BUTTON, pos=Vector(0, 1.5,-5),  name="2nd Wrapper Plane").activate()
    MAGNADOODLE = MagnaDoodle(size=(255,255)).activate()
    MAGNADOODLEWRAPPER = PygameWrapperPlane(wrap=MAGNADOODLE, pos=Vector(-2, -2,-10),  name="Magna Doodle Wrapper Plane").activate() 
    ECHO = consoleEchoer().activate()
    CUBE = SimpleCube(pos = Vector(2,-2,-10)).activate()
    CUBEROTATOR = CubeRotator().activate()
    TICKER1WRAPPER.link((TICKER1WRAPPER, "outbox"), (TICKER2, "inbox"))
    TICKER2WRAPPER.link((TICKER2WRAPPER, "outbox"), (TICKER2, "inbox"))
    BUTTON.link((BUTTON, "outbox"), (TICKER2, "inbox"))
    TEXT.link((TEXT, "outbox"), (TICKER1, "inbox"))
    CUBEROTATOR.link((CUBEROTATOR,"outbox"), (CUBE, "control3d"))
        
    Axon.Scheduler.scheduler.run.runThreads()  
예제 #18
0
    def main(self):

        while 1:
            try:
                if self.dataReady("inbox"):

                    (data, mac) = self.recv("inbox")
                    checksum = self.decryptobj.decrypt(mac)
                    if checksum == self.calcHash(data):

                        self.send(data, "outbox")
                    else:                      # we have a hash failure
                        raise IntegrityError  # This mechanism needs improvement
            except IntegrityError:

                print "Integrity Error"
                
            yield 1



if __name__ == "__main__":
    pipeline(
        SerialChargen(),
        MAC_Stamper("1234567812345678", mode="CBC"),
        DisruptiveComponent(),
        MAC_Checker("1234567812345678", mode="CBC"),
        consoleEchoer()
        ).run()

예제 #19
0
            def main(self):
                yield 1
                yield 1
                # check the first thing the introspector sends is a "DEL ALL" command
                expectedmsgs = ["DEL ALL"]
                self.ut.assert_(self.dataReady("inbox"), "Receiving initial message from Introspector")
                data = self.recv("inbox")
                data = data.split("\n")
                for line in data:
                    line = line.strip()
                    if line != "":
                        self.ut.assert_(line in expectedmsgs, "Didn't expect message: " + line)
                        expectedmsgs.remove(line)
                yield 1
                self.ut.assert_(
                    expectedmsgs == [], "All messages received, post Introspector and IntrospectorExaminer creation"
                )

                components, postboxes, linkages = self.i.introspect()

                # check no linkages found
                self.ut.assert_(
                    linkages == {(i.id, "o", "outbox"): (self.id, "i", "inbox")},
                    "runtime, found linkage from i/outbox to self/inbox",
                )

                # check the components found are self and i, only
                self.ut.assert_(len(components) == 2, "Runtime, found components: only 2 components")
                for c in [i, self]:
                    self.ut.assert_(
                        components[c.id] == c.name,
                        "Runtime, found component: component " + str(c.id) + " with name " + str(components[c.id]),
                    )

                # check the postboxes found are the 4 belonging to i only and 1 to self
                for p in [
                    (self.id, "i", "inbox"),
                    (i.id, "i", "inbox"),
                    (i.id, "i", "control"),
                    (i.id, "o", "outbox"),
                    (i.id, "o", "signal"),
                ]:
                    self.ut.assert_(p in postboxes, "Runtime, found postbox: " + str(p))
                    postboxes.remove(p)
                self.ut.assert_(len(postboxes) == 0, "Runtime, only the intended postboxes found")

                # check the first stream of data to come out of Introspector
                yield 1
                yield 1
                _s = '"' + str(self.id) + '"'
                _i = '"' + str(i.id) + '"'
                _si = '"' + str((self.id, "i", "inbox")) + '"'
                _ii = '"' + str((i.id, "i", "inbox")) + '"'
                _ic = '"' + str((i.id, "i", "control")) + '"'
                _io = '"' + str((i.id, "o", "outbox")) + '"'
                _is = '"' + str((i.id, "o", "signal")) + '"'
                expectedmsgs = [
                    "ADD NODE " + _i + ' "' + str(i.name) + '" randompos component',
                    "ADD NODE " + _s + ' "' + str(self.name) + '" randompos component',
                    "ADD NODE " + _ii + ' "inbox" randompos inbox',
                    "ADD NODE " + _ic + ' "control" randompos inbox',
                    "ADD NODE " + _io + ' "outbox" randompos outbox',
                    "ADD NODE " + _is + ' "signal" randompos outbox',
                    "ADD NODE " + _si + ' "inbox" randompos inbox',
                    "ADD LINK " + _i + " " + _ii,
                    "ADD LINK " + _i + " " + _io,
                    "ADD LINK " + _i + " " + _is,
                    "ADD LINK " + _i + " " + _ic,
                    "ADD LINK " + _s + " " + _si,
                    "ADD LINK " + _io + " " + _si,
                ]
                while self.dataReady("inbox"):
                    data = self.recv("inbox")
                    data = data.split("\n")
                    for line in data:
                        line = line.strip()
                        if line != "":
                            self.ut.assert_(line in expectedmsgs, "Didn't expect message: " + line)
                            expectedmsgs.remove(line)
                    yield 1
                self.ut.assert_(
                    expectedmsgs == [], "All messages received, post Introspector and IntrospectorExaminer creation"
                )

                # check thats all
                yield 1
                yield 1
                self.ut.assert_(
                    not self.dataReady("inbox"),
                    "No more messages, post Introspector and IntrospectorExaminer creation.",
                )

                # create and activate another component
                e = consoleEchoer()
                e.activate()
                # check for new messages
                yield 1
                yield 1
                _e = '"' + str(e.id) + '"'
                _ei = '"' + str((e.id, "i", "inbox")) + '"'
                _ec = '"' + str((e.id, "i", "control")) + '"'
                _eo = '"' + str((e.id, "o", "outbox")) + '"'
                _es = '"' + str((e.id, "o", "signal")) + '"'
                expectedmsgs = [
                    "ADD NODE " + _e + ' "' + str(e.name) + '" randompos component',
                    "ADD NODE " + _ei + ' "inbox" randompos inbox',
                    "ADD NODE " + _ec + ' "control" randompos inbox',
                    "ADD NODE " + _eo + ' "outbox" randompos outbox',
                    "ADD NODE " + _es + ' "signal" randompos outbox',
                    "ADD LINK " + _e + " " + _ei,
                    "ADD LINK " + _e + " " + _eo,
                    "ADD LINK " + _e + " " + _es,
                    "ADD LINK " + _e + " " + _ec,
                ]
                while self.dataReady("inbox"):
                    data = self.recv("inbox")
                    data = data.split("\n")
                    for line in data:
                        line = line.strip()
                        if line != "":
                            self.ut.assert_(line in expectedmsgs, "Didn't expect message: " + line)
                            expectedmsgs.remove(line)
                self.ut.assert_(expectedmsgs == [], "All messages received, post consoleEchoer creation")

                # check thats all
                yield 1
                yield 1
                self.ut.assert_(
                    not self.dataReady("inbox"),
                    "No more messages, post Introspector and IntrospectorExaminer creation.",
                )

                # create link to console echoer
                i.link((i, "signal"), (e, "inbox"))
                # check for new messages
                yield 1
                yield 1
                expectedmsgs = ["ADD LINK " + _is + " " + _ei]
                while self.dataReady("inbox"):
                    data = self.recv("inbox")
                    data = data.split("\n")
                    for line in data:
                        line = line.strip()
                        if line != "":
                            self.ut.assert_(line in expectedmsgs, "Didn't expect message: " + line)
                            expectedmsgs.remove(line)
                self.ut.assert_(
                    expectedmsgs == [], "All messages received, post linking Introspector/signal to consoleEchoer/inbox"
                )

                # check thats all
                yield 1
                yield 1
                self.ut.assert_(
                    not self.dataReady("inbox"),
                    "No more messages, post Introspector and IntrospectorExaminer creation.",
                )

                # disconnect Introspector from consoleEchoer
                for l in i.postoffice.linkages:
                    if ((l.source, l.sourcebox), (l.sink, l.sinkbox)) == ((i, "signal"), (e, "inbox")):
                        i.postoffice.deregisterlinkage(thecomponent=None, thelinkage=l)

                # check for new messages
                yield 1
                yield 1
                expectedmsgs = ["DEL LINK " + _is + " " + _ei]
                while self.dataReady("inbox"):
                    data = self.recv("inbox")
                    data = data.split("\n")
                    for line in data:
                        line = line.strip()
                        if line != "":
                            self.ut.assert_(line in expectedmsgs, "Didn't expect message: " + line)
                            expectedmsgs.remove(line)
                self.ut.assert_(
                    expectedmsgs == [],
                    "All messages received, post unlinking Introspector/signal from consoleEchoer/inbox",
                )

                # check thats all
                yield 1
                yield 1
                self.ut.assert_(
                    not self.dataReady("inbox"),
                    "No more messages, post Introspector and IntrospectorExaminer creation.",
                )

                # terminate console echoer
                e._deliver(message=shutdownMicroprocess(), boxname="control")
                yield 1
                yield 1

                # check for new messages
                yield 1
                yield 1
                expectedmsgs = [
                    "DEL NODE " + _e,
                    "DEL NODE " + _ei,
                    "DEL NODE " + _ec,
                    "DEL NODE " + _eo,
                    "DEL NODE " + _es,
                ]
                while self.dataReady("inbox"):
                    data = self.recv("inbox")
                    data = data.split("\n")
                    for line in data:
                        line = line.strip()
                        if line != "":
                            self.ut.assert_(line in expectedmsgs, "Didn't expect message: " + line)
                            expectedmsgs.remove(line)
                self.ut.assert_(expectedmsgs == [], "All messages received, post termination of consoleEchoer")

                # check thats all
                yield 1
                yield 1
                self.ut.assert_(
                    not self.dataReady("inbox"),
                    "No more messages, post Introspector and IntrospectorExaminer creation.",
                )

                # terminate
                self.i._deliver(message=shutdownMicroprocess(), boxname="control")
예제 #20
0
파일: tomg.py 프로젝트: thangduong/kamaelia

class Tuple2string(component):
    def main(self):
        while 1:
            yield 1
            if self.dataReady("inbox"):
                item = self.recv("inbox")
                data_id = str(item[0])
                data_length = str(len(str(item[1])))
                data = str(item[1])
                item = "%s %s %s" % (data_id, data_length, data)
                self.send(item, "outbox")


class String2tuple(component):
    def main(self):
        while 1:
            yield 1
            if self.dataReady("inbox"):
                item = self.recv("inbox")
                temp_list = str.split(item)
                data_id = int(temp_list[0])
                data = temp_list[2]
                item = (data_id, data)
                self.send(item, "outbox")


pipeline(Source(), Annotator(), Tuple2string(), Duplicate(), Throwaway(),
         Reorder(), String2tuple(), RecoverOrder(), consoleEchoer()).run()
예제 #21
0
    Graphline(
        CONTROL =  SingleServer(port=controlport),
        TOKENISER = lines_to_tokenlists(),
        MIXER = MatrixMixer(), 
        AUDIENCEMIX = audiencemix,
        linkages = {
           ("CONTROL" , "outbox") : ("TOKENISER" , "inbox"),
           ("TOKENISER" , "outbox") : ("MIXER" , "mixcontrol"),
           ("MIXER" , "mixcontrolresponse") : ("CONTROL" , "inbox"),
           ("MIXER", "outbox") : ("AUDIENCEMIX", "inbox"),
        }
    ).run()
else:
    Graphline(
        CONTROL = ConsoleReader("mixer desk >> "),
        CONTROL_ = consoleEchoer(),
        TOKENISER = lines_to_tokenlists(),
        MIXER = MatrixMixer(), 
        AUDIENCEMIX = audiencemix,
        linkages = {
           ("CONTROL" , "outbox") : ("TOKENISER" , "inbox"),
           ("TOKENISER" , "outbox") : ("MIXER" , "mixcontrol"),
           ("MIXER" , "mixcontrolresponse") : ("CONTROL_" , "inbox"),
           ("MIXER", "outbox") : ("AUDIENCEMIX", "inbox"),
        }
    ).run()

if 0:
    audienceout = pipeline(
        MatrixMixer(), 
        SingleServer(port=mockserverport)
예제 #22
0
        def main(self):
            r = 1.00
            f = 0.01
            while 1:
                yield 1
                if  r>1.0: f -= 0.001
                else: f += 0.001
                r += f
                
                self.send( Control3D(Control3D.SCALING, Vector(r, r, r)), "outbox")


    
    from Kamaelia.Util.ConsoleEcho import consoleEchoer
    from Kamaelia.Util.Graphline import Graphline
    
    Graphline(
        PLANE = TexPlane(pos=Vector(0, 0,-6), tex="Kamaelia.png", name="1st Tex Plane"),
        ROTATOR = CubeRotator(),
#        MOVER = CubeMover(),
#        BUZZER = CubeBuzzer(),
        ECHO = consoleEchoer(),
        linkages = {
            ("PLANE", "outbox") : ("ECHO", "inbox"),
#            ("ROTATOR", "outbox") : ("PLANE", "control3d"),
#            ("MOVER", "outbox") : ("PLANE", "control3d"),
#            ("BUZZER", "outbox") : ("CUBER", "control3d"),
        } ).run()
        
    Axon.Scheduler.scheduler.run.runThreads()  
예제 #23
0

if __name__ == "__main__":

    from Axon.Scheduler import scheduler
    from Kamaelia.Util.ConsoleEcho import consoleEchoer
    from InfiniteChooser import InfiniteChooser

    #   test = "RateControlledReadFileAdapter"
    test = "PerFileRateReadMultiFileAdapter"
    #   test = "FixedRateReadMultiFileAdapter"

    if test == "RateControlledReadFileAdapter":

        pipeline(
            RateControlledReadFileAdapter("./Carousel.py", readmode="lines", rate=20, chunksize=1), consoleEchoer()
        ).activate()

    elif test == "PerFileRateReadMultiFileAdapter":

        def filelist():
            #       while 1:
            yield ("./Carousel.py", {"rate": 500, "chunkrate": 1})
            yield ("./Carousel.py", {"rate": 400, "chunkrate": 20})
            yield ("./Carousel.py", {"rate": 1000, "chunkrate": 100})

        pipeline(
            JoinChooserToCarousel(
                InfiniteChooser(filelist()), RateControlledReadFileAdapter_Carousel(readmode="bytes")
            ),
            consoleEchoer(),
예제 #24
0
        # strip the direct reference to component objects from the dictionary, leaving
        # just a mapping from 'id' to 'name'
        cdict = dict([components[c] for c in components.iterkeys()])

        return cdict, postboxes, linkages

    def esc(self, s):
        s = s.replace('\\', '\\\\')
        s = s.replace('"', '\\"')
        s = s.replace("'", "\\'")
        return s


if __name__ == '__main__':

    c1 = Axon.Component.component().activate()
    c2 = Axon.Component.component().activate()
    c1.link((c1, "outbox"), (c2, "inbox"))
    i = Introspector(c1, c2)
    i.activate()
    from Kamaelia.Util.ConsoleEcho import consoleEchoer
    e = consoleEchoer()
    e.activate()
    i.link((i, "outbox"), (e, "inbox"))

    print "You should see the Introspector finds only a 'Component'."
    print "With standard inbox, control, signal and outbox postboxes"
    print
    Axon.Scheduler.scheduler.run.runThreads(slowmo=0)
예제 #25
0
def dumping_client():
    return pipeline(
        ConsoleReader("Connected to Mixer >> "),
        TCPClient("127.0.0.1", controlport),
        consoleEchoer(),
    )