skip to main |
skip to sidebar
Doing a quick review of the Rube Goldberg branches in git:
- Master - Needs pylint fixing
- file-plugin - work complete. Deleted
- gpio-impl - work complete. Deleted
- http-plug - work still to do. Merge conflicts from master. Added Trello item
- pip-packaging -- work still to do in order to figure out how to use from pip install only. Merged master. Added Trello
- scratch-plug - work complete. Deleted. Trello for sorting out tests
For the Rube Goldberg project at the CoderDojo I need a way to interact with Scratch from Python. Here's my steps of how I went about it:
- After reading around I realised that I'd have to run Scratch 1.4 and the Python interaction would come from scratchpy - https://github.com/pilliq/scratchpy
- Installed scratch 1.4 on Windows
- pip install scratchpy
- Enabled Scratch remote sensing - http://wiki.scratch.mit.edu/wiki/Remote_Sensor_Connections#Enabling
- Played with the interaction - http://youtu.be/YG99uam8pKA
- Create new branch for scratch plugin git checkout -b scratch-plug
- Check all tests pas
- python setup.py test
- Tests failed as wasn't on Rasp PI. After some poking around I discovered that I'd installed the GPIO package on to my development virtual box environment, and so now the package was loading okay and the case that I had set up in the test file to spot the lack of GPIO wasn't working. I deleted out the GPIO package and it all worked again...phew!
- Making the scratch target -- use a broadcast of either "BLOCK-PRESENT" or "BLOCK-ABSENT"
- Create a scratchplug.py module
- Implemented the target code
- Tested that it worked using a file source
- Not quite sure how to make the unit tests work. Will park that problem for now and come back to it later
- Now to make the source method
- The problem is that the scratch.receive() method blocks until it receives a broadcast, but the Rube Goldberg architecture needs to poll
- The solution will be to use the multiprocessing module as shown in this answer on Stack Overflow - http://stackoverflow.com/questions/492519/timeout-on-a-python-function-call
- Got a bit stuck coordinating the output with Queues since I didn't realise that multiprocessing had its own implementation of Queue -- you live and learn
- Committed that on to the scratch-plug and pushed to GitHub
- Made a quick demo of the Minecraft light going into scratch and scratch button turning on a light in Minecraft - https://www.youtube.com/watch?v=cpD-RegWybA