Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,813,525 Members 38,640 Now Online
XDA Developers Android and Mobile Development Forum

[DEV] Standalone python scripts

Tip us?
 
anantshri
Old
#1  
Senior Member - OP
Thanks Meter 318
Posts: 680
Join Date: Feb 2011
Location: Bangalore

 
DONATE TO ME
Default [DEV] Standalone python scripts

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:
PW=`pwd`
 export EXTERNAL_STORAGE=/mnt/sdcard
 export LANG=en
 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
 cd $PW
 /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.
The Following 4 Users Say Thank You to anantshri For This Useful Post: [ Click to Expand ]
 
DooMLoRD
Old
#2  
DooMLoRD's Avatar
Recognized Developer
Thanks Meter 38,384
Posts: 13,058
Join Date: Jul 2010
Location: Noida
very interesting
 
iridaki
Old
#3  
iridaki's Avatar
Retired Forum Moderator / Recognized Themer
Thanks Meter 4,656
Posts: 3,690
Join Date: Feb 2007
Location: Edinburgh, Scotland

 
DONATE TO ME
Brings back memories of Symbian...

Very interesting, looking forward to see if you can make something of it!
Thanks a lot!
 
pheel
Old
(Last edited by pheel; 12th August 2011 at 11:45 AM.)
#4  
Senior Member
Thanks Meter 94
Posts: 476
Join Date: Mar 2011
Location: Sydney
Quote:
Originally Posted by My_Immortal View Post
Brings back memories of Symbian...

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
Sony Xperia Z1
[Partially inactive on xda due to studies]

If you need a dropbox, get 250MB free by using THIS link

Nokia 3110 > Nokia 6100 > Sony Ericsson K750i > Nokia 5310 Xpress Music > Nokia N97 Mini > Sony Ericsson Xperia X10i > iPhone4s > Sony Xperia Z1

 
Hzu
Old
#5  
Senior Member
Thanks Meter 528
Posts: 1,493
Join Date: Nov 2010
Quote:
Originally Posted by phillu97 View Post
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
Obsolete Stuffs:
- FXP #125 CM7.2 ROM + #125 Kernel + Google Apps .FTF for Flashtool 0.8+
- Toolset for packaging FXP CM9 kernel .FTF
- Toolset for packaging FXP CM7 kernel .FTF
- Colour bug fix for FXP 121+ CM9.0 (Fixed as of #127.)
- Patch for camera (FXP CM7.2); removed as it was fixed in release #116.
- Patch for sensors (FXP CM7.2); removed as it was fixed in release #115.
 
pheel
Old
#6  
Senior Member
Thanks Meter 94
Posts: 476
Join Date: Mar 2011
Location: 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
Sony Xperia Z1
[Partially inactive on xda due to studies]

If you need a dropbox, get 250MB free by using THIS link

Nokia 3110 > Nokia 6100 > Sony Ericsson K750i > Nokia 5310 Xpress Music > Nokia N97 Mini > Sony Ericsson Xperia X10i > iPhone4s > Sony Xperia Z1

 
krzych
Old
#7  
Senior Member
Thanks Meter 264
Posts: 1,000
Join Date: Jul 2009
Location: Warsaw
Is this thread alive? Any news on console running python?
HTC Desire HD & Samsung Galaxy S4
Radio S-OFF, SuperCID or here | Eng S-OFF or here | Radio flashing | Radios | Proximity | Launcher | Voice | Battery | Prop | GPS Antenna | Desire Boost - Audio Effects App for DHD
Android - the most buggy system I've ever seen...
 
android_smiley
Old
#8  
Senior Member
Thanks Meter 16
Posts: 128
Join Date: Nov 2012
Location: Frankfurt
I've been trying everything to get python work but how to I actually get it working??? :/

Tags
python, scripting, standalone
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes