def run():
    options = parse_commandline()

    from bucker.provider.memcached import MemcachedQueue
    servers = options.servers.split(',')
    ip, port = options.id_generator.split(':')
    queue = MemcachedQueue(servers=servers, queue_list_name=options.queue,
                           id_gen_address=(ip, int(port)))

    logger = None
    if options.logger_path:
        from bucker.lib.logger import Logger
        logger = Logger(options.logger_path, False)
        queue.set_logger(logger)

    MemcachedQueue.setService(queue)
    queue.activate()

    from bucker.provider.memcached import MemcachedQueueProtocol
    from Kamaelia.Chassis.ConnectedServer import SimpleServer

    def make_protocol():
        mqp = MemcachedQueueProtocol()
        if logger:
            mqp.set_logger(logger)
        return mqp

    s = SimpleServer(protocol=make_protocol, port=9876)
    s.run()
Ejemplo n.º 2
0
 def main(self):
     #Create something to listen for a connection
     #Create something to give you files
     #Bolt them together
     #Go!
     server = SimpleServer(protocol=self.localFileServerFactory, port=8042)
     server.activate()
     scheduler.run.runThreads()
Ejemplo n.º 3
0
 def main(self):
     #Create something to listen for a connection
     #Create something to give you files
     #Bolt them together
     #Go!
     server = SimpleServer( protocol = self.localFileServerFactory, port = 8042)
     server.activate()
     scheduler.run.runThreads()
Ejemplo n.º 4
0
def run():
    from bucker.lib.midgen import MessageIdService, MessageIdProtocol
    service, shutdownservice, serv = MessageIdService.getService()
    serv.activate()
    
    def make_protocol():
        return MessageIdProtocol()

    from Kamaelia.Chassis.ConnectedServer import SimpleServer
    s = SimpleServer(protocol=make_protocol, port=9877)
    s.run()
Ejemplo n.º 5
0
 def __init__(self):
    super(testHarness,self).__init__()
    self.serverport = 4444
    self.server = SimpleServer(protocol=FortuneCookieProtocol, port=self.serverport)
    self.client = None
    self.display = ConsoleEchoer()
    self.displayerr = ConsoleEchoer()
Ejemplo n.º 6
0
def LocalEventServer(whiteboardBackplane="WHITEBOARD",
                     audioBackplane="AUDIO",
                     port=1500):
    def configuredClientConnector():
        return clientconnector(whiteboardBackplane=whiteboardBackplane,
                               audioBackplane=audioBackplane,
                               port=port)

    return SimpleServer(protocol=clientconnector, port=port)
Ejemplo n.º 7
0
def LocalEventServer(whiteboardBackplane="WHITEBOARD",
                     audioBackplane="AUDIO",
                     port=1500):
    from Kamaelia.Chassis.ConnectedServer import SimpleServer
    from Kamaelia.Util.Console import ConsoleEchoer

    def clientconnector():
        return Pipeline(
            chunks_to_lines(),
            lines_to_tokenlists(),
            Graphline(
                WHITEBOARD=FilterAndTagWrapper(
                    Pipeline(
                        publishTo(whiteboardBackplane),
                        # well, should be to separate pipelines, this is lazier!
                        subscribeTo(whiteboardBackplane),
                    )),
                AUDIO=Pipeline(
                    SimpleDetupler(1),  # remove 'SOUND' tag
                    SpeexDecode(3),
                    FilterAndTagWrapperKeepingTag(
                        Pipeline(
                            publishTo(audioBackplane),
                            # well, should be to separate pipelines, this is lazier!
                            subscribeTo(audioBackplane),
                        ), ),
                    RawAudioMixer(),
                    SpeexEncode(3),
                    Entuple(prefix=["SOUND"], postfix=[]),
                ),
                ROUTER=Router(
                    ((lambda tuple: tuple[0] == "SOUND"), "audio"),
                    ((lambda tuple: tuple[0] != "SOUND"), "whiteboard"),
                ),
                linkages={
                    # incoming messages go to a router
                    ("", "inbox"): ("ROUTER", "inbox"),

                    # distribute messages to appropriate destinations
                    ("ROUTER", "audio"): ("AUDIO", "inbox"),
                    ("ROUTER", "whiteboard"): ("WHITEBOARD", "inbox"),

                    # aggregate all output
                    ("AUDIO", "outbox"): ("", "outbox"),
                    ("WHITEBOARD", "outbox"): ("", "outbox"),

                    # shutdown routing, not sure if this will actually work, but hey!
                    ("", "control"): ("ROUTER", "control"),
                    ("ROUTER", "signal"): ("AUDIO", "control"),
                    ("AUDIO", "signal"): ("WHITEBOARD", "control"),
                    ("WHITEBOARD", "signal"): ("", "signal")
                },
            ),
            tokenlists_to_lines(),
        )

    return SimpleServer(protocol=clientconnector, port=port)
