コード例 #1
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.
# -------------------------------------------------------------------------
#
# 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()
コード例 #2
0
ファイル: KamaeliaLogger.py プロジェクト: thangduong/kamaelia
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()
コード例 #3
0
    from Axon.Scheduler import scheduler as _scheduler

    import sys
    dictArgs, optlist, remargs = parseArgs(sys.argv[1:])

    if "help" in dictArgs:
        print dictArgs["help"]
        
    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)
コード例 #4
0
    if "help" in dictArgs:
        print(dictArgs["help"])
        sys.exit(0)

    resolution = dictArgs.get("screensize", (800, 600))
    doNavelgaze = dictArgs.pop("navelgaze", None)
    doIntrospect = dictArgs.pop("introspect", None)

    pgd = PygameDisplay(width=resolution[0], height=resolution[1]).activate()
    PygameDisplay.setDisplayService(pgd)

    if doIntrospect is not None:
        (server, port) = doIntrospect

        Pipeline(Introspector(), TCPClient(server, port)).activate()

    if doNavelgaze:
        if "serverPort" in dictArgs:
            raise ValueError(
                "Makes no sense to navelgaze and use --port option - they're mutually exclusive"
            )
        app = Pipeline(
            Introspector(), ConsoleEchoer(forwarder=True),
            text_to_token_lists(),
            AxonVisualiser(caption="Axon / Kamaelia Visualiser", **dictArgs))
    else:
        app = AxonVisualiserServer(caption="Axon / Kamaelia Visualiser",
                                   **dictArgs)

    app.run()