Esempio n. 1
0
def NetworkLinkage(ip1, port1, ip2, port2):
    return Graphline(PIPE=Pipeline(
        TCPClient(ip1, port1),
        TCPClient(ip2, port2),
    ),
                     linkages={
                         ("PIPE", "outbox"): ("PIPE", "inbox"),
                         ("PIPE", "signal"): ("PIPE", "control"),
                     })
Esempio n. 2
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()
Esempio n. 3
0
def Pop3Proxy():
    return Graphline(SERVER=TCPClient(POP3SERVER_NAME, POP3SERVER_PORT),
                     RELAY=Pop3CommandRelay(),
                     LINESPLIT_CMDS=LineSplit(),
                     LINESPLIT_RESP=LineSplit(),
                     DELETION_STORE=SimpleCache(PERSISTENCE_STORE_FILENAME),
                     linkages={
                         ("", "inbox"): ("LINESPLIT_CMDS", "inbox"),
                         ("", "control"): ("LINESPLIT_CMDS", "control"),
                         ("LINESPLIT_CMDS", "outbox"): ("RELAY", "inbox"),
                         ("LINESPLIT_CMDS", "signal"): ("RELAY", "control"),
                         ("RELAY", "toServer"): ("SERVER", "inbox"),
                         ("RELAY", "toServerControl"): ("SERVER", "control"),
                         ("SERVER", "outbox"): ("LINESPLIT_RESP", "inbox"),
                         ("SERVER", "signal"): ("LINESPLIT_RESP", "control"),
                         ("LINESPLIT_RESP", "outbox"): ("RELAY", "fromServer"),
                         ("LINESPLIT_RESP", "signal"):
                         ("RELAY", "fromServerSignal"),
                         ("RELAY", "outbox"): ("", "outbox"),
                         ("RELAY", "signal"): ("", "signal"),
                         ("RELAY", "toStore"): ("DELETION_STORE", "inbox"),
                         ("RELAY", "toStoreControl"):
                         ("DELETION_STORE", "control"),
                         ("DELETION_STORE", "outbox"): ("RELAY", "fromStore"),
                     })
Esempio n. 4
0
    def start_task(self):
        from Axon.Introspector import Introspector
        from Kamaelia.Chassis.Pipeline import Pipeline
        from Kamaelia.Internet.TCPClient import TCPClient

        self.p = Pipeline(Introspector(), TCPClient(*self.visualiser_addr))
        self.p.activate()
Esempio n. 5
0
def EventServerClients(rhost, rport, 
                       whiteboardBackplane="WHITEBOARD",
                       audioBackplane="AUDIO"):
    # plug a TCPClient into the backplane
    
    loadingmsg = "Fetching sketch from server..."

    return Graphline(
            # initial messages sent to the server, and the local whiteboard
            GETIMG = Pipeline(
                        OneShot(msg=[["GETIMG"]]),
                        tokenlists_to_lines()
                    ),
            BLACKOUT =  OneShot(msg="CLEAR 0 0 0\r\n"
                                    "WRITE 100 100 24 255 255 255 "+loadingmsg+"\r\n"),
            NETWORK = TCPClient(host=rhost,port=rport),
            APPCOMMS = clientconnector(whiteboardBackplane=whiteboardBackplane,
                                       audioBackplane=audioBackplane),
            linkages = {
                ("GETIMG",   "outbox") : ("NETWORK",    "inbox"), # Single shot out
                ("APPCOMMS", "outbox") : ("NETWORK", "inbox"), # Continuous out

                ("BLACKOUT", "outbox") : ("APPCOMMS", "inbox"), # Single shot in
                ("NETWORK", "outbox") : ("APPCOMMS", "inbox"), # Continuous in
            } 
        )