Ejemplo n.º 8
0
 def __init__(self):
     super(testHarness, self).__init__(
     )  # I wonder if this can get forced to be called automagically?
     import random
     self.serverport = random.randint(4000, 8000)
     self.server = SimpleServer(protocol=FortuneCookieProtocol,
                                port=self.serverport)
     self.client = None
     self.display = ConsoleEchoer()
Ejemplo n.º 9
0
def run():
    options = parse_commandline()
    from Kamaelia.Chassis.ConnectedServer import SimpleServer

    from bucker.lib.logger import Logger

    logger = None
    if options.logger_path:
        from bucker.lib.logger import Logger

        logger = Logger(options.logger_path, True)

    from bucker.api.bus import MessageManagerServer, MessageManagerProtocol

    ip, port = options.server.split(":")
    mgr = MessageManagerServer(qs_host=ip, qs_port=int(port))
    if logger:
        mgr.set_logger(logger)
    MessageManagerServer.setService(mgr)
    mgr.activate()

    m = SimpleServer(protocol=MessageManagerProtocol, port=9875)
    m.run()
Ejemplo n.º 10
0
def run():
    options = parse_commandline()

    from bucker.lib.logger import Logger
    logger = None
    if options.logger_path:
        from bucker.lib.logger import Logger
        logger = Logger(options.logger_path, True)

    from Kamaelia.Chassis.ConnectedServer import SimpleServer

    from bucker.api.bus import ServiceBusServer, ServiceBusProtocol
    ip, port = options.server.split(':')
    queues = [unicode(q) for q in options.queues.split(',')]
    server = ServiceBusServer(queues=queues, host=ip, port=int(port),
                              manager_host='127.0.0.1', manager_port=9875)
    if logger:
        server.set_logger(logger)
    ServiceBusServer.setService(server)
    server.activate()

    s = SimpleServer(protocol=ServiceBusProtocol, port=9888)
    s.run()
Ejemplo n.º 11
0
def LocalEventServer(backplane="WHITEBOARD", port=1500):
    from Kamaelia.Chassis.ConnectedServer import SimpleServer
    from Kamaelia.Util.Console import ConsoleEchoer

    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(),
        )

    return SimpleServer(protocol=clientconnector, port=serveport)
Ejemplo n.º 12
0
#     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.
# -------------------------------------------------------------------------
"""\
========================
HTTP Server
========================
The fundamental parts of a webserver - an HTTP request parser and a request
handler/response generator. One instance of this component can handle one
TCP connection. Use a SimpleServer or similar component to allow several
concurrent HTTP connections to the server.

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

SimpleServer(protocol=lambda : HTTPServer(
             HTTPResourceGlue.createRequestHandler, port=80).run()

"lambda : HTTPServer(HTTPResourceGlue.createRequestHandler)" is the
Ejemplo n.º 13
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()
Ejemplo n.º 14
0
    def initialiseComponent(self):
        """\
      Initialises component. Sets up a ReadFileAdapter to read in the contents
      of an audio file at 95.2kbit/s and wires it to fire the contents out
      """
        myDataSource = ReadFileAdaptor(command="./afortune.pl",
                                       readmode="bitrate",
                                       bitrate=95200,
                                       chunkrate=25)
        assert self.debugger.note(
            "AudioCookieProtocol.initialiseComponent", 1,
            "Initialising AudioCookieProtocol protocol handler ", self.name)
        self.link(source=(myDataSource, "outbox"),
                  sink=(self, "outbox"),
                  passthrough=2)
        self.addChildren(myDataSource)

        return newComponent(myDataSource)

    def mainBody(self):
        """Main body - sits and waits, as ReadFileAdapter is getting on with the work for us"""
        return 1


__kamaelia_components__ = (AudioCookieProtocol, )

if __name__ == '__main__':
    from Kamaelia.Chassis.ConnectedServer import SimpleServer

    SimpleServer(protocol=AudioCookieProtocol, port=1500).run()
Ejemplo n.º 15
0
If any message is received on its "control" inbox, the component passes the message
onto its "signal" outbox and terminates.
"""

