Esempio n. 1
0
def main(*args): 
    Graphline(
        PALETTE = Palette("Palette","Brush"),
        CONSOLE = ConsoleReader(">>> "),
        LINESTOKENS = lines_to_tokenlists(),
        PAINT = Painter(),
        linkages = {
            ("CONSOLE", "outbox"): ("LINESTOKENS","inbox"),
            ("LINESTOKENS", "outbox"): ("PAINT","inbox"),
            ("PALETTE", "outbox"): ("LINESTOKENS","inbox"),
            ("PAINT", "colour") : ("PALETTE", "colourchange"),
        }
    ).run()
Esempio n. 2
0
                msg = self.recv("control")
                if isinstance(msg, producerFinished) or isinstance(
                        msg, shutdown):
                    self.send(producerFinished(self), "signal")
                    return

            self.pause()


if __name__ == '__main__':
    # The 'announce' URL of the BitTorrent tracker to use
    # e.g. "http://192.168.1.5:6969/announce"
    trackerannounceurl = raw_input("Tracker Announce URL: ")

    Graphline(
        filenamereader=ConsoleReader(">>> ", ""),

        # send the filename entered by the user to both the .torrent
        # maker and to the file writer to use as part of the filename
        # (so that it knows what to save the metadata as)
        filenamesplitter=Fanout(["toNamer", "toTorrentMaker"]),

        # makes the .torrent file (BitTorrent metadata)
        torrentmaker=TorrentMaker(trackerannounceurl),

        # saves the .torrent file
        filewriter=WholeFileWriter(),

        # does the seeding (uploading) of the file
        torrentpatron=TorrentPatron(),
Esempio n. 3
0
        SubscribeTo("DEBUGIN"),
        PublishTo("USERRESPONSE"),
    ).activate()
    Pipeline(
        Textbox(position=(250,48), size=(500,150)),
        PublishTo("DEBUGIN"),
    ).activate()

    Pipeline(
        SubscribeTo("OUIJAOUT"),
        PureTransformer(lambda x: str(x)+"\n"),
        TextDisplayer(position=(250,220), size=(500,150)),
    ).activate()

Pipeline(
    ConsoleReader(">> "),
    PureTransformer(lambda x: x[:-1]),
    PublishTo("PROGRAMME"),
).activate()

else:
    Pipeline(
        SubscribeTo("OUIJAOUT"),
        TextDisplayer(position=(250,48),
                      size=(500,322),
                      text_height=25),
    ).activate()

def Publisher(*args, **argd):
    return PublishTo("OPENCV_VOTES")
Esempio n. 4
0
        return topology


__kamaelia_components__ = (TopologyViewer3D, )

