#!/bin/bash

PYTHONS=`find /usr/bin/python* | grep -v config | grep -v count`

function gen_ocarina()
{
	PY=$1
	#OUT="bin/ocarina"
	#echo "#!/bin/bash" > $OUT
	#echo "$PY ocarina.py \$*" >> $OUT
	#chmod +x $OUT

	OUT="ocarina.py"
	echo "#!$PY" > $OUT
	echo "import ocarina" >> $OUT
	echo "ocarina.run()" >> $OUT
	chmod +x $OUT
}

function gen_bin()
{
	PY=$1
	gen_ocarina $PY
	echo ""
}

for PY in $PYTHONS
do
	$PY -c "import gst" 2>/dev/null 1>/dev/null
	if [ "$?" == "0" ]
	then
		echo "Found python version: $PY"
		gen_bin $PY
		break
	fi
done
