We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › xmlrpclib and python server
Page Index Toggle Pages: 1
xmlrpclib and python server (Read 771 times)
xmlrpclib and python server
Dec 20th, 2008, 1:49am
 
I made xml-rpc server on python and I use xmlrpclib in processing as client.
What processing get is python list that is processing object like this: [[0, 4, 4, 4, 4, 4, 4, 4, 5, 1, 1, 3], [0, 0, 4, 4, 4, 4, 4, 4, 5, 7, 7, 7]]
How can I work with this type of object in processing ?
How could it be transformed into array or vector?
Re: xmlrpclib and python server
Reply #1 - Dec 20th, 2008, 11:50am
 
You should avoid multiple posts... It only dilutes information and disperses answers.

You should show the code on the Processing side  and tell us what you send from the Python side, but I guess what you get is (already) a double array: param[][].
Re: xmlrpclib and python server
Reply #2 - Dec 20th, 2008, 3:22pm
 
thank you for nitifications
processing code is

Object  result = client.execute("sm_3x3",X);
print(result);
---
answer:
[[0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3], [0, 0, 0, 0, 4, 4, 4, 4, 5, 1, 3, 7], [0, 0, 0, 0, 0, 0, 4, 4, 0, 1, 1, 1], [0, 0, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6], [0, 0, 4, 4, 4, 4, 4, 4, 5, 7, 3, 3]]



if I use
Object [][] result = client.execute("sm_3x3",X);
or
int [][] result = client.execute("sm_3x3",X);
processing says "cannot convert from Object to int[][]" or "cannot convert from Object to Object[][]"

please help

Re: xmlrpclib and python server
Reply #3 - Dec 20th, 2008, 6:36pm
 
OK, I was curious to see how this XML RPC stuff works.
So I downloaded and installed the library, made two sketches with the drawing examples. It worked.
I expanded the examples as follow:
Server: Code:
public Vector update(int x, int y)
{
// Same code...

 Vector vv = new Vector();
 Vector v1 = new Vector();
 Vector v2 = new Vector();
 v1.add(x); v1.add(y);
 v2.add(this.x); v2.add(this.y);
 vv.add(v1); vv.add(v2);
 return vv;
}

Client: Code:
void keyPressed()
{
// Same code...


 Object o = client.execute("testserver.update", go);
 println(o.getClass().getName() + ": " + o);
}

I got an output similar to your (just with less values).
This should push you in the right direction: you can access the data with Vector v = (Vector) o;
Re: xmlrpclib and python server
Reply #4 - Dec 20th, 2008, 11:56pm
 
I tried Vector v = (Vector) o;
and now I see the light at the end of tunnel
But println (v[0]);  as well as println (v[0][0]);  
gives `the type of the experssion must be an array but it resolved to Vector'
I am novice in processing and i will thank you for any suggestion how to access this data
Re: xmlrpclib and python server
Reply #5 - Dec 21st, 2008, 9:45am
 
See Vector reference:
Code:
  Object o = client.execute("testserver.update", go);
Vector v = (Vector) o;
Vector v1 = (Vector) v.get(1);
println(o.getClass().getName() + ": " + o + " > " + v.get(1) + " > " + v1.get(0));
Re: xmlrpclib and python server
Reply #6 - Dec 21st, 2008, 2:38pm
 
I made server on python to visualize data using processing, and now I can access python data. But it is still Object, for example:  
int L1 = (int) v1.get(5);
says "Cannot cast from Object ti int"
(The method line(float,float,float,float) in the type PApplet is not applicable for the arguments(Object))

This question is now solved at http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Syntax;action=display;num=1230029675;start=0#4

Thank you very much for consultation in new and powerful language that processing is.
Page Index Toggle Pages: 1