Hi Eduardo,

I’ve got nothing in the pre-packaged arena to recommend, but if your
looking to roll your own system, read on.


   - accepts data and that you could retrieve it later in block.

 Before having a server that can accept data, have you considered how to
transmit your data? For instance, if you’re looking at rolling your own
system, then one of the pattern you could use is called PUB/SUB, for
publish/subscribe. I.e. your methods/functions publishes data and then
something is out there listening. Also called producer and consumer.

Once the consumer has collected data, say in a mongodb database or in a
simple text file, you can provide access to this datastore via a web
interface, command-line or pyqt gui. Depending on your use, it may be
helpful to think of keeping the production and consumption of your data
separate; the opposite being finding a pre-packaged web-server and
designing your messages for it specifically.

If separate, say in a text-file, retrieving the data is a mere open(path,
'r'), this is then equally applicable to both your web-server, and tools.

The production of message could look something like this:

 ___________
|           |
|   start   |--> publish "A: starting MyTool"
|___________|
      |
 _____v_____
|           |
|   meth1   |--> publish "A: running MyCommand"
|___________|
      |
 _____v_____
|           |
|   meth2   |--> publish "A: wrapping up MyTool"
|___________|

Each message potentially transmitting dates and user and machine stats etc.
You’d then have a consumer, listening for anything tagged “A”.

       __________
      |          |
("A"--|  listen  |
      |__________|

The important thing to note being that producing messages is a non-blocking
operation and that there mustn’t be a consumer/listener at the other end;
that is optional.

give response to calls with simple arguments

For this, there is the REQ/REP pattern, for request/reply, in which you
could either send a message, synchonously, and await an arbitrary response:

>>> unpacked_message = {'status': 'ok', 'command': 'givz_cat'}>>> 
>>> packed_message = json.dumps(unpacked_message)>>> 
>>> socket.send(packed_message)>>> packed_reply = socket.recv()# Blocks here>>> 
>>> unpacked_reply = json.loads(packed_reply)>>> process(reply)

Or you could go for something like the RPC pattern which mimics calling
upon procedures as though they were local:

>>> reply = myobj.givz_cat()>>> process(reply)

Each perform similar tasks (i.e. the bundling and serialising of commands)
whereas an RPC masks it under a familiar, higher-level interface.

And finally, to make any of this possible, you can either roll your own
low-level messaging mechanism, which in the case of REQ/REP isn’t that big
of a deal (with e.g. socket module) depending on your aspirations, but for
PUB/SUB would make life slightly more difficult. For this or both, I would
suggest a MOM <http://en.wikipedia.org/wiki/Message-oriented_middleware>,
or Message-Oriented Middleware, such as ZeroMQ <http://zeromq.org/>.
Whichever you choose, there are tutorials and use-cases in the ZeroMQ
guide<http://zguide.zeromq.org/py:all#Messaging-Patterns>
.

Hope it helps.

Best,
Marcus
​

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBC0NrHqYbkNDm%2BDHTnxeYtRUpafv70tKqT9ZSqqgrDOA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to