Esempio n. 6
0
        def main(self):
            self.lagger = Lagger()
            self.irc = IRCBot("[kambot-logging]", "", "#kamaelia",
                              "kamaeliabot")
            self.kambot = Kambot("[kambot-logging]", "#kamaelia")
            self.client = TCPClient("irc.freenode.net", 6667, 1)
            self.writer = DateNamedLogger(
                "/home/ryan/kamhttpsite/kamaelia/irc/", ".txt")

            # IRC <-> Kambot
            self.link((self.irc, "heard"), (self.kambot, "inbox"))
            self.link((self.kambot, "outbox"), (self.irc, "command"))

            # Kambot -> file writer
            self.link((self.kambot, "log"), (self.writer, "inbox"))

            # TCP <-> IRC
            self.link((self.irc, "outbox"), (self.client, "inbox"))
            self.link((self.client, "outbox"), (self.irc, "inbox"))

            self.addChildren(self.lagger, self.irc, self.kambot, self.client,
                             self.writer)
            yield Axon.Ipc.newComponent(*(self.children))
            while 1:
                self.pause()
                yield 1
Esempio n. 7
0
def HTTPDataStreamingClient(fullurl, method="GET", body=None, headers={}, username=None, password=None, proxy=None):
    # NOTE: username not supported yet
    # NOTE: password not supported yet

    headers = dict(headers)
    proto, host, port, path = parse_url(fullurl)
    if username is not None and password is not None:
        (header_field, header_value) = http_basic_auth_header(username, password)
        headers[header_field] = header_value

    if proxy != None:
        request = fullurl
        _, req_host , req_port, _ = parse_url(proxy)
    else:
        request = path
        req_host , req_port = host, port

    return Pipeline(
                    HTTPClientRequest(url=request, host=host, method=method, postbody=body, headers=headers),
                    TCPClient(req_host, req_port, wait_for_serverclose=True),
                    HTTPClientResponseHandler(suppress_header = True),
                   )

    # Leaving this here for a little while, since it is interesting/useful
    # Worth bearing in mind this next line will never execute

    return Pipeline(
                    HTTPClientRequest(url=request, host=host, method=method, postbody=body, headers=headers),
                    ComponentBoxTracer(
                        TCPClient(req_host, req_port, wait_for_serverclose=True),
                        Pipeline(
                            PureFilter(lambda x: x[0] == "outbox"),           # Only interested in data from the connection
                            PureTransformer(lambda x: x[1]),                  # Just want the data from the wire
                            PureTransformer(lambda x: base64.b64encode(x)+"\n"), # To ensure we capture data as chunked on the way in
                            SimpleFileWriter("tweets.b64.txt"),                # Capture for replay / debug
                        ),
                    ),
                    ComponentBoxTracer(
                        HTTPClientResponseHandler(suppress_header = True),
                        Pipeline(
                            PureFilter(lambda x: x[0] == "outbox"), # Only want the processed data here
                            PureTransformer(lambda x: x[1]), # Only want the raw data
                            SimpleFileWriter("tweets.raw.txt"),
                        ),
                    )
                   )
Esempio n. 8
0
	def _buildPublicProtocol(self):
		addr = getattr(self.publicServer.server,'lastAddr','127.0.0.1')
		if addr in self.allowed_addresses:
			print "Accepted public petition from: %s" % addr
			client = TCPClient(
					self.remote_server, 
					port=self.remote_port
				)
			protocol = _ProtocolForwarder()
			self.link((protocol, "fromsocket"), (client,   "inbox"))
			self.link((client,   "outbox"),     (protocol, "tosocket"))
			self.link((client,   "signal"),     (protocol, "control"))

			client.activate()
			return protocol
		else:
			print "Rejected public petition from: %s" % addr
			return _NotAuthorizedProtocol()
Esempio n. 9
0
def WebcamEventServerClients(rhost, rport, webcamBackplane="WEBCAM"):
    # plug a TCPClient into the backplane

    return Graphline(
        NETWORK=TCPClient(host=rhost, port=rport),
        APPCOMMS=clientconnectorwc(webcamBackplane=webcamBackplane),
        linkages={
            ("APPCOMMS", "outbox"): ("NETWORK", "inbox"),  # Continuous out
            ("NETWORK", "outbox"): ("APPCOMMS", "inbox"),  # Continuous in
        })
