[DEV] Standalone python scripts

Search This thread

anantshri

Senior Member
Feb 22, 2011
687
320
Bangalore
anantshri.info
I have been experimenting lately with some python scripts using the concept of http://code.google.com/p/android-scripting/

however i found the interface limiting in lots of places.

  • you can't run applications on console directly.
  • you have environmental limitations.
  • you can't pass command-line arguments.
so while searching for solution i have came across python standalone however this script itself had some shortcommings including path errors.

so i have worked on this and found an optimal solution so here is the customized script.

Code:
[B]PW=`pwd`[/B]
 export EXTERNAL_STORAGE=/mnt/sdcard
 [B]export LANG=en[/B]
 PYTHONPATH=/mnt/sdcard/com.googlecode.pythonforandroid/extras/python
 PYTHONPATH=${PYTHONPATH}:/data/data/com.googlecode.pythonforandroid/files/python/lib/python2.6/lib-dynload
 export PYTHONPATH
 export TEMP=/mnt/storage/com.googlecode.pythonforandroid/extras/python/tmp
 export PYTHON_EGG_CACHE=$TEMP
 export PYTHONHOME=/data/data/com.googlecode.pythonforandroid/files/python
 export LD_LIBRARY_PATH=/data/data/com.googlecode.pythonforandroid/files/python/lib
 [B]cd $PW[/B]
 /data/data/com.googlecode.pythonforandroid/files/python/bin/python "$@"

These changes allow for following things.

  1. allow us to use this shell script to call python.
  2. allows for command line argument passing.
  3. relative path references are now working
what i have setup at my system is as follows

  • script is named as py and placed at /system/bin/
  • chmod 755 /system/bin/py
  • so now i can naviagate to any folder and just type py followed by script name to execute it.
This should help in quick porting and testing of scripts in android handset, and small name should help in making it easy to work on virtual terminal.

However we cann't undermine the SL4A project coz the project is there to provide interfacing between android and python.

successfully
I will try to keep updating all the python scripts that i have been able to run hope others can also contribute to it.
 

pheel

Senior Member
Mar 7, 2011
488
95
Sydney
Brings back memories of Symbian... :D

Very interesting, looking forward to see if you can make something of it!
Thanks a lot! :)

OMGG YERHH ! i used to develop pytjon apps , but the limitation was python runtime had to be preinstalled... ! omgg ... superpython and python runtime ... how fast time travels ... sigh

Sent from my X10i using XDA Premium App
 
Last edited:

Hzu

Senior Member
Nov 13, 2010
1,689
577
OMGG YERHH ! i used to develop pytjon apps , but the limitation was python runtime had to be preinstalled... ! omgg ... superpython and python runtime ... how fast time travels ... sigh

Sent from my X10i using XDA Premium App
Haha superpython is cool. I remember translating those python scripts into my language. It was easy since I wad kinda familiar with python.


Sent from my X10i using XDA App
 

pheel

Senior Member
Mar 7, 2011
488
95
Sydney
hahahaha , and also nokia rolled out scribble powered by python which included python runtime . thats when everybody enjoyed by apps :) but of course thier dead now . i dont customise anymore , i let the ddevs do that and i relax :]

but again , thanks devs . i would have went back to symbian if it werent for them .

Sent from my X10i using XDA Premium App
 

Top Liked Posts

  • There are no posts matching your filters.
  • 4
    I have been experimenting lately with some python scripts using the concept of http://code.google.com/p/android-scripting/

    however i found the interface limiting in lots of places.

    • you can't run applications on console directly.
    • you have environmental limitations.
    • you can't pass command-line arguments.
    so while searching for solution i have came across python standalone however this script itself had some shortcommings including path errors.

    so i have worked on this and found an optimal solution so here is the customized script.

    Code:
    [B]PW=`pwd`[/B]
     export EXTERNAL_STORAGE=/mnt/sdcard
     [B]export LANG=en[/B]
     PYTHONPATH=/mnt/sdcard/com.googlecode.pythonforandroid/extras/python
     PYTHONPATH=${PYTHONPATH}:/data/data/com.googlecode.pythonforandroid/files/python/lib/python2.6/lib-dynload
     export PYTHONPATH
     export TEMP=/mnt/storage/com.googlecode.pythonforandroid/extras/python/tmp
     export PYTHON_EGG_CACHE=$TEMP
     export PYTHONHOME=/data/data/com.googlecode.pythonforandroid/files/python
     export LD_LIBRARY_PATH=/data/data/com.googlecode.pythonforandroid/files/python/lib
     [B]cd $PW[/B]
     /data/data/com.googlecode.pythonforandroid/files/python/bin/python "$@"

    These changes allow for following things.

    1. allow us to use this shell script to call python.
    2. allows for command line argument passing.
    3. relative path references are now working
    what i have setup at my system is as follows

    • script is named as py and placed at /system/bin/
    • chmod 755 /system/bin/py
    • so now i can naviagate to any folder and just type py followed by script name to execute it.
    This should help in quick porting and testing of scripts in android handset, and small name should help in making it easy to work on virtual terminal.

    However we cann't undermine the SL4A project coz the project is there to provide interfacing between android and python.

    successfully
    I will try to keep updating all the python scripts that i have been able to run hope others can also contribute to it.