At first glance, this looks incredibly handy. It definitely makes 
interactive demos much easier.
Thanks for this!
I am still, however, stuck on the last series of messages regardin 
interprocess communication. It wasn't clear to me if you would support 
the Python 2.6 processing module, or if your interprocess communication 
is DIY.
Can you please point me to some more recent examples of IPC in Kamaelia? 
This is the most common question asked of me when I speak about Kamaelia 
publicly.
Thanks once again!
Gloria
> Hi,
>
>
> I've written a simple python interpreter component. 
>
> Currently sits here: Kamaelia.Experimental.PythonInterpreter
>
> This allows a variety of things, from a basic command line console:
>
>    * StandaloneInterpreter().run()
>
> Which you can run in the background on any console. For example you could do 
> this:
>
>     ServerCore(protocol=myprotocol, port=1234).activate()
>     StandaloneInterpreter().run()
>
> Alternatively, you can use an embeddable component that speaks to 
> inbox/outbox 
> rather than stdin/stdout. Crudely you can do something like this:
>
>     Pipeline(
>         ConsoleReader(),
>         InterpreterTransformer(),
>         ConsoleEchoer(),
>     ).run()
>
> But you can also put it inside a pygame application, reading & writing from a 
> Textbox/TextDisplayer:
>
>     Pipeline(
>         Textbox(size = (800, 300), position = (100,380)),
>         InterpreterTransformer(),
>         TextDisplayer(size = (800, 300), position = (100,40)),
>     ).run()
>
> The interesting option this opens up of course is the fact that you can add 
> in 
> a networked interpreter (which is hideously insecure incidentally - so only 
> safe of a network you completely control!) into any application:
>
>     from Kamaelia.Chassis.Pipeline import Pipeline
>     from Kamaelia.Chassis.ConnectedServer import ServerCore
>     from Kamaelia.Util.PureTransformer import PureTransformer
>     
>     from Kamaelia.Experimental.PythonInterpreter import InterpreterTransformer
>     
>     def NetInterpreter(*args, **argv):
>         return Pipeline(
>                     PureTransformer(lambda x: str(x).rstrip()),
>                     InterpreterTransformer(),
>                     PureTransformer(lambda x: str(x)+"\r\n>>> "),
>                )
>     
>     ServerCore(protocol=NetInterpreter, port=1236).run()
>
> In one console:
>     # ./ServerBasedPythonInterpreter.py
>
> In another:
>     ~> telnet 127.0.0.1 1236
>     Trying 127.0.0.1...
>     Connected to 127.0.0.1.
>     Escape character is '^]'.
>     
>     >>> self
>     Component 
> Kamaelia.Experimental.PythonInterpreter.InterpreterTransformer_21 [ inboxes : 
> {'control': [], 'inbox': []} outboxes : {'outbox': [], 'signal': []}
>     >>> "hello world"
>     hello world
>     >>> Axon
>     <module 'Axon' 
> from '/usr/local/lib/python2.5/site-packages/Axon/__init__.pyc'>
>     >>> dir(self)
>     ['Inbox', 'Inboxes', 'Outboxes', 'Usescomponents', '_AxonObject_...
>     >>> self.scheduler
>     Axon.Scheduler.scheduler_1 :1 :1 :0 :
>     >>> self.scheduler.threads
> {<Kamaelia.Internet.TCPServer.TCPServer object at 0xb7b972cc>: <object object 
> at 0xb7c92468>, 
> <Kamaelia.Internet.ConnectedSocketAdapter.ConnectedSocketAdapter object at 
> 0xb7ba4acc>: <object object at 0xb7c92468>, 
> <Kamaelia.Experimental.PythonInterpreter.InterpreterTransformer object at 
> 0xb7ba6bec>: <object object at 0xb7c92468>, 
> <Kamaelia.Chassis.Pipeline.Pipeline object at 0xb7bafc2c>: <object object at 
> 0xb7c92468>, <Kamaelia.Experimental.PythonInterpreter.InterpreterTransformer 
> object at 0xb7b9dc4c>: <object object at 0xb7c92468>, 
> <Kamaelia.Util.PureTransformer.PureTransformer object at 0xb7baf86c>: <object 
> object at 0xb7c92460>, <Kamaelia.Chassis.ConnectedServer.ServerCore object at 
> 0xb7b8acec>: <object object at 0xb7c92468>, 
> <Kamaelia.Chassis.Pipeline.Pipeline object at 0xb7ba1d0c>: <object object at 
> 0xb7c92468>, <Kamaelia.Util.PureTransformer.PureTransformer object at 
> 0xb7ba192c>: <object object at 0xb7c92468>, 
> <Kamaelia.Util.PureTransformer.PureTransformer object at 0xb7b9d96c>: <object 
> object at 0xb7c92468>, <Kamaelia.Internet.Selector.Selector object at 
> 0xb7b979cc>: <object object at 0xb7c92468>}
>
> etc.
>
> The idea behind this component really is to assist in debugging live running 
> systems by directly rummaging around inside them, which is why this form is 
> probably most useful:
>
>     if interactive_debug:
>         StandaloneInterpreter().activate()
>     
>     MyMainApplication().run()
>
> And whilst the other forms naturally drop out as useful, this form is 
> probably 
> the safest of the bunch!
>
> This form also is slightly more flexible, in that it allows this sort of 
> thing:
>
>     ~/> ./BasicPythonInterpreter.py
>     > from Kamaelia.UI.Pygame.Ticker import Ticker
>
>     ok
>     > X=Ticker()
>
>     ok
>     Component Kamaelia.UI.Pygame.Ticker.Ticker_7 [ inboxes : {'control': 
> [], '_displaycontrol': [], 'unpausebox': [], 'pausebox': [], 'inbox': 
> [], 'alphacontrol': []} outboxes : {'outbox': <>, 'signal': 
> <>, '_displaysignal': <>}
>   
>> X.activate()
>>     
>
>     ok
>     Component Kamaelia.UI.Pygame.Ticker.Ticker_7 [ inboxes : {'control': 
> [], '_displaycontrol': [], 'unpausebox': [], 'pausebox': [], 'inbox': 
> [''], 'alphacontrol': []} outboxes : {'outbox': <>, 'signal': 
> <>, '_displaysignal': <>}
>   
>> self.link((self, "outbox"), (X,"inbox"))
>>     
>
>     ok
>     Link( source:
> [Kamaelia.Experimental.PythonInterpreter.StandaloneInterpreter_5,outbox], 
> sink:[Kamaelia.UI.Pygame.Ticker.Ticker_7,inbox] )
>   
>> self.send("Hello", "outbox")
>>     
>
>     ok
>
> As you can guess this then results the text displayer outputting to the 
> display. For example, if you're rummaging inside a system, you could start up 
> an introspector in another console:
>
>    ./AxonVisualiser.py --port 1500
>
> And then in the enbedded interpreter do this:
>   
>> from Kamaelia.Util.Introspector import Introspector
>>     
>
> ok
>   
>> from Kamaelia.Chassis.Pipeline import Pipeline
>>     
>
> ok
>   
>> from Kamaelia.Internet.TCPClient import TCPClient
>>     
>
> ok
>   
>> Pipeline(
>>     
>     Introspector(),
>     TCPClient("127.0.0.1", 1500),
> ).activate()
>   
> ok
>
> And as you might expect, though I think it's really cool :-) , you have added 
> an Axon visualisation/introspector to a _running_ system - which looks like 
> this:
>
> http://www.kamaelia.org/images/IntrospectingKamaeliaSystemWithInterpreter.png
>
> Hope others find it useful too :-)
>
> Regards,
>
>
> Michael.
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"kamaelia" group.
To post to this group, send email to kamaelia@googlegroups.com
To unsubscribe from this group, send email to 
kamaelia+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/kamaelia?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to