Esempio n. 10
0
 def __init__(self, host, portnumber, delay = 0, workers = 5, debug = 1):
     JsonRPCBase.__init__(self, workers = workers, debug = debug)
     self.host = host
     self.portnumber = portnumber
     self.delay = delay
     self.client = Graphline(
         TCPCLIENT = TCPClient(self.host, self.portnumber, self.delay),
         PROTOCOL = self.jsonprotocol(),
         linkages = { ('TCPCLIENT', 'outbox') : ('PROTOCOL', 'inbox'),
                      ('PROTOCOL', 'outbox') : ('TCPCLIENT', 'inbox'),                          
                      ('TCPCLIENT', 'signal') : ('PROTOCOL', 'control'),
                      ('PROTOCOL', 'signal') : ('TCPCLIENT', 'control'), 
                     } )
     self.handle = Handle(self.client)
Esempio n. 11
0
    def main(self):
        import random
        port = self.port

        host = self.host

        #      client = TCPClient(host,port)
        #      clientProtocol = self.IRC_Handler(self.nick, self.nickinfo, self.defaultChannel)

        subsystem = Graphline(SELF=self,
                              CLIENT=TCPClient(host, port),
                              PROTO=self.IRC_Handler(self.nick, self.nickinfo,
                                                     self.defaultChannel),
                              linkages={
                                  ("CLIENT", ""): ("CLIENT", ""),
                                  ("CLIENT", ""): ("PROTO", ""),
                                  ("PROTO", ""): ("CLIENT", ""),
                                  ("PROTO", ""): ("PROTO", ""),
                                  ("CLIENT", "outbox"): ("PROTO", "inbox"),
                                  ("PROTO", "outbox"): ("CLIENT", "inbox"),
                                  ("PROTO", "heard"): ("SELF", "outbox"),
                                  ("SELF", "inbox"): ("PROTO", "talk"),
                                  ("SELF", "topic"): ("PROTO", "topic"),
                                  ("SELF", "control"): ("PROTO", "control"),
                                  ("PROTO", "signal"): ("CLIENT", "control"),
                                  ("CLIENT", "signal"): ("SELF", "signal"),
                              })

        #      self.link((client,"outbox"), (clientProtocol,"inbox"))
        #      self.link((clientProtocol,"outbox"), (client,"inbox"))
        #
        #      self.link((clientProtocol, "heard"), (self, "outbox"), passthrough=2)
        #      self.link((self, "inbox"), (clientProtocol, "talk"), passthrough=1)
        #      self.link((self, "topic"), (clientProtocol, "topic"), passthrough=1)
        #
        #      self.link((self, "control"), (clientProtocol, "control"), passthrough=1)
        #      self.link((clientProtocol, "signal"), (client, "control"))
        #      self.link((client, "signal"), (self, "signal"), passthrough=2)
        #
        self.addChildren(subsystem)
        yield _Axon.Ipc.newComponent(*(self.children))
        while 1:
            self.pause()
            yield 1
Esempio n. 12
0
 def clientRequest(rootip, rootport, myip, myport):
     servip, servport = rootip, rootport
     port = 0
     while port == 0:
         l = LikeFile(TCPClient(
             servip,
             servport))  # "REQUEST connecting to ", servip, servport
         l.activate()
         l.send("REQCONNECT %s:%d" % (myip, myport))
         resp_raw = l.recv()
         resp = resp_raw.split(" ")
         if resp[0] == "CONNECT":  # "Connecting to", port
             port = int(resp[1])
             ip = servip
         elif resp[
                 0] == "REQCONNECT":  #"REDIRECTED : request connecting to ", servip, servport
             servip, servport = resp[1].split(":")
             servport = int(servport)
     return servip, port  # Resulting server ip/port we can connect to
