Exemple #1
0
def EventServerClients(rhost, rport, backplane="WHITEBOARD"):
        # plug a TCPClient into the backplae
        from Kamaelia.Internet.TCPClient import TCPClient

        loadingmsg = "Fetching sketch from server..."

        return pipeline( subscribeTo(backplane),
                         TagAndFilterWrapper(
                         Graphline( GETIMG = OneShot(msg=[["GETIMG"]]),
                                    PIPE = pipeline(
                                            tokenlists_to_lines(),
                                            TCPClient(host=rhost,port=rport),
                                            chunks_to_lines(),
                                            lines_to_tokenlists(),
                                        ),
                                    BLACKOUT = OneShot(msg=[["CLEAR",0,0,0],["WRITE",100,100,24,255,255,255,loadingmsg]]),
                                    linkages = { ("self","inbox") : ("PIPE","inbox"),
                                                 ("self","control") : ("PIPE","control"),
                                                 ("PIPE","outbox") : ("self","outbox"),
                                                 ("PIPE","signal") : ("self","signal"),
                                                 ("GETIMG","outbox") : ("PIPE","inbox"),
                                                 ("BLACKOUT","outbox") : ("self","outbox"),
                                               },
                                  )
                         ),
                         publishTo(backplane),
                       ) #.activate()
Exemple #2
0
 def test_Simple(self):
     # initially manual wotsit
     pipeline(filePointer(),
         LocalFileServer(),
         Tester(self)
         ).activate()
     
     scheduler.run.runThreads()
Exemple #3
0
 def clientconnector():
     return pipeline(
         chunks_to_lines(),
         lines_to_tokenlists(),
         FilterAndTagWrapper(
             pipeline( publishTo(backplane),
                         # well, should be to separate pipelines, this is lazier!
                       subscribeTo(backplane),
                     )
             ),
         tokenlists_to_lines(),
         )
Exemple #4
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
Exemple #5
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
Exemple #6
0
import sys
if len(sys.argv) > 1:
   dj1port = int(sys.argv[1])
else:
   dj1port = 1701

class ConsoleReader(threadedcomponent):
   def run(self):
      while 1:
         line = raw_input("DJ1-> ")
         line = line + "\n"
         self.send(line, "outbox")

class message_source(Axon.Component.component):
    def main(self):
        while 1:
            self.send("hello", "outbox")
            yield 1

pipeline(
     ReadFileAdaptor("audio.1.raw", readmode="bitrate", bitrate =1536000),
#     ReadFileAdaptor("audio.1.raw", readmode="bitrate", bitrate =200000000),
     TCPClient("127.0.0.1", dj1port),
).run()

if 0:
    pipeline(
         ConsoleReader(),
         TCPClient("127.0.0.1", dj1port),
    ).run()
Exemple #7
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()

Exemple #8
0
        self.multitorrent.rawserver.add_task(self.get_status,
                                             self.config['display_interval'])
        status = self.torrent.get_status(self.config['spew'])
        self.d.display(status)

    def global_error(self, level, text):
        self.d.error(text)

    def error(self, torrent, level, text):
        self.d.error(text)

    def failed(self, torrent, is_external):
        self.doneflag.set()

    def finished(self, torrent):
        self.d.finished()


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

    # download a linux distro
    pipeline(
        ConsoleReader(">>> ", ""),
        TorrentClient(
            "http://www.tlm-project.org/public/distributions/damnsmall/current/dsl-2.4.iso.torrent"
        ),
        ConsoleEchoer(),
    ).run()
Exemple #9
0
from WholeFileWriter import WholeFileWriter
from TorrentMaker import TorrentMaker
from Kamaelia.Util.Fanout import fanout
from HTTPHelpers import HTTPMakePostRequest
from HTTPClient import SimpleHTTPClient
from TorrentPatron import TorrentPatron

from PureTransformer import PureTransformer

from OnDemandIntrospector import OnDemandIntrospector
from Kamaelia.File.Writing import SimpleFileWriter