from Axon.Component import component


class EchoProtocol(component):
    """\
   EchoProtocol() -> new EchoProtocol component

   Simple component that copies anything sent to its "inbox" inbox to its "outbox"
   outbox.
   """
    def main(self):
        while not self.dataReady("control"):
            for message in self.Inbox("inbox"):
                self.send(message, "outbox")
            if not self.anyReady():
                self.pause()
            yield 1
        self.send(self.recv("control"), "signal")


__kamaelia_components__ = (EchoProtocol, )

if __name__ == '__main__':
    from Kamaelia.Chassis.ConnectedServer import SimpleServer

    SimpleServer(protocol=EchoProtocol, port=1501).run()
Ejemplo n.º 16
0
        self.addChildren(myDataSource)
        assert self.debugger.note("FortuneCookieProtocol.main", 1, self.name,
                                  "Added Child", myDataSource)
        return newComponent(myDataSource)

    def mainBody(self):
        """\
      Main body.

      All the interesting work has been done by linking the file reader's output
      to our output.  Messages sent to control are unchecked and the first
      message causes the component to exit.
      """
        self.pause()
        while self.dataReady("control"):
            data = self.recv("control")
            self.send(data, "signal")
            return 0
        assert self.debugger.note("FortuneCookieProtocol.main", 10, self.name,
                                  "Main Loop")
        return 1


__kamaelia_components__ = (FortuneCookieProtocol, )

if __name__ == '__main__':
    from Kamaelia.Chassis.ConnectedServer import SimpleServer

    SimpleServer(protocol=FortuneCookieProtocol, port=1500).run()
Ejemplo n.º 17
0
		return newComponent( myDataSource )

	def handleDataIn(self):
		if self.dataReady("datain"):
			data = self.recv("datain")
			if self.debug:
				sys.stdout.write(data)
			self.send(data,"outbox")
		return 1

	def handleInbox(self):
		if self.dataReady("inbox"):
			data = self.recv("inbox")
			self.send(data,"outbox")
		return 1

	def mainBody(self):
		self.handleDataIn()
		self.handleInbox()
		return 1

__kamaelia_components__  = ( HelloServer, )


if __name__ == '__main__':

   SimpleServer(protocol=HelloServer, port=5222).activate()
   # HelloServer(debug = 1).activate()
   scheduler.run.runThreads(slowmo=0)
Ejemplo n.º 18
0
                self.disconnectResourceHandler()
                self.debug("sendEnd")
                if lengthMethod == "close" or connection.lower() == "close":
                    self.send(producerFinished(), "signal") #this functionality is semi-complete
                    return

            self.updateShouldShutdown()
            if self.ssCode > 0:
                return

            self.pause()

__kamaelia_components__  = ( HTTPServer, HTTPRequestHandler, )