Esempio n. 13
0
def SimpleIRCClientPrefab(host='irc.freenode.net', port=6667):
    """\
    SimpleIRCClientPrefab(...) -> IRC_Client connected to tcp via a Graphline.
    Routes its "inbox" to IRC_Client's "talk" and IRC_Client's "heard" to
    "outbox"

    Keyword arguments:
    - host -- the server to connect to. Default irc.freenode.net
    - port -- the port to connect on. Default 6667.
    """
    client = Graphline(irc=IRC_Client(),
                       tcp=TCPClient(host, port),
                       linkages={
                           ("self", "inbox"): ("irc", "talk"),
                           ("irc", "outbox"): ("tcp", "inbox"),
                           ("tcp", "outbox"): ("irc", "inbox"),
                           ("irc", "heard"): ("self", "outbox"),
                       })
    return client
Esempio n. 14
0
def OSCARClient(server, port):
    """\
    OSCARClient(server, port) -> returns an OSCARProtocol component connected to
    a TCPClient.

    User input goes into OSCARClient's "inbox" in the form (channel, flap body)
    and useable output comes out of "outbox" in the same form. 
    """
    return Graphline(oscar=OSCARProtocol(),
                     tcp=TCPClient(server, port),
                     linkages={
                         ("oscar", "outbox"): ("tcp", "inbox"),
                         ("tcp", "outbox"): ("oscar", "inbox"),
                         ("oscar", "signal"): ("tcp", "control"),
                         ("self", "inbox"): ("oscar", "talk"),
                         ("oscar", "heard"): ("self", "outbox"),
                         ("self", "control"): ("oscar", "control"),
                         ("tcp", "signal"): ("self", "signal"),
                     })
Esempio n. 15
0
def ComplexIRCClientPrefab(host="127.0.0.1",
                           port=6667,
                           nick="kamaeliabot",
                           nickinfo="Kamaelia",
                           defaultChannel="#kamaeliatest",
                           IRC_Handler=IRC_Client):
    return Graphline(
        CLIENT=TCPClient(host, port),
        PROTO=IRC_Handler(nick, nickinfo, defaultChannel),
        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")
        })
Esempio n. 16
0
def SimpleIRCClientPrefab(host="127.0.0.1",
                          port=6667,
                          nick="kamaeliabot",
                          nickinfo="Kamaelia",
                          defaultChannel="#kamaeliatest",
                          IRC_Handler=IRC_Client,
                          Input_Handler=InputFormatter):
    return Graphline(
        CLIENT=TCPClient(host, port),
        PROTO=IRC_Handler(nick, nickinfo, defaultChannel),
        FORMAT=PureTransformer(Input_Handler),
        linkages={
            ("CLIENT", "outbox"): ("PROTO", "inbox"),
            ("PROTO", "outbox"): ("CLIENT", "inbox"),
            ("PROTO", "heard"):
            ("SELF",
             "outbox"),  #SELF refers to the Graphline. Passthrough linkage
            ("SELF", "inbox"): ("FORMAT", "inbox"),  #passthrough
            ("FORMAT", "outbox"): ("PROTO", "talk"),
            ("SELF", "control"): ("PROTO", "control"),  #passthrough
            ("PROTO", "signal"): ("CLIENT", "control"),
            ("CLIENT", "signal"): ("SELF", "signal"),  #passthrough
        })
Esempio n. 17
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"),
Esempio n. 18
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)
#!/usr/bin/python
# -*- coding: utf-8 -*-

from Kamaelia.Chassis.Pipeline import Pipeline
from Kamaelia.Util.Console import *

# ------- START OF CODE FRAGMENT NEEDED TO CONNECT TO INTROSPECTOR ----
# Remember to start Kamaelia/Tools/AxonVisualiser before doing this.
# cd Kamaelia/Tools
# ./AxonVisualiser.py --port=1600
from Kamaelia.Util.Introspector import Introspector
from Kamaelia.Internet.TCPClient import TCPClient