if __name__ == '__main__':
    pipeline(
        ConsoleReader(),
        OnDemandIntrospector(),
        ConsoleEchoer(),
    ).activate()
    Graphline(
        streamin=pipeline(
            IcecastClient("http://127.0.0.1:1234/"),  # a stream's address
            IcecastDemux(),
            IcecastStreamRemoveMetadata(),
            Chunkifier(500000),
            ChunkDistributor("./"),
            WholeFileWriter(),
            TorrentMaker("http://192.168.1.5:6969/announce"),
        ),
        split=fanout(["toMetaUploader", "toSharer"]),
        fileupload=pipeline(ChunkDistributor("./torrents/", ".torrent"),
                            WholeFileWriter(),
Exemple #10
0
	    
class echoer(Axon.Component.component):
    def main(self):
        count = 0
        while 1:
            self.pause()
            yield 1
            while self.dataReady("inbox"):
                data = self.recv("inbox")
                print "echoer #",self.id,":", data, "count:", count
                count = count +1

# create a back plane by name Random talk
Backplane("RandomTalk").activate()

# create a reader and pipeline it to publish object
pipeline(
       MyReader(),
       Encryptor("12345678901234567890123456789012"),
       publishTo("RandomTalk"),
).activate()

#pipeline the subscribe object to the echoer
#note the connection publisher and subscriber is via BACKPLANE:)
pipeline(
        subscribeTo("RandomTalk"),
        Decryptor("12345678901234567890123456789012"),
	echoer(),
).run()
            
Exemple #11
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.
"""
This is a simple proxy to relay multicast data from a given multicast
group and port as a TCP Service on a given port. It's worth noting that
this is one way - any data from the TCP connection is discarded.
"""

from Kamaelia.Util.Backplane import Backplane, publishTo, subscribeTo
from Kamaelia.Internet.Multicast_transceiver import Multicast_transceiver
from Kamaelia.Util.PipelineComponent import pipeline
from config import mcast_group, mcast_port, mcast_tcp_splitter_port

p = Backplane("MulticastProxy").activate()

pipeline(
    Multicast_transceiver("0.0.0.0", mcast_port, mcast_group, 0),
    publishTo("MulticastProxy"),
).activate()


def RelayMulticastData():  # Protocol handler for each connected client
    return subscribeTo("MulticastProxy")


SimpleServer(RelayMulticastData, mcast_tcp_splitter_port).run()
Exemple #12
0
        self.send( shutdownMicroprocess(self), "signal")
        # we'll destroy outselves when we receive a shutdown message ourselves
        self.label["text"] = "Shutting down..."
        self.playbutton.destroy()

        
if __name__ == "__main__":
    from Axon.Scheduler import scheduler

    from Kamaelia.Util.PipelineComponent import pipeline
    from Kamaelia.vorbisDecodeComponent import VorbisDecode, AOAudioPlaybackAdaptor
    from Kamaelia.File.Reading import FixedRateControlledReusableFileReader
    
    # make pipeline, but make the signal->control path loop round, so a shutdownMicroprocess()
    # message sent by ControlWindow will eventually get back to ControlWindow()
    p=pipeline( ControlWindow(),
                FixedRateControlledReusableFileReader( readmode="bytes",
                                                       rate=128000/8,
                                                       chunksize=1024 ),
                VorbisDecode(),
                AOAudioPlaybackAdaptor()
              ).activate()
    p.link( (p,"signal"), (p,"control") )
    
    if 0:
        from Kamaelia.Internet.TCPClient import TCPClient
        from Kamaelia.Util.Introspector import Introspector
        pipeline(Introspector(), TCPClient("127.0.0.1",1500)).activate()
    
    scheduler.run.runThreads(slowmo=0)
Exemple #13
0
                c += 1
                data = self.recv("inbox")
                size += len(data)
                self.send(data, "outbox")
            if (c % 20) == 0:
                t_dash = time.time()
                if t_dash - t > 1:
                    print int((size / (t_dash - t)) * 8)
                    t = t_dash
                    size = 0
            yield 1


if 1:
    pipeline(
        DVB_Multiplex(freq, [600, 601], feparams),
        SimpleFileWriter("somefile.ts"),
    ).run()

if 0:
    pipeline(
        ReadFileAdaptor("somefile.ts", readsize=8000000),
        MaxSizePacketiser(),
        Multicast_transceiver("0.0.0.0", 0, "224.168.2.9", 1600),
    ).activate()

    pipeline(
        Multicast_transceiver("0.0.0.0", 1600, "224.168.2.9", 0),
        SimpleDetupler(1),
        SimpleFileWriter("otherfile.ts"),
    ).run()
                "CBBC":4671,
              }

import time
class dataRateMeasure(component):
    def main(self):
        size = 0
        c = 0
        t = time.time()
        while 1:
            while self.dataReady("inbox"):
                c += 1
                data = self.recv("inbox")
                size += len(data)
                self.send(data, "outbox")
            if (c % 20) == 0:
                t_dash = time.time()
                if t_dash - t > 1:
                    print int((size/(t_dash - t))*8)
                    t = t_dash
                    size = 0
            yield 1

if 1:
    pipeline(
        Multicast_transceiver("0.0.0.0", 1600, "224.168.2.9", 0),
        SimpleDetupler(1),
        dataRateMeasure(),
        Pipethrough("mplayer -"),
    ).run()
Exemple #15
0
                          ("PAINTER", "outbox")    : ("SPLIT", "inbox"),
                          ("SPLIT", "outbox")      : ("CANVAS", "inbox"),
                          ("SPLIT", "outbox2")     : ("self", "outbox"), # send to network

                          ("self", "inbox")        : ("PREFILTER", "inbox"),
                          ("PREFILTER", "outbox")  : ("CANVAS", "inbox"),
                          ("PREFILTER", "history_event")  : ("HISTORY", "inbox"),
                          ("CANVAS", "outbox")     : ("self", "outbox"),

                          ("CANVAS","surfacechanged") : ("HISTORY", "inbox"),
                          },
                    )

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
Exemple #16
0
class printer(component):
   def tick(self,ID):
      for i in (1,2,3,4,5,6,7,8,9,10):
         print "TICK", ID, i
         yield i
      print "TICK DONE"
   def main(self):
      ID = randint(0,20000)
      print "PRE-WAIT"
      yield WaitComplete(self.tick(ID))
      print "POST-WAIT"
      while 1:
         yield 1
         try:
            data = self.recv("inbox")
            print data,
         except:
           print "NO DATA READY, LETS WAIT A BIT"
           ID = randint(0,20000)
           print "PRE-WAIT"
           yield WaitComplete(self.tick(ID))
           print "POST-WAIT"

pipeline(
         cat("""\
Information Center, n.: 
A room staffed by professional computer people whose job it is to tell you why you cannot have the information you require.
""".split(" ")),
         printer(),
).run()
Exemple #17
0
#
#     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.

import Axon
from Kamaelia.Util.PipelineComponent import pipeline
from Kamaelia.Internet.TCPClient import TCPClient
from Kamaelia.Util.Console import ConsoleEchoer

class linesender(Axon.Component.component):
    def __init__(self, *lines):
        super(linesender, self).__init__()
        self.lines = lines[:]
    def main(self):
        for line in self.lines:
           self.send(line+"\r\n", "outbox")
           yield 1

pipeline(
    linesender("GET /cgi-bin/blog/feed.cgi HTTP/1.0",
               "Host: 127.0.0.1",
               ""),
    TCPClient("127.0.0.1", 80),
    ConsoleEchoer(),
).run()
Exemple #18
0
# (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.
"""
The purpose behind this component is to allow the following to occur:

pipeline(
   dataSource(),
   ExternalPipeThrough("command", *args),
   dataSink(),
).run()

More specificaly, the longer term interface of this component will be:

ExternalPipeThrough:
   inbox - data recieved here is sent to the program's stdin
   outbox - data sent here is from the program's stdout
   control - at some point we'll define a mechanism for describing
      control messages - these will largely map to SIG* messages
Exemple #19
0
def dumping_client():
    return pipeline(
        TCPClient("132.185.131.178", 1700),
        printer(),   
    )
Exemple #20
0
        assert (mode == "play" or mode == "record")
        filename = sys.argv[2]
        rhost = sys.argv[3]
        rport = int(sys.argv[4])
    except:
        sys.stderr.write(
            "Usage:\n    ./WhiteboardClerk play|record filename host port\n\n")
        sys.exit(1)

    if mode == "record":
        print "Recording..."
        pipeline(
            OneShot(msg=[["GETIMG"]]),
            tokenlists_to_lines(),
            TCPClient(host=rhost, port=rport),
            chunks_to_lines(),
            Timestamp(),
            IntersperseNewlines(),
            SimpleFileWriter(filename),
        ).run()

    elif mode == "play":
        print "Playing..."
        pipeline(
            Graphline(
                FILEREADER=PromptedFileReader(filename, "lines"),
                DETIMESTAMP=DeTimestamp(),
                linkages={
                    # data from file gets detimestamped and sent on
                    ("FILEREADER", "outbox"): ("DETIMESTAMP", "inbox"),
                    ("DETIMESTAMP", "outbox"): ("", "outbox"),
Exemple #21
0
                self.postoffice.deregisterlinkage(thelinkage = linkages[box])
                self.deleteOutbox(outboxes[box])

            del self.actors[actorName]


    def exeuntAll(self, includingNarrator=False):
        self.send("EXIT ALL...\n","outbox")
        for actor in self.actors.keys():
            if includingNarrator or actor != "NARRATOR":
                for retval in self.exeunt(actor):
                    yield retval






if __name__ == "__main__":
    from Kamaelia.Util.PipelineComponent import pipeline
    from Kamaelia.File.Reading import RateControlledFileReader
    from Kamaelia.Util.ConsoleEcho import consoleEchoer

    pipeline( RateControlledFileReader("../CE/twelfthnight.txt", readmode="lines", rate=50, chunksize=1),
              demodulation(),
              error_correction(),
              demultiplexing(),
              director("127.0.0.1", "#theglobe"),
              consoleEchoer(),
            ).run()
            
Exemple #22
0
    from Kamaelia.ReadFileAdaptor import ReadFileAdaptor
    from Kamaelia.Util.Graphline import Graphline

    channels_london =  {
           "MORE4+1" : (   538, #MHz
                         [ 701, 702 ] # PID (programme ID) for video and PID for audio
                       )
    }
    services = {
           "NEWS24": (754, [640, 641]),
           "MORE4+1": (810, [701,702]),
           "TMF": (810, [201,202])
    }
    if 0:
        pipeline(
           DVB_Multiplex(754, [640, 641, 620, 621, 622, 610, 611, 612, 600, 601, 602, 12]),
           SimpleFileWriter("multiplex_new.data")
        ).run()
    if 1:
        Graphline(
            SOURCE=ReadFileAdaptor("multiplex.data"),
            DEMUX=DVB_Demuxer({
                "640": "NEWS24",
                "641": "NEWS24",
                "600": "BBCONE",
                "601": "BBCONE",
                "610": "BBCTWO",
                "611": "BBCTWO",
                "620": "CBBC",
                "621": "CBBC",
            }),
            NEWS24=SimpleFileWriter("news24.data"),
Exemple #23
0
                    torrents.append([msg.torrentid, msg.savefolder])

                elif isinstance(msg, TIPCTorrentStatusUpdate):
                    print msg.torrentid
                    if msg.torrentid == torrents[0][0]:
                        print msg.statsdictionary
                        if msg.statsdictionary.get("fractionDone", 0) == 1:
                            self.send(torrents[0][1], "outbox")
                            torrents.pop(0)
            self.pause()


if __name__ == "__main__":
    partslist = "filelist.txt"
    resourcefetcher = TriggeredFileReader  # SimpleHTTPClient

    pipeline(ConsoleReader(), OnDemandIntrospector(), ConsoleEchoer()).activate()

    pipeline(
        CheapAndCheerfulClock(30.0),
        TriggeredSource(partslist),
        resourcefetcher(),
        LineSplit(),
        UnseenOnly(),
        PureTransformer(lambda x: x or None),  # eradicate blank lines
        resourcefetcher(),
        TorrentPatron(),
        StreamReconstructor(),
        ConsoleEchoer(),
    ).run()
Exemple #24
0
        t = time.time()
        while 1:
            while self.dataReady("inbox"):
                c += 1
                data = self.recv("inbox")
                size += len(data)
                self.send(data, "outbox")
            if (c % 20) == 0:
                t_dash = time.time()
                if t_dash - t > 1:
                    print int((size/(t_dash - t))*8)
                    t = t_dash
                    size = 0
            yield 1


pipeline(
    AlsaRecorder(),
    SpeexEncode(3),
#   Encryptor("1234567812345678", "AES"),
    dataRateMeasure(),
    SingleServer(port=1601),
).activate()

pipeline(
    TCPClient("127.0.0.1", 1601),
#    Decryptor("1234567812345678", "AES"),
    SpeexDecode(3),
    AlsaPlayer(),
).run()
Exemple #25
0
            if self.dataReady("linknode"):
                self.recv("linknode")
                if node is not None:
                    linkstart = node
                    linkmode = True

TVC = TopologyViewerComponent(position=(0,0)).activate()
Graphline(
    NEW = Button(caption="New Component", msg="NEXT", position=(72,8)),
    EDIT = Button(caption="Edit Component", msg="NEXT", position=(182,8)),
    DEL = Button(caption="Delete Component", msg="NEXT", position=(292,8)),
    LINK = Button(caption="Make Link", msg="NEXT", position=(402,8)),
    CONSOLEINPUT = pipeline(
                     ConsoleReader(">>> "),
                     chunks_to_lines(),
                     lines_to_tokenlists(),
                   ),
    EDITOR_LOGIC = EditorLogic(),
    DEBUG = ConsoleEchoer(),
    TVC = TVC, 
    linkages = {
        ("CONSOLEINPUT", "outbox"): ("TVC", "inbox"),
        ("NEW", "outbox"): ("EDITOR_LOGIC", "newnode"),
        ("EDIT", "outbox"): ("EDITOR_LOGIC", "editnode"),
        ("DEL", "outbox") : ("EDITOR_LOGIC", "delnode"),
        ("LINK", "outbox") : ("EDITOR_LOGIC", "linknode"),
        ("TVC", "outbox") : ("EDITOR_LOGIC", "itemselect"),
        ("EDITOR_LOGIC", "outbox") : ("DEBUG", "inbox"),
        ("EDITOR_LOGIC", "nodeevents") : ("TVC", "inbox"),
    }
Exemple #26
0
#!/usr/bin/env python

# The contents of this file are subject to the BitTorrent Open Source License
# Version 1.1 (the License).  You may not copy or use this file, in either
# source code or executable form, except in compliance with the License.  You
# may obtain a copy of the License at http://www.bittorrent.com/license/.
#
# Software distributed under the License is distributed on an AS IS basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
# for the specific language governing rights and limitations under the
# License.

"""\
=================
.torrent Maker
=================

