Thread: Native SoundKloud
View Single Post
Old 01-07-2013, 01:21 AM   #168
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021142
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
Todays work. replaced all the headachey python module install details with a shell script.

[root@kindle root]# /mnt/us/soundkloud/prep.sh
Spoiler:
Quote:
Internet Connection tests as okay... Continuing
Connecting to pypi.python.org (140.211.10.73:80)
wget: can't open 'setuptools-0.6c11-py2.7.egg': File exists

Processing setuptools-0.6c11-py2.7.egg
Removing /mnt/us/python/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg
Copying setuptools-0.6c11-py2.7.egg to /mnt/us/python/usr/local/lib/python2.7/dist-packages
setuptools 0.6c11 is already the active version in easy-install.pth
Installing easy_install script to /mnt/us/python/usr/local/bin
Installing easy_install-2.7 script to /mnt/us/python/usr/local/bin

Installed /mnt/us/python/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11

Searching for pip
Best match: pip 1.2.1
Processing pip-1.2.1-py2.7.egg
pip 1.2.1 is already the active version in easy-install.pth
Installing pip script to /mnt/us/python/usr/local/bin
Installing pip-2.7 script to /mnt/us/python/usr/local/bin

Using /mnt/us/python/usr/local/lib/python2.7/dist-packages/pip-1.2.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip

Requirement already satisfied (use --upgrade to upgrade): soundcloud in /mnt/us/python/usr/local/lib/python2.7/dist-packages/soundcloud-0.3.5-py2.7.egg
Requirement already satisfied (use --upgrade to upgrade): fudge==1.0.3 in /mnt/us/python/usr/local/lib/python2.7/dist-packages/fudge-1.0.3-py2.7.egg (from soundcloud)
Requirement already satisfied (use --upgrade to upgrade): requests>=0.14.0 in /mnt/us/python/usr/local/lib/python2.7/dist-packages (from soundcloud)
Requirement already satisfied (use --upgrade to upgrade): simplejson>=2.0 in /mnt/us/python/usr/local/lib/python2.7/dist-packages (from soundcloud)
Cleaning up...

Downloading/unpacking requests==0.14.2
Downloading requests-0.14.2.tar.gz (361kB): 361kB downloaded
Running setup.py egg_info for package requests

warning: no files found matching 'tests/*.'
Installing collected packages: requests
Found existing installation: requests 0.14.2
Uninstalling requests:
Successfully uninstalled requests
Running setup.py install for requests

warning: no files found matching 'tests/*.'
Successfully installed requests
Cleaning up...


EDIT: Updated version will try to check for non-standard installs...