Pipeline(
    Introspector(),
    TCPClient("127.0.0.1", 1600),
).activate()
# ------- END OF CODE FRAGMENT NEEDED TO CONNECT TO INTROSPECTOR ----

Pipeline(
    ConsoleReader(),
    ConsoleEchoer(),
).run()

Esempio n. 20
0
                    elif splitline[0] == "NICK":
                        msg = string.join(splitline[1:], " ")[1:]
                        msg = ( "NICK", linesender, splitline[1], msg )
                        self.send(msg, "heard")

                    elif splitline[0] > '000' and splitline[0] < '300 
            else:
                self.pause()

from Kamaelia.Chassis.Pipeline import Pipeline
from Kamaelia.Chassis.Graphline import Graphline
from Kamaelia.Util.Console import ConsoleReader, ConsoleEchoer
host = 'irc.freenode.net'
port = 6667
nick = 'ryans_irc_client'
pwd = ''
user = '******'

if __name__ == '__main__':
    Graphline(irc = IRCClient(host, port, nick, pwd, user),
              tcp = TCPClient(host, port),
              out = ConsoleEchoer(),
              linkages = {
                  ("irc", "outbox") : ("tcp", "inbox"),
                  ("irc", "signal") : ("tcp", "control"),
                  ("tcp", "outbox") : ("irc", "inbox"),
                  ("tcp", "signal") : ("irc", "control"),
                  ("irc", "heard") : ("out", "inbox")
                  }
              ).run()
Esempio n. 21
0
# This is a quick example of using kamaelia as a general tcp client in your system.


host = "irc.freenode.net"
port = 6667

import Axon.background
import Axon.Handle
import time
import Queue
from Kamaelia.Util.Console import ConsoleEchoer
from Kamaelia.Internet.TCPClient import TCPClient
Axon.background.background().start()

print "what channel on freenode?"
channel = raw_input(">>> ") # this is to prevent spammage of the default settings.

client = Axon.Handle.Handle(TCPClient(host = host, port = port)).activate()
time.sleep(1)
client.put("user likefile likefile likefile :likefile\n","inbox")
client.put("nick likefile\n","inbox")
client.put("JOIN %s\n" % channel, "inbox")
while True:
    try:
        print client.get("outbox")
    except Queue.Empty:
        time.sleep(0.1)



# 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.
# -------------------------------------------------------------------------
#
# Simple test harness for integrating TCP clients and servers in one system, sharing selector components etc.
#
#

import random
from Kamaelia.Protocol.FortuneCookieProtocol import FortuneCookieProtocol
from Kamaelia.Chassis.ConnectedServer import SimpleServer
from Kamaelia.Internet.TCPClient import TCPClient
from Kamaelia.Util.Console import ConsoleEchoer
from Kamaelia.Chassis.Pipeline import Pipeline

from Kamaelia.Util.Introspector import Introspector

# Start the introspector and connect to a local visualiser
Pipeline(
    Introspector(),
    TCPClient("127.0.0.1", 1500),
).activate()

clientServerTestPort = random.randint(1501, 1599)

SimpleServer(protocol=FortuneCookieProtocol,
             port=clientServerTestPort).activate()

Pipeline(TCPClient("127.0.0.1", clientServerTestPort), ConsoleEchoer()).run()
Esempio n. 23
0
# 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.

# a slightly more complicated example of a TCP client, where we define an echo.

from Kamaelia.Chassis.ConnectedServer import SimpleServer
from Kamaelia.Protocol.EchoProtocol import EchoProtocol
from Kamaelia.Internet.TCPClient import TCPClient
from Axon.likefile import LikeFile, schedulerThread
import time

schedulerThread(slowmo=0.01).start()

PORT = 1900
# This starts an echo server in the background.
SimpleServer(protocol=EchoProtocol, port=PORT).activate()