if __name__ == '__main__':
    import socket
    
    from Kamaelia.Chassis.ConnectedServer import SimpleServer
    
    # this works out what the correct response to a request is
    from Kamaelia.Community.RJL.Kamaelia.Protocol.HTTP.HTTPResourceGlue import createRequestHandler 
    
    def createhttpserver():
        return HTTPServer(createRequestHandler)

    SimpleServer(
        protocol=createhttpserver,
        port=8082,
        socketOptions=(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    ).run()
Ejemplo n.º 19
0
    def main(self):
        while 1:
            self.send(("ballpos", self.x,self.y), "outbox")
            self.moveball()
            time.sleep(0.04)

Backplane("GameEvents").activate()
if sys.argv[1] == "server":

    def ClientProtocol():
        return Pipeline(
                    SubscribeTo("GameEvents"),
                    PureTransformer(lambda x : "|".join([str(y) for y in x])+"X")
               )

    SimpleServer(port=1601, protocol=ClientProtocol).activate()

    Pipeline(
        GameModel(),
        PublishTo("GameEvents"),
    ).activate()

else:
    B = ""
    def unmarshall(x):
        global B
        B = B+x
        if B.find("X") != -1:
            L = B[:B.find("X")]
            B = B[B.find("X")+1:]
            L = L.split("|")
Ejemplo n.º 20
0
def mkTCPClient(args):
    return TCPClient(*args)

#
#\-----------------------------------------------------------------


#/-----------------------------------------------------------------
# So we can handle requests for our control port for building
# the mesh
#
def mySwarmer():
    return SimpleSwarm(mydataport)


SimpleServer(protocol=mySwarmer, port=mycontrolport).activate()
#
#\-----------------------------------------------------------------

#/-----------------------------------------------------------------
# Mechanism to allow the audio data to be shared to all clients
#
Backplane("RADIO").activate()
#
#\-----------------------------------------------------------------

#/-----------------------------------------------------------------
# The client portion of the P2P swarm
#
Graphline(
    CONFIGURE=ConnectToSwarm(rootip, rootcontrolport, myip, mycontrolport),
Ejemplo n.º 21
0
SERVERPORT      = 1500


def MultiFileReaderProtocol(filenames, bitrate, chunksizebytes):

    def protocolFactory(*argv, **argd):
        return JoinChooserToCarousel(
            ForwardIteratingChooser(filenames),
            FixedRateControlledReusableFileReader(readmode="bytes",
                                               rate=bitrate/8,
                                               chunksize=chunksizebytes)
          )
    return protocolFactory



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

   filereader = MultiFileReaderProtocol( FILES_TO_STREAM, BITRATE, CHUNKSIZEBYTES)

   server     = SimpleServer( protocol = filereader, port = SERVERPORT ).activate()

   if 0:
        from Kamaelia.Internet.TCPClient import TCPClient
        from Kamaelia.Util.Introspector import Introspector
        pipeline(Introspector(), TCPClient("127.0.0.1",1501)).activate()
   
   scheduler.run.runThreads(slowmo=0)

Ejemplo n.º 22
0
# data port - connecting to here gets you the data. Its good form
#    to ask on the control port first if you can connect there.
#
# As a result that's why there's two SimpleServer instances.
#

import Axon

from Kamaelia.Chassis.ConnectedServer import SimpleServer
from Kamaelia.Internet.TCPClient import TCPClient

from likefile import *
background = schedulerThread().start()


class Echo(Axon.Component.component):
    def main(self):
        while 1:
            while self.dataReady("inbox"):
                self.send(self.recv("inbox"), "outbox")
            yield 1


SimpleServer(protocol=Echo, port=1600).activate()

time.sleep(1)

#
# We can then write code here to demo the use of likefile with TCPClient.
#
Ejemplo n.º 23
0
                 "Bye." 
    ]
    def main(self):
        message_from_server = None
        i = 0
        while message_from_server != "Bye.":
            yield self.waitinbox() 
            message_from_server = self.recv("inbox")
            print "MESSAGE FROM SERVER:", message_from_server

            if message_from_server != "Bye.":
               self.send(self.myscript[i], "outbox")
               i = i+1
        self.send(Axon.Ipc.producerFinished(), "signal")

SimpleServer(protocol = MyServer, port = 1500).activate()

Graphline(
    HANDLER = MyClient(),
    CONNECTION = TCPClient("127.0.0.1", 1500),
    linkages = {
        # Data from the handler to the network connection (ie to the server)
        ("HANDLER", "outbox") : ("CONNECTION", "inbox"),
        ("HANDLER", "signal") : ("CONNECTION", "control"),

        # Data from the network	 connection back to the handler (ie from the server)
        ("CONNECTION","outbox") : ("HANDLER","inbox"),
        ("CONNECTION","signal") : ("HANDLER","control"),
    }
).run()        
        
Ejemplo n.º 24
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()
Ejemplo n.º 25
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.ConnectedServer import SimpleServer
from Kamaelia.Protocol.FortuneCookieProtocol import FortuneCookieProtocol
from Axon.Ipc import shutdownMicroprocess
from Axon.Component import component
import time


class TerminatingProtocol(component):
    """runs for one second"""
    def main(self):
        lasttime = time.time()
        life = 1  #runs for 1 seconds
        while time.time() < lasttime + life:
            yield 1
            if self.dataReady():
                print self.recv()
        self.send(shutdownMicroprocess(), "signal")  #close the socket
        print "shutdownMicroprocess sent"
        yield 1


port = 50000
SimpleServer(protocol=TerminatingProtocol, port=port).run()
Ejemplo n.º 26
0
    hostname = "localhost"
    locallist = ["ronline.no-ip.info", "localhost"]
    localdict = listToDict(locallist)

    uniqueid = UniqueId().activate()
    deliveryqueueone = DeliveryQueueOne().activate()
    deliveryqueuetwo = DeliveryQueueTwo(localdict=localdict).activate()

    localdelivery = LocalDelivery(deliveryqueuedir="received",
                                  localmaildir="local").activate()
    remotedelivery = RemoteDelivery().activate()
    deliveryqueueone.link((deliveryqueueone, "outbox"),
                          (deliveryqueuetwo, "inbox"))
    deliveryqueuetwo.link((deliveryqueuetwo, "local"),
                          (localdelivery, "inbox"))
    deliveryqueuetwo.link((deliveryqueuetwo, "remote"),
                          (localdelivery, "inbox"))

    SMTPServerProtocol = lambda: SMTPServer(hostname="localhost",
                                            storagequeue=deliveryqueueone,
                                            localdict=localdict,
                                            uniqueidservice=uniqueid,
                                            funccreateinterface=
                                            DeliveryQueueOneInterface)
    SimpleServer(protocol=SMTPServerProtocol,
                 port=8025,
                 socketOptions=(socket.SOL_SOCKET, socket.SO_REUSEADDR,
                                1)).activate()
    scheduler.run.runThreads(slowmo=0)
Ejemplo n.º 27
0
FILES_TO_STREAM = [shortfile, shortfile,
                   shortfile]  # [  file_to_stream, file_to_stream2 ]
BITRATE = 800000  # 38000
CHUNKSIZEBYTES = 512
SERVERPORT = 1500


def MultiFileReaderProtocol(filenames, bitrate, chunksizebytes):
    def protocolFactory(*argv, **argd):
        return JoinChooserToCarousel(
            ForwardIteratingChooser(filenames),
            FixedRateControlledReusableFileReader(readmode="bytes",
                                                  rate=bitrate / 8,
                                                  chunksize=chunksizebytes))

    return protocolFactory


if __name__ == '__main__':

    filereader = MultiFileReaderProtocol(FILES_TO_STREAM, BITRATE,
                                         CHUNKSIZEBYTES)

    if 0:
        from Kamaelia.Internet.TCPClient import TCPClient
        from Kamaelia.Util.Introspector import Introspector
        Pipeline(Introspector(), TCPClient("127.0.0.1", 1501)).activate()

    server = SimpleServer(protocol=filereader, port=SERVERPORT).run()
# 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()
Ejemplo n.º 29
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"),
                     })


