FORUMS

How to Root the LG G4 and Install TWRP Recovery – XDA TV

A rooting method has finally been found for the flagship LG G4. In this … more

New Xposed for Lollipop 5.0 Update Fixes Major Bugs

Senior Recognized Developer rovo89 has patched Xposed for Lollipop 5.0 to … more

Download Sony’s new AOSP-like concept for Xperia Z3

Over in our forums, Recognized Contributor Jozinek has posted a very … more

OnePlus 2 vs Moto X Style: Which is The Better Flagship?

Two big industry names have announced their newest flagship phones within the … more

[DEV] Standalone python scripts

687 posts
Thanks Meter: 320
 
Post Reply Subscribe to Thread Email Thread
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: [ View ]
 
 
11th August 2011, 07:37 PM |#2  
DooMLoRD's Avatar
Recognized Developer
Flag Gurgaon
Thanks Meter: 39,529
 
More
very interesting
12th August 2011, 07:43 AM |#3  
iridaki's Avatar
Retired Forum Moderator / Recognized Themer
Flag Edinburgh, Scotland
Thanks Meter: 5,058
 
Donate to Me
More
Brings back memories of Symbian...

Very interesting, looking forward to see if you can make something of it!
Thanks a lot!
12th August 2011, 11:35 AM |#4  
Senior Member
Flag Sydney
Thanks Meter: 95
 
More
Quote:
Originally Posted by My_Immortal

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
Last edited by pheel; 12th August 2011 at 11:45 AM.
12th August 2011, 02:07 PM |#5  
Senior Member
Thanks Meter: 566
 
More
Quote:
Originally Posted by phillu97

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
13th August 2011, 11:46 AM |#6  
Senior Member
Flag Sydney
Thanks Meter: 95
 
More
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
22nd June 2012, 04:36 PM |#7  
Senior Member
Flag Warsaw
Thanks Meter: 295
 
More
Is this thread alive? Any news on console running python?
26th August 2013, 08:43 PM |#8  
Senior Member
Flag Frankfurt
Thanks Meter: 16
 
More
I've been trying everything to get python work but how to I actually get it working??? :/
Post Reply Subscribe to Thread

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

Advanced Search
Display Modes