This component accepts filenames, one per message, in "inbox" and outputs the metadata (contents of the .torrent file) for that file to outbox.

Example Usage
-------------

This setup accepts filenames, one per line, and then seeds them using the given
tracker.

pipeline(
    ConsoleReader(eol=""),
    TorrentMaker(defaulttracker="http://sometracker.example.com:6969/announce"),
    TorrentPatron()
).run()
    
Exemple #27
0
            if self.dataReady("linknode"):
                self.recv("linknode")
                if node is not None:
                    linkstart = node
                    linkmode = True


TVC = TopologyViewerComponent(position=(0, 0)).activate()
Graphline(NEW=Button(caption="New Component", msg="NEXT", position=(72, 8)),
          EDIT=Button(caption="Edit Component", msg="NEXT", position=(182, 8)),
          DEL=Button(caption="Delete Component", msg="NEXT",
                     position=(292, 8)),
          LINK=Button(caption="Make Link", msg="NEXT", position=(402, 8)),
          CONSOLEINPUT=pipeline(
              ConsoleReader(">>> "),
              chunks_to_lines(),
              lines_to_tokenlists(),
          ),
          EDITOR_LOGIC=EditorLogic(),
          DEBUG=ConsoleEchoer(),
          TVC=TVC,
          linkages={
              ("CONSOLEINPUT", "outbox"): ("TVC", "inbox"),
              ("NEW", "outbox"): ("EDITOR_LOGIC", "newnode"),
              ("EDIT", "outbox"): ("EDITOR_LOGIC", "editnode"),
              ("DEL", "outbox"): ("EDITOR_LOGIC", "delnode"),
              ("LINK", "outbox"): ("EDITOR_LOGIC", "linknode"),
              ("TVC", "outbox"): ("EDITOR_LOGIC", "itemselect"),
              ("EDITOR_LOGIC", "outbox"): ("DEBUG", "inbox"),
              ("EDITOR_LOGIC", "nodeevents"): ("TVC", "inbox"),
          }).run()