SimpleServer(protocol=Pop3Proxy, port=PROXYSERVER_PORT).run()
Ejemplo n.º 30
0
nlnl = '\n', '\n'
key = nlnl

def new_key(key, word):
   if word == '\n': return nlnl
   else: return (key[1], word)
      
class Chatty(Axon.Component.component):
   data = {}
   def updateChain(self, message):
       key = nlnl
       for word in message.split():
           self.__class__.data.setdefault(key, []).append(word)
           key = new_key(key, word)
   def response(self):
       key, result, word = nlnl, [], None
       while word != "\n":
           word = random.choice(self.__class__.data.get(key, nlnl))
           key = new_key(key, word)
           result.append(word)
       return " ".join(result)
   def main(self):
       while 1:
           if self.dataReady("inbox"):
               message = self.recv("inbox")
               self.updateChain(message)
               self.send(self.response(), "outbox")
           yield 1

SimpleServer(protocol=Chatty, port=1500).run() 
Ejemplo n.º 31
0
        self.send(footer, "outbox")
        yield 1

        # and shutdown nicely
        self.send(Axon.Ipc.producerFinished(self), "signal")
        yield 1


def EchoHandler(request):
    return Pipeline(Cat(request), ExampleWrapper())


def servePage(request):
    return Minimal(request=request,
                   homedirectory=homedirectory,
                   indexfilename=indexfilename)


def HTTPProtocol():
    return HTTPServer(
        requestHandlers([
            ["/echo", EchoHandler],
            ["/hello", HelloHandler],
            ["/", servePage],
        ]))


SimpleServer(protocol=HTTPProtocol,
             port=8082,
             socketOptions=(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)).run()
Ejemplo n.º 32
0
def LocalWebcamEventServer(webcamBackplane="WEBCAM", port=1501):
    def configuredClientConnector():
        return clientconnectorwc(webcamBackplane=webcamBackplane, port=port)

    return SimpleServer(protocol=clientconnectorwc, port=port)
Ejemplo n.º 33
0
def LocalWebcamEventServer(webcamBackplane="WEBCAM", port=1501):
    # Sets up the webcam server in a similar way to the one used for images and audio
    def configuredClientConnector():
        return clientconnectorwc(webcamBackplane=webcamBackplane, port=port)

    return SimpleServer(protocol=clientconnectorwc, port=port)