scratra
python-scratch is no longer a pain
scratra.tk
Scratra is a framework, inspired by Sinatra, that makes connecting python with Scratch super simple. After you've downloaded(right click, save as...) it, you write this:
from scratra import *
@broadcast('hi')
def hi(scratch):
print 'Hello, world!'
run()Enable remote sensor connections, run, broadcast 'hi', and ... BAM!
View the nearly finished help resource.
Use this thread for discussions, ideas, suggestions, etc. Anything about it.
I'm excited to hear your thoughts, sentiments, and opinions.
Last edited by Greatdane (2012-05-04 22:27:03)
Offline
Oooh, I like the use of decorators... That's very clever
Presumably it supports messages with multiple values, and everything? I still can't get Construct to parse them properly...
Offline
blob8108 wrote:
Oooh, I like the use of decorators... That's very clever
![]()
Presumably it supports messages with multiple values, and everything? I still can't get Construct to parse them properly...![]()
Indeed it does..
I take a substring of the message starting at 4(removing the first four unecessary chars) then .split(), then if the first item of the list is 'sensor-update', parse the other things. You can check it on github.
Offline
Greatdane wrote:
blob8108 wrote:
Oooh, I like the use of decorators... That's very clever
![]()
Presumably it supports messages with multiple values, and everything? I still can't get Construct to parse them properly...![]()
Indeed it does..
![]()
I take a substring of the message starting at 4(removing the first four unecessary chars) then .split(), then if the first item of the list is 'sensor-update', parse the other things. You can check it on github.
What if the message is split up into multiple packets, such that you need multiple calls to socket.recv() to get it all?
Although I suppose that's unlikely to happen, given it's a local connection on the same machine...
Offline
blob8108 wrote:
Greatdane wrote:
blob8108 wrote:
Oooh, I like the use of decorators... That's very clever
![]()
Presumably it supports messages with multiple values, and everything? I still can't get Construct to parse them properly...![]()
Indeed it does..
![]()
I take a substring of the message starting at 4(removing the first four unecessary chars) then .split(), then if the first item of the list is 'sensor-update', parse the other things. You can check it on github.What if the message is split up into multiple packets, such that you need multiple calls to socket.recv() to get it all?
Although I suppose that's unlikely to happen, given it's a local connection on the same machine...
I'm not sure the message is split up into multiple packets very often, as that only happens when it's too long(occurring when multiple sensor updates happen at one time, very rarely). It's not too much of a problem to worry about.
Offline
Sounds cool!
Offline
DigiTechs wrote:
Just to ask, can you broadcast from Scratra to Scratch?
Yeah, but my documentation was somehow deleted, and I don't want to write it again. In your function, do
def myFunc(scratch):
scratch.broadcast('message')Offline
Greatdane wrote:
DigiTechs wrote:
Just to ask, can you broadcast from Scratra to Scratch?
Yeah, but my documentation was somehow deleted, and I don't want to write it again. In your function, do
Code:
def myFunc(scratch): scratch.broadcast('message')
Thanks.
Offline
scratra.tk: "This website was set to be removed for inactivity by www.000webhost.com. If you own this website, click here to protect it."
Just thought you should know...
Offline