Saturday, October 3, 2009

Prepping Fedora Core for NXT brick, and Arduino, to be used with pygame and mod_python, in a python environment

If you do a fresh install of Fedora 11, you just need to save this script and run it as root on your machine, once you have saved it with a .sh extenstion, open the terminal, use the command su to become root, then navigate to the directory you have saved it in. Change the permissions, before you try to run it, so it is executable. Run it by typing dot then slash the the script name: ./scriptname.sh

Before the script:
su
chmod 777 scriptname.sh


#! /bin/bash
yum -y install mod_python
mkdir -p /var/www/html/test
cat <<-EOF >/etc/httpd/conf.d/pythonTwo.conf
<Directory /var/www/html/test>
AddHandler python-program .py
PythonHandler mptest
PythonDebug On
</Directory>
EOF
cat <<-EOF >/var/www/html/test/mptest.py
#!/usr/bin/python
from mod_python import apache

def handler(req):
req.send_http_header()
req.write("Hello World!")
return apache.OK
EOF
yum -y install python-devel
yum -y install git
git clone http://github.com/lupeke/python-firmata.git
cd python-firmata
python setup.py install
yum -y install gcc
yum -y install pybluez
yum -y install nxt_python
yum -y install pygame
/usr/sbin/apachectl restart


**caveat**
Be careful where you save it, it will create a directory for the python-firmata in that directory. If you use this right when your machine boots, there is a possibility the yum updater will start using yum, if the script will pause until the updater is finished using yum then continue, or you can run it before you start the script.

No comments: