Forum
Best way to run python script with Xbian? - Printable Version

+- Forum (http://forum.xbian.org)
+-- Forum: Community (/forum-5.html)
+--- Forum: Uncategorized (/forum-59.html)
+--- Thread: Best way to run python script with Xbian? (/thread-1329.html)



Best way to run python script with Xbian? - Skywatch - 7th Sep, 2013 07:22 PM

HI,

Probably a bit noobish, but what's the best/preferred way to run a python script at start up to run alongside xbian without prbolems?

I want to start looking into some hardware/automation stuff soon.

Skywatch.


RE: Best way to run python script with Xbian? - namtih - 7th Sep, 2013 07:59 PM

You could use "nano /etc/rc.local" to execute commands at startup of your Rpi for example.


RE: Best way to run python script with Xbian? - Markamc - 8th Sep, 2013 05:29 AM

I'm a noob....I used the upstart.conf route, /etc/init/ , it works for me for grabbing an event before xbmc does at start-up and can also respwan if necessary. Here is the one i wrote... uimapper.conf to exec the python code

http://markamc.cybaman.net/?p=50

hope it helps

mark


RE: Best way to run python script with Xbian? - mk01 - 8th Sep, 2013 06:46 AM

Yes, the best way would be to write upstart script /etc/init/my_python_script.conf

Code:
#!upstart

start on startup
stop on runlevel [06]

respawn

exec python /path/to/my/python/script.py

If it should run constantly, respawn will re-start the script if crashed (exited with return code different than 0).

If it is just task-like script (should be started - do something - and exit), remove "respawn" a put "task" instead.

It will be started with startup of XBian and depending whether it's "task" or not, it will remain running (check with "status my_python_script") or will just start, do the job and stop.

If the script is providing some output text, it can be found at /var/log/upstart/my_python_script.log .


RE: Best way to run python script with Xbian? - Skywatch - 13th Sep, 2013 07:37 PM

Thanks for that - It will need to run constantly as it will be controlling the power to the amp and probably some lighting as well.

Does anyone know if it is possible to run WebIOPI alongside xbian? This will be crucial to the plan. Can I use startup to get this going too?

Cheers!

Skywatch


RE: Best way to run python script with Xbian? - mk01 - 15th Sep, 2013 09:37 AM

if it runs on Debian, there is 99% probability that it will run on XBian as well.