[PD] Pd+pachube+python

Roman Haefeli reduzent at gmail.com
Mon Dec 6 11:58:59 CET 2010


Hi Fernando

I wasn't able to successfully run your python script, because I have no
access to the URL you posted:
urllib2.HTTPError: HTTP Error 401: Unauthorized

However, the description of the problem you have did ring a bell. I
remember that once someone had a similar problem. OSC allows to
transport different data types and a '1' can be sent as a string, an int
or a float. Ints and floats are converted by [unpackOSC] to Pd's
floating point number format and strings are converted to Pd's symbols.
I guess what you have here might be a symbolic '1' instead of a numeric
one.

The real fix would be to make sure that numeric values are really sent
as numeric values. That doesn't help if you don't have any control over
the sender. I haven't found yet a nice solution in Pd to convert
symbolic numbers into real floats. You could send all your data over a
[netsend]-[netclient] connection, because then the data is transformed
to FUDI messages and back to Pd messages and thus loses any information
about whether a certain element was numeric or symbolic. 

Roman


On Sun, 2010-12-05 at 22:26 -0300, FernandoG wrote:
> Hi 
> I am trying to comunicate pd with data coming from pachube
> (www.pachube.com) using a python script. The script ask for data from
> pachube web and convert the data to OSC protocol. Then the OSC mesagge
> is sent to pd. Pd recibe the OSC mesagge but something is wrong when
> unpack and route the data. 
> Data can not get in a number box object, this error mesagge is
> diplayed in console:   error: gatom: no method for '1'
> 
> The python script
> 
> # to receive data
> import urllib2
> # to send on with OpenSoundControl, OSC
> from simpleOSC import *
> import time
> 
> 
> initOSCClient('127.0.0.1', 57110)
> while 1:
> 
> data=urllib2.urlopen('http://api.pachube.com/v2/feeds/2791.csv?key=hereyourcode')
>   for l in data: 
>     d = l.strip().split(",", 2)
>     print d
>     sendOSCMsg('/test/num',d[0])  
>     sendOSCMsg('/test/val',d[2]) 
>     time.sleep(5) # wait here some secs
> 
> 
> the patch
> 
> #N canvas 599 0 450 476 10;
> #X declare -lib mrpeach;
> #X obj -217 25 import mrpeach;
> #X obj -220 112 unpackOSC;
> #X floatatom -219 277 5 0 0 0 - - -;
> #X obj -214 148 routeOSC /test;
> #X obj -191 348 print;
> #X floatatom -150 281 5 0 0 0 - - -;
> #X obj -219 66 udpreceive 57110;
> #X floatatom -92 290 5 0 0 0 - - -;
> #X obj -204 205 routeOSC /val /num;
> #X connect 1 0 3 0;
> #X connect 3 0 8 0;
> #X connect 6 0 1 0;
> #X connect 8 0 2 0;
> #X connect 8 1 5 0;
> #X connect 8 1 4 0;
> #X connect 8 2 7 0;
> 
> 
> any idea?
> 
> thanks
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list





More information about the Pd-list mailing list