Exemple #28
0
if __name__ == "__main__":

    from Axon.Scheduler import scheduler

    from Kamaelia.Util.PipelineComponent import pipeline
    from Kamaelia.Visualisation.PhysicsGraph.TopologyViewerComponent import TopologyViewerComponent

    from Kamaelia.Util.Splitter import PlugSplitter as Splitter
    from Kamaelia.Util.Splitter import Plug

    #    from Filters import FilterSelectMsgs, FilterTopologyMsgs
    from PipeBuild import PipeBuild
    from PipelineWriter import PipelineWriter
    from BuildViewer import BuildViewer
    from GUI import BuilderControlsGUI, TextOutputGUI

    items = list(getAllClasses(COMPONENTS))

    pipegen = Splitter(pipeline(BuilderControlsGUI(items), PipeBuild()))

    viewer = Splitter(BuildViewer())

    Plug(viewer, pipegen).activate()  # feedback loop for 'selected' msgs

    Plug(pipegen, viewer).activate()
    Plug(pipegen, pipeline(PipelineWriter(),
                           TextOutputGUI("Pipeline code"))).activate()

    scheduler.run.runThreads()
Exemple #29
0
# 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 Axon.Component import component
from Axon.Ipc import producerFinished, shutdown
from PureTransformer import PureTransformer

