Wednesday, February 2, 2011

Line Input Struggles

Spent a while today trying to add interactive command capability to the CosmicIServer class via a StreamLineConnection tied to the STDIO streams that are redirected to the TikiTerm console. It is coded but not working yet. At the moment, I'm stuck on an error where Python is complaining that a "h.handle(msg)" method call doesn't match the "def handle(inst, msg)" method prototype in the Command_ReqHandler because the number of arguments doesn't match, but it DOES, dammit! It's baffling because those particular lines of codes aren't even new, and were working fine before, for commands sent via the MainServer connection.

Aha, I fixed that bug now (I was adding the handler CLASS instead of a handler INSTANCE to the handler list - although possibly I should change the interface so we can just supply a class instead), but now I am having a different problem, having to do with getting the code in one module to access global variables that are initialized in another module that itself uses the first module. I've always had trouble getting this sort of thing to work correctly. Oh wait, I just had an idea about how to fix it. I can dynamically add a copy of the object reference as an attribute of the second module after the object gets initialized in the first module... Hooray, it worked!!

Here's a screenshot showing the server response to an input command line. As expected, we get an error message indicating that the command is unknown. I haven't yet defined any server commands that would be particularly useful in interactive mode!


No comments:

Post a Comment