# give the component time to commence listening on a port.
time.sleep(0.5)

echoClient = LikeFile(TCPClient(host="localhost", port=PORT))
while True:
    echoClient.put(raw_input(">>> "))
    print echoClient.get()
Esempio n. 24
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()
Esempio n. 25
0
# 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()

Esempio n. 26
0
if __name__ == '__main__':
    import sys

    raw_config = get_config_lines()
    C = parse_config(raw_config)
#    print config
#    C = default_config
    channel = "#kamaelia-test"
    Name = "kamaeliabot"
    pwd = None
    logdir = "."

    if len(sys.argv) > 1: channel = sys.argv[1]
    if len(sys.argv) > 2: Name = sys.argv[2]
    if len(sys.argv) > 3: pwd = sys.argv[3]

    from Kamaelia.Internet.TCPClient import TCPClient
    from Kamaelia.Util.Introspector import Introspector
    from Kamaelia.Chassis.Pipeline import Pipeline
    Pipeline( Introspector(), TCPClient("127.0.0.1",1501) ).activate()
    print "Logging %s as %s" % (C["channel"], C["name"],)
    Logger(C["channel"],
           name=C["name"],
	   host=C["host"],
           password=C["pwd"],
           logdir=C["logdir"],
           formatter=(lambda data: Kamaelia.Apps.IRCLogger.Support.HTMLOutformat(data)),
           filewriter = Kamaelia.Apps.IRCLogger.Support.LoggerWriter,
           ).run()
Esempio n. 27
0
            'lynx -dump -source >phrases.txt http://thwackety.com/phrases.txt'
        ).run()
        print "Got it!"

    f = open("phrases.txt")
    phrases = [line.strip() for line in f]
    f.close()
    pprint.pprint(phrases)
    username = sys.argv[1]
    password = sys.argv[2]
    server = sys.argv[3]
    port = int(sys.argv[4])
    print "username ="******"password ="******"server =", server
    print "port =", repr(port)

    if 1:
        Graphline(RAWCLIENT=basicPop3Client(username=username,
                                            password=password),
                  CLIENT=Pop3Client(phrases=phrases),
                  SERVER=TCPClient(server, port),
                  linkages={
                      ("CLIENT", "outbox"): ("RAWCLIENT", "client_inbox"),
                      ("RAWCLIENT", "client_outbox"): ("CLIENT", "inbox"),
                      ("RAWCLIENT", "outbox"): ("SERVER", "inbox"),
                      ("SERVER", "outbox"): ("RAWCLIENT", "inbox"),
                      ("RAWCLIENT", "signal"): ("SERVER", "control"),
                      ("SERVER", "signal"): ("RAWCLIENT", "control"),
                  }).run()
Esempio n. 28
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)
Esempio n. 29
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()
Esempio n. 30
0
#

from Kamaelia.Chassis.Pipeline import Pipeline
from Kamaelia.Chassis.ConnectedServer import SimpleServer
from Kamaelia.Internet.TCPClient import TCPClient
from Kamaelia.Codec.Vorbis import VorbisDecode, AOAudioPlaybackAdaptor
import Kamaelia.File.ReadFileAdaptor
import random

file_to_stream = "../SupportingMediaFiles/KDE_Startup_2.ogg"
clientServerTestPort = random.randint(1500, 2000)

print "Client Server demo running on port", clientServerTestPort


def AdHocFileProtocolHandler(filename):
    class klass(Kamaelia.File.ReadFileAdaptor.ReadFileAdaptor):
        def __init__(self, *argv, **argd):
            super(klass, self).__init__(filename,
                                        readmode="bitrate",
                                        bitrate=128000)

    return klass


server = SimpleServer(protocol=AdHocFileProtocolHandler(file_to_stream),
                      port=clientServerTestPort).activate()

Pipeline(TCPClient("127.0.0.1", clientServerTestPort), VorbisDecode(),
         AOAudioPlaybackAdaptor()).run()