"""\
=================
Data Source component
=================

This component outputs messages specified at its creation one after another.

Example Usage
-------------

To output "hello" then "world":
pipeline(
    DataSource(["hello", "world"]),
    ConsoleEchoer()
).run()
Exemple #30
0
    else:
    
        i = None
        if "navelgaze" in dictArgs:
            del dictArgs["navelgaze"]
            dictArgs['noServer'] = True
            from Kamaelia.Util.Introspector import Introspector
            i = Introspector()

        if "introspect" in dictArgs:
            (server, port) = dictArgs["introspect"]
            del dictArgs["introspect"]
            
            from Kamaelia.Util.Introspector import Introspector
            from Kamaelia.Internet.TCPClient import TCPClient
            from Kamaelia.Util.PipelineComponent import pipeline
            
            pipeline( Introspector(), 
                      TCPClient(server, port) 
                    ).activate()

        app = AxonVisualiserServer(caption="Axon / Kamaelia Visualiser", **dictArgs)

        if i:
            i.link( (i,"outbox"), (app,"inbox") )
            i.activate()

        app.activate()

        _scheduler.run.runThreads(slowmo=0)
Exemple #31
0
            
            # if we should send some more if we can
            if len(self.outboxes["outbox"]) < self.maxqueue:
                if self.dataReady("_selectorready"):
                    #print "selector is ready"
                    msg = self.recv("_selectorready")
                    self.tryReadChunk(self.fd)
                    self.selectorWait(self.fd)
            self.pause()
            
        self.send(producerFinished(self), "signal")
        #print "IntelligentFileReader terminated"
        
class DebugOutput(component):
    def main(self):
        while 1:
            yield 1
            self.pause()
            #if self.dataReady("inbox"):
            #    msg = self.recv("inbox")
            
            #print "Queue length = " + str(len(self.["inbox"]))
            
            
if __name__ == "__main__":
    pipeline(
        ConsoleReader(),
        IntelligentFileReader("/dev/urandom", 1024, 5),
        DebugOutput(),
    ).run()
Exemple #32
0
                    "outbox"    : PPostbox.Outbox
                }
                
from Kamaelia.UI.PygameDisplay import PygameDisplay

pgd = PygameDisplay(width=800,height=600).activate()
PygameDisplay.setDisplayService(pgd)

TVC = TopologyViewerComponent(position=(0,48), laws = AxonLaws(), particleTypes=particleTypes)

SANDBOX = Sandbox()

Graphline(
    CONSOLEINPUT = pipeline(
                     ConsoleReader(">>> "),
                     chunks_to_lines(),
                     lines_to_tokenlists(),
                   ),
    DEBUG = ConsoleEchoer(forwarder=True),
    TVC = TVC,
    INTROSPECTOR = pipeline(Introspector(SANDBOX), chunks_to_lines(), lines_to_tokenlists()),
    SANDBOX = SANDBOX,
    NEW = Button(caption="New Component", msg="NEXT", position=(8,8)),
    CHANGE = Button(caption="Change Component", msg="NEXT", position=(128,8)),
    DEL = Button(caption="Delete Component", msg="NEXT", position=(256,8)),
    LINK = Button(caption="Make Link", msg="NEXT", position=(402,8)),
    UNLINK = Button(caption="Break Link", msg="NEXT", position=(480,8)),
    GO   = Button(caption="Activate!", msg="NEXT", position=(590,8)),
    EDITOR_LOGIC = EditorLogic(),
    CED = ComponentEditor(classes),
    linkages = {
Exemple #33
0
# 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()
Exemple #34
0

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()
Exemple #35
0

class display(component):
    "Takes a message from it's inbox, does stuff to it and sends it to it's outbox indefinitely"

    def main(self):
        while 1:
            if self.dataReady("inbox"):
                pygame.init()
                self.list_surface_components = self.recv("inbox")

                myDisplay.prepare_display(self.list_surface_components)
                myDisplay.display()
                #debug

            yield 1


myDisplay = pygame_display.MyDisplay()
display_size = [1000, 800]

filename = "twelfthnight.txt"
picture_directory = "characters"

app = pipeline(producer(filename), demodulation(), error_correction(),
               demultiplexing(), decode(picture_directory), video_scaling(),
               display())

app.activate()
scheduler.run.runThreads(slowmo=0)
Exemple #36
0
       phoneLibs = False
       
 #  IP_toConnectTo = "132.185.133.36"
   IP_toConnectTo = "127.0.0.1"
   print IP_toConnectTo 
   serverport = 1616
   delay = 5
   windows_ClientContentDir = "C:\\ClientContent\\"
   mac_ClientContentDir = "/temp/"
   phone_ClientContentDir = "E:\\Ciaran's Files\\Temp"
   ClientContentDir = [windows_ClientContentDir, mac_ClientContentDir, phone_ClientContentDir]
   demo_mode = True

   import sys
   sys.path.append("..\Layout")
   from Introspector import Introspector
   from Kamaelia.Internet.TCPClient import TCPClient
   from Kamaelia.Util.PipelineComponent import pipeline
                    
   pipeline( Introspector(), 
             TCPClient("132.185.133.29",1500) 
            ).activate()
   
   t = UserInterface(IP_toConnectTo, serverport, delay, ClientContentDir, demo_mode)
   t.activate()
   scheduler.run.runThreads(slowmo=0)

#   t = Client()
#   t.activate()
#   scheduler.run.runThreads(slowmo=0)
Exemple #37
0
            while self.dataReady("inbox"):
                c += 1
                data = self.recv("inbox")
                size += len(data)
                self.send(data, "outbox")
            if (c % 20) == 0:
                t_dash = time.time()
                if t_dash - t > 1:
                    print int((size/(t_dash - t))*8)
                    t = t_dash
                    size = 0
            yield 1

if 1:
    pipeline(
        DVB_Multiplex(freq, [600,601], feparams),
        SimpleFileWriter("somefile.ts"),
    ).run()

if 0:
    pipeline(
        ReadFileAdaptor("somefile.ts",readsize=8000000),
        MaxSizePacketiser(),
        Multicast_transceiver("0.0.0.0", 0, "224.168.2.9", 1600),
    ).activate()

    pipeline(
        Multicast_transceiver("0.0.0.0", 1600, "224.168.2.9", 0),
        SimpleDetupler(1),
        SimpleFileWriter("otherfile.ts"),
    ).run()
Exemple #38
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()
Exemple #39
0
                result.append(chr(mixed_lsb))
                result.append(chr(mixed_msb))

        except IndexError:
            print "WARNING: odd (not even) packet size"
        return "".join(result)


Backplane("DJ1").activate()
Backplane("DJ2").activate()
Backplane("music").activate()
Backplane("destination").activate()

pipeline(
    SingleServer(port=dj1port),
    publishTo("DJ1"),
).activate()

pipeline(
    SingleServer(port=dj2port),
    publishTo("DJ2"),
).activate()

pipeline(
    SingleServer(port=musicport),
    publishTo("music"),
).activate()

livecontrol = 1
networkserve = 0
standalone = 1
Exemple #40
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()
Exemple #41
0
 def dumping_server():
     return pipeline(
         SingleServer(mockserverport),
         printer(),
     )
Exemple #42
0

if __name__ == "__main__":

    from Axon.Scheduler import scheduler

    from Kamaelia.Util.PipelineComponent import pipeline
    from Kamaelia.Visualisation.PhysicsGraph.TopologyViewerComponent import TopologyViewerComponent

    from Kamaelia.Util.Splitter import PlugSplitter as Splitter
    from Kamaelia.Util.Splitter import Plug

    #    from Filters import FilterSelectMsgs, FilterTopologyMsgs
    from PipeBuild import PipeBuild
    from PipelineWriter import PipelineWriter
    from BuildViewer import BuildViewer
    from GUI import BuilderControlsGUI, TextOutputGUI

    items = list(getAllClasses(COMPONENTS))

    pipegen = Splitter(pipeline(BuilderControlsGUI(items), PipeBuild()))

    viewer = Splitter(BuildViewer())

    Plug(viewer, pipegen).activate()  # feedback loop for 'selected' msgs

    Plug(pipegen, viewer).activate()
    Plug(pipegen, pipeline(PipelineWriter(), TextOutputGUI("Pipeline code"))).activate()

    scheduler.run.runThreads()
#     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.
"""
Splitting server. This expects a single inbound connection on one port and spits it out to all recipients who connect on another port. This can be
used as an alternate server for the TCPRelayMulticast to connect to, and
it would expect to be fed using MulticastTCPClientRelay.