if __name__ == "__main__":
    from Kamaelia.Util.DataSource import DataSource
    from Kamaelia.Visualisation.PhysicsGraph.lines_to_tokenlists import lines_to_tokenlists
    from Kamaelia.Util.Console import ConsoleEchoer, ConsoleReader
    from Kamaelia.Chassis.Graphline import Graphline

    # Data can be from both DataSource and console inputs
    print("Please type the command you want to draw")
    Graphline(
        CONSOLEREADER=ConsoleReader(">>> "),
        #        DATASOURCE = DataSource(['ADD NODE 1Node 1Node randompos -', 'ADD NODE 2Node 2Node randompos -',
        #                                 'ADD NODE 3Node 3Node randompos -', 'ADD NODE 4Node 4Node randompos -',
        #                                 'ADD LINK 1Node 2Node','ADD LINK 2Node 3Node', 'ADD LINK 3Node 4Node',
        #                                 'ADD LINK 4Node 1Node']),
        DATASOURCE=DataSource([
            'ADD NODE 1Node 1Node randompos teapot',
            'ADD NODE 2Node 2Node randompos -',
            'ADD NODE 3Node 3Node randompos sphere',
            'ADD NODE 4Node 4Node randompos -',
            'ADD NODE 5Node 5Node randompos sphere',
            'ADD NODE 6Node 6Node randompos -',
            'ADD NODE 7Node 7Node randompos sphere', 'ADD LINK 1Node 2Node',
            'ADD LINK 1Node 3Node', 'ADD LINK 1Node 4Node',
            'ADD LINK 1Node 5Node', 'ADD LINK 1Node 6Node',
            'ADD LINK 1Node 7Node',
Esempio n. 5
0
            pass
        if self.dataReady("control"):
            self.send(self.recv("control"), "signal")
        else:
            self.send(Axon.Ipc.producerFinished(), "signal")


if __name__ == "__main__":
    from TaggingPluggableProcessor import TaggingPluggableProcessor
    from Kamaelia.Chassis.Pipeline import Pipeline
    from Kamaelia.Util.Console import ConsoleReader, ConsoleEchoer
    from Kamaelia.Util.PureTransformer import PureTransformer

    TPP = TaggingPluggableProcessor()

    Pipeline(ConsoleReader(), PureTransformer(lambda x: int(x)), TPP,
             ConsoleEchoer()).activate()

    ConditionalTransformer(TPP, "EVEN", lambda x: x % 2 == 0,
                           lambda x: "Even ! " + str(x)).activate()

    def isodd(x):
        return x % 2 == 1

    def format_as_odd(x):
        return "Odd ! " + str(x)

    ConditionalTransformer(TPP, "ODD", isodd, format_as_odd).activate()

    class Divisible3(ConditionalTransformer):
        @staticmethod
Esempio n. 6
0
    def main(self):
        while 1:
            yield 1
            while self.dataReady("inbox"):
                msg = self.recv("inbox")
                self.forwardqueue.push(msg)

            while len(self.forwardqueue) >= self.chunksize:
                self.sendChunk()

            if self.nodelay:
                self.sendPartialChunk()

            while self.dataReady("control"):
                msg = self.recv("control")
                if isinstance(msg, producerFinished):
                    self.sendPartialChunk()
                    self.send(msg, "signal")
                    return
                elif isinstance(msg, shutdown):
                    self.send(msg, "signal")
                    return
            self.pause()


if __name__ == '__main__':
    from Kamaelia.Util.PipelineComponent import pipeline
    from Kamaelia.Util.Console import ConsoleEchoer, ConsoleReader

    pipeline(ConsoleReader(eol=""), Chunkifier(20), ConsoleEchoer()).run()
Esempio n. 7
0
                if command == "undo\n":
                    self.send(self.loadMessage(current), "outbox")

            if not self.anyReady():
                yield 1


if __name__ == "__main__":
    from Kamaelia.Chassis.Pipeline import pipeline
    from Kamaelia.Util.Console import ConsoleReader, ConsoleEchoer

    def loadMessage(current):
        return [["LOAD", "slide.%d.png" % (current, )]]

    def saveMessage(current):
        return [["SAVE", "slide.%d.png" % (current, )]]


    #pipeline(
    #ConsoleReader(),
    #CheckpointSequencer(loadMessage,
    #saveMessage),
    #ConsoleEchoer(),
    #).run()
    pipeline(
        ConsoleReader(),
        CheckpointSequencer(lambda X: [["LOAD", "slide.%d.png" % (X, )]],
                            lambda X: [["SAVE", "slide.%d.png" % (X, )]]),
        ConsoleEchoer(),
    ).run()
Esempio n. 8
0
            self.link((self, "inbox"), (self.chatter, "talk"), passthrough=1)
            self.link((self.chatter, "outbox"), (self.oscar, "inbox"))
            self.link((self.oscar, "outbox"), (self.chatter, "inbox"))
            self.link((self, "internal outbox"), (self.chatter, "inbox"))
            while len(queued):
                self.send(queued[0], "internal outbox")
                del(queued[0])
            assert self.debugger.note("AIMHarness.main", 5, "Everything linked up and initialized, starting normal operation")
            while True:  #FIXME:  Why do we keep running instead of dying?
                self.pause()
                yield 1

__kamaelia_components__ = (AIMHarness, )

if __name__ == '__main__':
    from Kamaelia.Chassis.Pipeline import Pipeline
    from Kamaelia.Util.Console import ConsoleEchoer, ConsoleReader
    from Kamaelia.Util.PureTransformer import PureTransformer

    def tuplefy(data):
        data = data.split()
        if len(data) > 1: 
            data = ("message", data[0], " ".join(data[1:]))
            return data
           
    Pipeline(ConsoleReader(),
             PureTransformer(tuplefy),
             AIMHarness("kamaelia1", "abc123"),
             ConsoleEchoer()
             ).run()
Esempio n. 9
0
                    return
                else:  # format and send input query
                    s = s.split()
                    if len(s) == 5:
                        self.send(s)
                    if len(s) == 4:
                        self.send(s + [None])
                    if len(s) == 3:
                        self.send(s + [None, None])
                yield 1


if __name__ == '__main__':
    from Kamaelia.Chassis.Graphline import Graphline
    from Kamaelia.Util.Console import ConsoleReader

    Graphline(CR=ConsoleReader(),
              RL=ReadLoop(),
              Q=Query(),
              GD=GetData(),
              linkages={
                  ('CR', "outbox"): ('RL', "stdin"),
                  ('RL', "outbox"): ('Q', "requests"),
                  ('Q', "answers"): ('RL', "inbox"),
                  ('GD', "outbox"): ('Q', "data"),
                  ('Q', "queries"): ('GD', "inbox"),
                  ('Q', "loopback"): ('Q', "format"),
                  ('RL', "signal"): ('Q', "control"),
                  ('Q', "signal"): ('GD', "control")
              }).run()
Esempio n. 10
0
    ).activate()

    Backplane("VisualiserControl").activate()
    Backplane("VisualiserEvents").activate()
    Pipeline(
        SubscribeTo("VisualiserControl"),
        BuildViewer(),
        PublishTo("VisualiserEvents"),
    ).activate()

    #
    # Debugging console
    #
    from Kamaelia.Util.Console import ConsoleReader
    from Kamaelia.Visualisation.Axon.AxonVisualiserServer import text_to_token_lists
    Pipeline(ConsoleReader(), text_to_token_lists(),
             PublishTo("VisualiserControl")).activate()

    Graphline(SEMANTIC_EVENTS=SubscribeTo("Panel_Events"),
              SELECTION_EVENTS=SubscribeTo("VisualiserEvents"),
              TOPOLOGY_VISUALISER=PublishTo("VisualiserControl"),
              CODE_DISPLAY=PublishTo("Display"),
              MAKELINK=Button(caption="make link",
                              size=(63, 32),
                              position=(800, 0),
                              msg="LINK"),
              CENTRAL_CONTROL=Magic(),
              CODE_GENERATOR=CodeGen(),
              linkages={
                  ("SEMANTIC_EVENTS", "outbox"):
                  ("CENTRAL_CONTROL", "from_panel"),
Esempio n. 11
0
def CommandConsole():
    return Pipeline(ConsoleReader(),
                 text_to_tokenlists(),
                 parseCommands())
                self.send(link, "outbox")
            yield 1

        self.send(self.shutdown_mess, "signal")


if __name__ == "__main__":
    from Kamaelia.Util.DataSource import DataSource
    from Kamaelia.Visualisation.PhysicsGraph.lines_to_tokenlists import lines_to_tokenlists
    from Kamaelia.Util.Console import ConsoleReader, ConsoleEchoer
    from GenericTopologyViewer import GenericTopologyViewer
    from Kamaelia.Chassis.Graphline import Graphline

    # Data can be from both DataSource and console inputs
    Graphline(
        CONSOLEREADER=ConsoleReader(),
        DATASOURCE=DataSource([
            "  person  mum   gender=female,photo=../Files/mum.jpg,width=80,height=80 ",
            '  ', """   
                    """,
            'person dad gender=male,shape=rect,width=80,height=80',
            '  person  son   gender=male,photo=../Files/son.gif,width=60,height=60',
            'person son photo=../Files/son1.gif', 'person daughter radius=20',
            'person daughter radius=100', ' childof  (  mum  , son  ) ',
            'childof(mum, daughter)', 'childof(dad, son)',
            'childof(dad, daughter)'
        ]),
        PARSER=RelationAttributeParser(),
        TOKENS=lines_to_tokenlists(),
        VIEWER=GenericTopologyViewer(),
        CONSOLEECHOER=ConsoleEchoer(),
Esempio n. 13
0
       for child in self.childComponents():
           if child._isStopped():
               self.removeChild(child)   # deregisters linkages for us

       return 0==len(self.childComponents())
                  
if __name__=="__main__":
    from Kamaelia.Util.Console import ConsoleReader, ConsoleEchoer
    from Kamaelia.Chassis.Pipeline import Pipeline
    import time
    class Waiter(Axon.Component.component):
        def main(self):
            print "RUNNING"
            t = time.time()
            while time.time()-t >2:
                yield 1
            print "DONE"
            
    # All the following run as you would expect at this stage
    if 0:
        Waiter().run()

    if 0:
        ThreadWrap( Waiter() ).run()

    if 1:
        Pipeline(
            ThreadWrap(ConsoleReader()),
            ConsoleEchoer(),
        ).run()
Esempio n. 14
0
    def formatChannelMsg(self, msg):
        return msg

    def formatMisc(self, msg):
        return msg

    def formatNotice(self, msg):
        return msg

    def formatError(self, msg):
        return msg

    def formatNumReply(self, msg):
        return msg


if __name__ == '__main__':
    from Kamaelia.Util.Console import ConsoleReader, ConsoleEchoer
    from Kamaelia.Chassis.Graphline import Graphline
    from Kamaelia.Chassis.Pipeline import Pipeline
    from Prefab import ComplexIRCClientPrefab

    client = Graphline(
        prefab=ComplexIRCClientPrefab(host="irc.freenode.net",
                                      nick="kamaeliabot",
                                      defaultChannel="#kamtest"),
        formatter=Translator("kamaeliabot"),
        linkages={("prefab", "outbox"): ("formatter", "privmsg")})

    Pipeline(ConsoleReader(), client, ConsoleEchoer()).run()
Esempio n. 15
0
    from Kamaelia.Util.Console import ConsoleEchoer, ConsoleReader
    from Kamaelia.Util.OneShot import OneShot

    print 
    if len(sys.argv)>1:
        testing = int(sys.argv[1])
    else:
        testing = 10




    if testing == 1:
        Graphline(
            MAKESSL = OneShot(" make ssl "), # The actual message here is not necessary
            CONSOLE = ConsoleReader(),
            ECHO = ConsoleEchoer(),
            CONNECTION = TCPClient("kamaelia.svn.sourceforge.net", 443),
            linkages = {
                ("MAKESSL", "outbox"): ("CONNECTION", "makessl"),
                ("CONSOLE", "outbox"): ("CONNECTION", "inbox"),
                ("CONSOLE", "signal"): ("CONNECTION", "control"),
                ("CONNECTION", "outbox"): ("ECHO", "inbox"),
                ("CONNECTION", "signal"): ("ECHO", "control"),
            }
        ).run()

    if testing == 2:
        print "Test 2 Disabled, was more of a sketch thinking 'what sort of API might we like?'"

    if 0:
Esempio n. 16
0
            ("CANVAS", "eventsOut"): ("PAINTER", "inbox"),
            ("PALETTE", "outbox"): ("PAINTER", "colour"),
            ("ERASER", "outbox"): ("PAINTER", "erase"),
            ("LOAD", "outbox"): ("CANVAS", "inbox"),
            ("SAVE", "outbox"): ("CANVAS", "inbox"),
            ("PAINTER", "outbox"): ("SPLIT", "inbox"),
            ("SPLIT", "outbox"): ("CANVAS", "inbox"),
            ("self", "inbox"): ("CANVAS", "inbox"),
            ("SPLIT", "outbox2"): ("self", "outbox"),
            ("CANVAS", "outbox"): ("self", "outbox"),
        },
    )

mainsketcher = \
    Graphline( SKETCHER = makeBasicSketcher(width=1024,height=768),
               CONSOLE = Pipeline(ConsoleReader(),text_to_tokenlists(),parseCommands()),

               linkages = { ('self','inbox'):('SKETCHER','inbox'),
                            ('SKETCHER','outbox'):('self','outbox'),
                            ('CONSOLE','outbox'):('SKETCHER','inbox'),
                          }
                 )

# primary whiteboard
Pipeline(subscribeTo("WHITEBOARD"), TagAndFilterWrapper(mainsketcher),
         publishTo("WHITEBOARD")).activate()

if __name__ == "__main__":
    import sys, getopt, re

    rhost, rport, serveport = parseOptions()
Esempio n. 17
0
# -*- coding: utf-8 -*-
# Copyright 2010 British Broadcasting Corporation and Kamaelia Contributors(1)
#
# (1) Kamaelia Contributors are listed in the AUTHORS file and at
#     http://www.kamaelia.org/AUTHORS - please extend this file,
#     not this notice.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from Kamaelia.Chassis.Pipeline import Pipeline
from Kamaelia.Util.Console import ConsoleReader
from Kamaelia.Protocol.HTTP.HTTPClient import SimpleHTTPClient
from Kamaelia.File.Writing import SimpleFileWriter

Pipeline(
    ConsoleReader(">>> ", ""),
    SimpleHTTPClient(),
    SimpleFileWriter("downloadedfile.txt"),
).run()

Esempio n. 18
0
    def createconnection(self):
        conn = self.factory(host=self.host,
                            db=self.db,
                            login=self.login,
                            passwd=self.passwd,
                            port=self.port,
                            delay=self.delay,
                            format=self.format,
                            pool=(self, "inbox"))
        #self.addChildren(conn)
        #self.spareconnections.append(conn)
        #self.link((conn,"signal"),(self,"cursorcontrol"))
        conn.activate()


def starttestcursorserver():
    cursorServer = CursorServer()
    cursorServer.activate()
    theCat = coordinatingassistanttracker.getcat()
    theCat.registerService("SEDNA_CURSORS", cursorServer, "inbox")


if __name__ == '__main__':
    from Kamaelia.Util.Console import ConsoleReader, ConsoleEchoer

    starttestcursorserver()
    Pipeline(ConsoleReader(">>> ", ""), SednaConsoleInput(),
             AutoCommit(service="SEDNA_CURSORS", terminable=False),
             ConsoleEchoer()).run()
Esempio n. 19
0
    def suffixMatchOnly(x):
        if x[:len(urlprefix)] == urlprefix:
            return x

    class ListSplit(component):
        def main(self):
            while 1:
                yield 1
                while self.dataReady("inbox"):
                    msg = self.recv("inbox")
                    for m in msg:
                        self.send(m, "outbox")
                self.pause()

    Graphline(usersuppliedurls=ConsoleReader(eol=""),
              splitter=Fanout(["toHTTPClient", "toCorrectRelativeLinks"]),
              splittertwo=Fanout(["toSplitterOne", "toEchoer"]),
              newlinesuffixadder=PureTransformer(lambda x: x + "\n"),
              httpclient=SimpleHTTPClient(),
              htmlprocessor=HTMLProcess(),
              linkextractor=ExtractLinks(),
              linkcorrector=CorrectRelativeLinks(),
              listsplitter=ListSplit(),
              prefixmatcher=PureTransformer(suffixMatchOnly),
              newurlechoer=ConsoleEchoer(),
              unseenonly=UnseenOnly(),
              linkages={
                  ("usersuppliedurls", "outbox"): ("unseenonly", "inbox"),
                  ("newurlechoer", "outbox"): ("splitter", "inbox"),
                  ("splitter", "toHTTPClient"): ("httpclient", "inbox"),
Esempio n. 20
0
if __name__ == '__main__':
    from Kamaelia.Chassis.Pipeline import Pipeline
    from Kamaelia.Util.Console import ConsoleEchoer

    if 0:
        Pipeline(Textbox(size = (800, 300),
                         position = (0,0)),
                 TextDisplayer(size = (800, 300),
                               position = (0,340))
                 ).run()

    if 0: #old test just involving TextDisplayer
        from Kamaelia.Chassis.Pipeline import Pipeline
        from Kamaelia.Util.Console import ConsoleReader
        Pipeline(ConsoleReader(), TextDisplayer()).run()

    if 1: #old test just involving TextDisplayer
        import Axon
        import time
        from Kamaelia.Chassis.Pipeline import Pipeline

        #the long lines are there on purpose, to see if the component wraps text correctly.

        class TimedLineSender(Axon.ThreadedComponent.threadedcomponent):
            text =  """\
                    To be, or not to be: that is the question:
                    Whether 'tis nobler in the mind to suffer
                    The slings and arrows of outrageous fortune,
                    Or to take arms against a sea of troubles,
                    And by opposing end them? To die: to sleep;
Esempio n. 21
0
        homedir = os.path.expanduser("~")
        file = open(homedir + "/twitter-login.conf")
    except IOError, e:
        print ("Failed to load login data - exiting")
        sys.exit(0)

    raw_config = file.read()
    file.close()

    # Read Config
    config = cjson.decode(raw_config)
    bitlyusername = config['bitlyusername']
    bitlyapikey = config['bitlyapikey']
    proxy = config['proxy']

    READER = ConsoleReader()
    DECODER = PureTransformer(lambda x: cjson.decode(x))
    CLEANER = TweetCleaner(['user_mentions','urls','hashtags'])
    WRITER = ConsoleEchoer()
    FIXER = RetweetFixer()
    SPELLING = PureTransformer(lambda x: spellingFixer(x))
    LINKER = LinkResolver(bitlyusername,bitlyapikey)
    REQUESTER = HTTPGetter(proxy, "BBC R&D Grabber")

    if 0:
        Pipeline(READER,DECODER,CLEANER,WRITER).run()

    if 0:
        Pipeline(READER,DECODER,FIXER,WRITER).run()

    if 0:
Esempio n. 22
0
                self.forwardqueue.push(msg)
            
            while len(self.forwardqueue) >= self.chunksize:
                self.sendChunk()
                
            if self.nodelay:
                self.sendPartialChunk()
                
            while self.dataReady("control"):
                msg = self.recv("control")
                if isinstance(msg, producerFinished):
                    self.sendPartialChunk()
                    self.send(msg, "signal")
                    return
                elif isinstance(msg, shutdown):
                    self.send(msg, "signal")
                    return
            self.pause()

__kamaelia_components__  = ( Chunkifier, )

if __name__ == '__main__':
    from Kamaelia.Chassis.Pipeline import pipeline
    from Kamaelia.Util.Console import ConsoleEchoer, ConsoleReader

    pipeline(
        ConsoleReader(eol=""),
        Chunkifier(20),
        ConsoleEchoer()
    ).run()
Esempio n. 23
0
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from Kamaelia.Util.PipelineComponent import pipeline
from Kamaelia.Util.Console import ConsoleReader, ConsoleEchoer

import sys
sys.path.append("../../")
sys.path.append("../../Util")
sys.path.append("../../HTTP")
sys.path.append("../../Torrent")

from DataSource import DataSource
from OnDemandIntrospector import OnDemandIntrospector

from TorrentClient import TorrentClient, BasicTorrentExplainer
from TorrentMaker import TorrentMaker

if __name__ == '__main__':

    # seed a file
    pipeline(ConsoleReader(">>> ", ""),
             TorrentMaker("http://localhost:6969/announce"), TorrentPatron(),
             BasicTorrentExplainer(),
             ConsoleEchoer()
             #TorrentPatron(),
             #BasicTorrentExplainer(),
             #ConsoleEchoer(),
             ).run()
Esempio n. 24
0
            yield 1
            while self.dataReady("inbox"):
                chunknumber += 1
                data = self.recv("inbox")

                # create list of form [filename, contents]
                command = [
                    self.basepath + "chunk" + str(chunknumber) + self.suffix,
                    data
                ]
                self.send(command, "outbox")

            while self.dataReady("control"):
                msg = self.recv("control")
                if isinstance(msg, producerFinished) or isinstance(
                        msg, shutdown):
                    self.send(producerFinished(self), "signal")
                    return

            self.pause()


__kamaelia_components__ = (ChunkNamer, )

if __name__ == "__main__":
    from Kamaelia.Chassis.Pipeline import pipeline
    from Kamaelia.Community.RJL.Kamaelia.File.WholeFileWriter import WholeFileWriter
    from Kamaelia.Util.Console import ConsoleReader
    pipeline(ConsoleReader(), ChunkNamer("test", ".txt"),
             WholeFileWriter()).run()
Esempio n. 25
0
            elif message.get("REMOVELISTENEVENT", None) is not None:
                self.eventswanted[message["REMOVELISTENEVENT"]] = False
                self.removeListenEvents([message["REMOVELISTENEVENT"]])


__kamaelia_components__ = (PygameWrapper,)

if __name__=='__main__':
    from Kamaelia.Util.Console import ConsoleReader
    from Kamaelia.UI.PygameDisplay import PygameDisplay
    from Kamaelia.UI.Pygame.Ticker import Ticker
    import sys;
    sys.path.append("../Pygame/")
    from MagnaDoodle import *
    
    # override pygame display service
    ogl_display = OpenGLDisplay.getDisplayService()
    PygameDisplay.setDisplayService(ogl_display[0])

    TICKER = Ticker(size = (150, 150)).activate()
    TICKER_WRAPPER = PygameWrapper(wrap=TICKER, position=(4, 1,-10), rotation=(-20,15,3)).activate()
    MAGNADOODLE = MagnaDoodle(size=(200,200)).activate()
    MAGNADOODLEWRAPPER = PygameWrapper(wrap=MAGNADOODLE, position=(-2, -2,-10), rotation=(20,10,0)).activate()
    READER = ConsoleReader().activate()
    
    READER.link( (READER,"outbox"), (TICKER, "inbox") )
    
    Axon.Scheduler.scheduler.run.runThreads()  
# Licensed to the BBC under a Contributor Agreement: THF
Esempio n. 26
0
        SPLIT = Fanout(["toGraphline", "toTCP"]),
        linkages = {
              ("CLIENT" , "outbox") : ("PROTO" , "inbox"),
              ("PROTO"  , "outbox") : ("SPLIT", "inbox"),
              ("PROTO"  , "heard")  : ("SELF", "outbox"), #passthrough
              ("SELF"  , "inbox") : ("PROTO" , "talk"), #passthrough
              ("SELF"  , "control") : ("PROTO" , "control"), #passthrough
              ("PROTO"  , "signal") : ("CLIENT", "control"),
              ("CLIENT" , "signal") : ("SELF" , "signal"), #passthrough
              ("SPLIT", "toGraphline") : ("SELF", "sendCopy"), #passthrough
              ("SPLIT", "toTCP") : ("CLIENT", "inbox")
              }
        )

if __name__ == '__main__':
    from Kamaelia.Util.Console import ConsoleReader
    from NiceTickerPrefab import NiceTickerPrefab as NiceTicker
    from Kamaelia.Chassis.Graphline import Graphline
    Graphline(
        reader = ConsoleReader(),
        irc = ComplexIRCClientPrefab(host="irc.freenode.net", nick="kamaeliabot", defaultChannel="#kamtest"),
        display1 = NiceTicker(render_right = 800,render_bottom = 300),
        display2 = NiceTicker(render_right = 800,render_bottom = 300, position = (0, 340)),
        linkages = {
            ("reader", "outbox") : ("irc", "inbox"),
            ("irc", "outbox") : ("display1", "inbox"),
            ("irc", "sendCopy") : ("display2", "inbox")
            }
            
    ).run()
Esempio n. 27
0
from Kamaelia.Util.Console import ConsoleReader, ConsoleEchoer
from Kamaelia.Chassis.Graphline import Graphline
from Kamaelia.File.ReadFileAdaptor import ReadFileAdaptor
from Kamaelia.Visualisation.PhysicsGraph3D.TopologyViewer3DWithParams import TopologyViewer3DWithParams
from Kamaelia.Support.Particles.SimpleLaws import SimpleLaws
from Kamaelia.UI.OpenGL.Button import Button
from Kamaelia.Apps.CL.DictChooser import DictChooser
from Kamaelia.Apps.CL.JSON import JSONDecoder
from Kamaelia.Apps.CL.CollabViewer.CollabParsing import CollabWithViewParser

laws = SimpleLaws(bondLength=2.2)

# Data can be from both DataSource and console inputs
Graphline(
    CONSOLEREADER=ConsoleReader('>>>'),
    READER=ReadFileAdaptor('Data/collab.json'),
    JSONDECODER=JSONDecoder(),
    CONSOLEECHOER=ConsoleEchoer(),
    COLLABPARSER=CollabWithViewParser(),
    BUTTONORG=Button(caption="orgView", msg="orgView", position=(-10, 8, -20)),
    BUTTONSTAFF=Button(caption="staffView",
                       msg="staffView",
                       position=(-8, 8, -20)),
    DICTCHOOSER=DictChooser(allowDefault=True),
    VIEWER=TopologyViewer3DWithParams(laws=laws),
    linkages={
        ("CONSOLEREADER", "outbox"): ("JSONDECODER", "inbox"),
        ("READER", "outbox"): ("JSONDECODER", "inbox"),
        ("JSONDECODER", "outbox"): ("COLLABPARSER", "inbox"),
        #("COLLABPARSER","outbox")  : ("CONSOLEECHOER","inbox"),
Esempio n. 28
0
                if readsomething:
                    self.selectorWait(self.fd)
                    waiting = True

            if not self.done:
                self.pause()

        self.send(removeReader(self, self.fd), '_selectorask')
        os.close(self.fd)

        self.send(producerFinished(self), "signal")
        self.debug("IntelligentFileReader terminated")


__kamaelia_components__ = (IntelligentFileReader, )

if __name__ == "__main__":

    class DebugOutput(component):
        def main(self):
            while 1:
                yield 1
                self.pause()

    pipeline(
        ConsoleReader(),  # send arbitrary messages to wake it
        IntelligentFileReader("/dev/urandom", 1024, 5),
        DebugOutput(),  # component that doesn't check its inbox
    ).run()
Esempio n. 29
0
        self.send("Backward", "infomover_commands")
        self.send("Play", "infomover_commands")


if __name__ == "__main__":
    from Kamaelia.Chassis.Graphline import Graphline
    from Kamaelia.Util.Console import ConsoleReader
    from Kamaelia.UI.PygameDisplay import PygameDisplay
    from Kamaelia.Community.THF.Kamaelia.UI.OpenGL.OpenGLDisplay import OpenGLDisplay
    from Kamaelia.Community.RJL.Kamaelia.Protocol.HTTP.HTTPClient import SimpleHTTPClient
    from Kamaelia.Community.RJL.Kamaelia.Protocol.Torrent.TorrentPatron import TorrentPatron

    ogl_display = OpenGLDisplay(limit_fps=100).activate()
    OpenGLDisplay.setDisplayService(ogl_display)
    # override pygame display service
    PygameDisplay.setDisplayService(ogl_display)

    Graphline(reader=ConsoleReader(prompt="Enter torrent location:", eol=""),
              httpclient=SimpleHTTPClient(),
              gui=TorrentOpenGLGUI(),
              backend=TorrentPatron(),
              linkages={
                  ("gui", "outbox"): ("backend", "inbox"),
                  ("reader", "outbox"): ("gui", "torrent_url"),
                  ("gui", "fetcher"): ("httpclient", "inbox"),
                  ("httpclient", "outbox"): ("gui", "torrent_file"),
                  ("backend", "outbox"): ("gui", "inbox")
              }).run()

# Licensed to the BBC under a Contributor Agreement: THF
Esempio n. 30
0
        except socket.gaierror, e:
            self.send((data, e[1]), "signal")
        else:
            self.send((data, hostname), "outbox")

    def main(self):
        if self.oneShot:
            self.doLookup(self.oneShot)
            self.send(producerFinished(self), "signal")
            return
        while True:
            while self.dataReady("inbox"):
                returnval = self.doLookup(self.recv("inbox"))
                if returnval != None:
                    self.send(returnval, "outbox")
            while self.dataReady("control"):
                msg = self.recv("control")
                if isinstance(msg, producerFinished) or isinstance(
                        msg, shutdownMicroprocess):
                    self.send(producerFinished(self), "signal")
                    return
            self.pause()


__kamaelia_components__ = (GetHostByName, )

if __name__ == "__main__":
    from Kamaelia.Chassis.Pipeline import Pipeline
    from Kamaelia.Util.Console import ConsoleReader, ConsoleEchoer
    Pipeline(ConsoleReader(">>> ", ""), GetHostByName(), ConsoleEchoer()).run()