(this is on a 5 with a non standard installed python but a missing pythonenv for example)
[root@kindle soundkloud]# ./prep.sh
Quote:
Internet Connection tests as okay... Continuing
Non-Standard Python install maybe?... Searching /mnt/us/* (gimme a sec...)
python located, run AND greater than version 2.7: 1
Sorry it didn't work out... For more info on WHICH PYTHON TO RUN see http://bit.ly/soundkloud
okay so let see what would happen if we "fixed it"
Spoiler:
(NOTE: the pythonenv files EXPECTS to be in a directory named python to minimise false postives, and in the /mnt/us/* hierarchy)

So where are we gonna do this test?
[root@kindle python]# pwd
Quote:
/mnt/us/usr/share/python
[root@kindle python]# cat > ./pythonenv << EOF
Quote:
> export PYTHONPATH=/mnt/us/usr/lib/python2.7
> EOF
Now it works okay... Even with a non-standard location. ( fails on zero size files)

To hide library complaints one could....
[root@kindle soundkloud]# ./prep.sh 2> /dev/null

prep.sh
Spoiler:
PHP Code:
#!/bin/sh
#Check for python
skroot=/mnt/us/soundkloud/  # the default location...
REPORT=""  # error holder
MYPY=/mnt/us/python/usr/bin/python2.7 # the default location...
MYENV=/mnt/us/python/pythonenv # the default location...
TESTURL=google.com # meh you never know... someone might not be able to reach that...

## For if we fail
report ()
# spit it out...
eips -c
echo $REPORT
# Drop and roll...
eips -/mnt/us/soundkloud/prep.jpg
eips 0 1 
"$REPORT"
sleep 2
eips 
"      PRESS HOME KEY TO RETURN TO YOUR KINDLE     "
echo "Sorry it didn't work out... For more info on WHICH PYTHON TO RUN see http://bit.ly/soundkloud"
exit 1
}

## internet test
if ! ping -c 1 $TESTURL > /dev/null
then
REPORT
="    Please connect internet before proceeding    "
eips -c
eips 0 1 
"$REPORT"
sleep 2
eips 
"      PRESS HOME KEY TO RETURN TO YOUR KINDLE     "
exit 1
## we are good to go
else 
echo 
"Internet Connection tests as okay... Continuing"
fi

## python location and version test
if [ ! -e $MYPY ]
then
echo "Non-Standard Python install maybe?... Searching /mnt/us/* (gimme a sec...)"
MYPY=$(find /mnt/us/ -name '*'"python2.7"'*' grep "bin/python" )

## we failed
if [ -z $MYPY ]
then
REPORT
="   PY NOT FOUND. see http://bit.ly/soundkloud    "
report
fi
fi

# Make sure python is 2.7 or later
PYTHON_OK=`$MYPY -c 'import sys
print (sys.version_info >= (2, 7) and "1" or "0")'
`
echo 
"python located, run AND greater than version 2.7: $PYTHON_OK"
if [ "$PYTHON_OK'0' ]; then
REPORT
="   PY VERSION FAIL. see http://bit.ly/soundkloud  "
report
fi

## check we have an env to source - Or find one
if [ ! -e $MYENV ]
then
MYENV
=$(find /mnt/us/ -name '*'"pythonenv" grep "python/pythonenv" )
fi
## we failed
if [ -z $MYENV ]
then
REPORT
="      NO PY ENV?. see http://bit.ly/soundkloud    "
report
fi

## not 0 sized right?
if [ ! -s $MYENV ]
then
REPORT
="   ENV FILE 0 SIZE see http://bit.ly/soundkloud "
report
else
echo 
"using python environment file: $MYENV"
fi

## phew we made it...

cd $skroot
wget http
://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg

usleep 100
source $MYENV 

## hey, if you have a non standard install you could mess with this.
## But the above logic should do the work now...
## Let's hope that you have your python IN your PATH!! 
## meh no? add an extra splatter - just in case...

export PATH=`dirname $MYPY`:/mnt/us/python/usr/bin:/mnt/us/python/usr/local/bin:$PATH
sh 
./setuptools-0.6c11-py2.7.egg 

usleep 100
easy_install pip

usleep 100
pip install soundcloud

usleep 100
pip install 
-I requests==0.14.2

eips 
-c
eips 
-/mnt/us/soundkloud/post.jpg

usleep 500
eips 
"      PRESS HOME KEY TO RETURN TO YOUR KINDLE     " 


this makes a one shot installer a far closer reality.

Also fixed up the build scripts to be much shorter and simpler to read.

reworked the build so that the armv6l and the arm7l targets are chosen at run-time. Thus one release suits all..

more stuff i should note down but yeah progress.
Attached Thumbnails
Click image for larger version

Name:	Selection_102.png
Views:	60
Size:	29.4 KB
ID:	98943   Click image for larger version

Name:	ImageMagick: root.fb.pgm_101.png
Views:	60
Size:	26.7 KB
ID:	98944  

Last edited by twobob; 01-13-2013 at 10:53 PM. Reason: updated prep.sh, added a bunch of error handling, fixed dirname call issue.
twobob is offline   Reply With Quote