"""

from Kamaelia.Util.Backplane import Backplane, publishTo, subscribeTo
from Kamaelia.Util.PipelineComponent import pipeline
from Kamaelia.SimpleServerComponent import SimpleServer
from Kamaelia.SingleServer import SingleServer
from config import tcp_tcp_splitter_port, tcp_splitter_client_port

p = Backplane("Splitting").activate()

pipeline(SingleServer(tcp_tcp_splitter_port), publishTo("Splitting")).activate()


def SubscribeToSplitData():  # Protocol handler for each connected client
    return subscribeTo("Splitting")


SimpleServer(SubscribeToSplitData, tcp_splitter_client_port).run()
Exemple #44
0
def dumping_server():
    return pipeline(
        SingleServer(1700),
        printer(),
    )
Exemple #45
0
                    if mp["done"]:
                        flags.append("[DONE]")
                    output += "%8d  %8d  %6.2f  %6d  %s %s\n" % (
                        mp["running"], mp["active"], mp["%usage"],
                        mp["lineno"], mp["name"], " ".join(flags))
                output += "---------------------------------------------------------\n"
                self.send(output, "outbox")

            yield 1
            self.pause()


def FormattedProfiler(*largs, **kargs):
    return pipeline(Profiler(*largs, **kargs), ProfilerOutputFormatter())


if __name__ == "__main__":
    from Kamaelia.Util.Console import ConsoleEchoer

    class BusyComponent(component):
        def main(self):
            while 1:
                yield 1

    BusyComponent().activate()

    pipeline(
        FormattedProfiler(10.0, 1.0),
        ConsoleEchoer(),
    ).run()
# See the License for the specific language governing permissions and
# limitations under the License.
# -------------------------------------------------------------------------
#
# RETIRED
print """
/Sketches/filereading/ClientStreamToFile.py

 This file has been retired.
 It is retired because it is now part of the main code base.
 If you want to use this, you can now find it in:
     Kamaelia-Distribution/Examples/example12/ClientStreamToFile.py

 (Hopefully contains enough info to do what you wanted to do.)
"""

import sys
sys.exit(0)
#
from Kamaelia.Internet.TCPClient import TCPClient
from Kamaelia.Util.PipelineComponent import pipeline
from WriteFileAdapter import WriteFileAdapter

outputfile = "/tmp/received.raw"
clientServerTestPort=1500

pipeline(TCPClient("127.0.0.1",clientServerTestPort),
         WriteFileAdapter(outputfile)
        ).run()

Exemple #47
0
def FormattedProfiler(*largs, **kargs):
    return pipeline(Profiler(*largs, **kargs), ProfilerOutputFormatter())
# 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.
"""
Splitting server. This expects a single inbound connection on one port and spits it out to all recipients who connect on another port. This can be
used as an alternate server for the TCPRelayMulticast to connect to, and
it would expect to be fed using MulticastTCPClientRelay.

"""

from Kamaelia.Util.Backplane import Backplane, publishTo, subscribeTo
from Kamaelia.Util.PipelineComponent import pipeline
from Kamaelia.SimpleServerComponent import SimpleServer
from Kamaelia.SingleServer import SingleServer
from config import tcp_tcp_splitter_port, tcp_splitter_client_port

p = Backplane("Splitting").activate()

pipeline(
    SingleServer(tcp_tcp_splitter_port),
    publishTo("Splitting"),
).activate()


def SubscribeToSplitData():  # Protocol handler for each connected client
    return subscribeTo("Splitting")


SimpleServer(SubscribeToSplitData, tcp_splitter_client_port).run()
Exemple #49
0
def dumping_client():
    return pipeline(
        TCPClient("132.185.131.178", 1700),
        printer(),
    )
Exemple #50
0
#!/usr/bin/python

from Kamaelia.Util.PipelineComponent import pipeline
from Record import AlsaRecorder
from Play import AlsaPlayer
from Kamaelia.SingleServer import SingleServer
from Kamaelia.Internet.TCPClient import TCPClient

pipeline(
    AlsaRecorder(),
    SingleServer(port=1601),
).activate()

pipeline(
    TCPClient("127.0.0.1", 1601),
    AlsaPlayer(),
).run()
Exemple #51
0
    from Kamaelia.Util.PipelineComponent import pipeline
    from Kamaelia.File.Writing import SimpleFileWriter
    from Kamaelia.ReadFileAdaptor import ReadFileAdaptor
    from Kamaelia.Util.Graphline import Graphline
    from Kamaelia.Util.Console import ConsoleEchoer

    Graphline(
        #        SOURCE=ReadFileAdaptor("/home/matteh/eit.ts"),
        SOURCE=DVB_Multiplex(505833330.0 / 1000000.0, [18, 20]),
        DEMUX=DVB_Demuxer({
            "18": "_EIT_",
            "20": "_DATETIME_"
        }),
        EIT=pipeline(
            PSIPacketReconstructor(),
            EITPacketParser(),
            NowNextServiceFilter(4164, 4228),  # BBC ONE & BBC TWO
            NowNextChanges(),
            ConsoleEchoer(),
        ),
        DATETIME=pipeline(
            PSIPacketReconstructor(),
            TimeAndDatePacketParser(),
            ConsoleEchoer(),
        ),
        linkages={
            ("SOURCE", "outbox"): ("DEMUX", "inbox"),
            ("DEMUX", "_EIT_"): ("EIT", "inbox"),
            ("DEMUX", "_DATETIME_"): ("DATETIME", "inbox"),
        }).run()