Quo Vadis, Open {Source, Standards, World}? w/ Jan Wildeboer – XDA:DevCon 2014

Open Source was a big topic at this years XDA:DevCon … more

Android 5.0 Leaked for the Samsung Galaxy Note 3

Android Lollipop is still making its way to many new devices. Firmware updates have been … more

Learn to Sync Files Between Android And PC with Unison

Dropbox and similar cloud services are great if youre planning to keep your files … more

OnePlus Indian Ban Lifted, Android One Expanding – XDA TV

Android 5.0.1 Lollipop is available for the Nvidia SHIELD Tablet! That and … more

Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[DEV] Standalone python scripts

OP anantshri

11th August 2011, 08:19 PM   |  #1  
OP Senior Member
Flag Bangalore
Thanks Meter: 318
 
682 posts
Join Date:Joined: Feb 2011
Donate to Me
More
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, 08:37 PM   |  #2  
DooMLoRD's Avatar
Recognized Developer
Flag Noida
Thanks Meter: 39,127
 
13,127 posts
Join Date:Joined: Jul 2010
very interesting
12th August 2011, 08:43 AM   |  #3  
iridaki's Avatar
Retired Forum Moderator / Recognized Themer
Flag Edinburgh, Scotland
Thanks Meter: 4,889
 
3,968 posts
Join Date:Joined: Feb 2007
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, 12:35 PM   |  #4  
Senior Member
Flag Sydney
Thanks Meter: 95
 
479 posts
Join Date:Joined: Mar 2011
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 12:45 PM.
12th August 2011, 03:07 PM   |  #5  
Senior Member
Thanks Meter: 557
 
1,583 posts
Join Date:Joined: Nov 2010
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, 12:46 PM   |  #6  
Senior Member
Flag Sydney
Thanks Meter: 95
 
479 posts
Join Date:Joined: Mar 2011
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, 05:36 PM   |  #7  
Senior Member
Flag Warsaw
Thanks Meter: 276
 
1,069 posts
Join Date:Joined: Jul 2009
More
Is this thread alive? Any news on console running python?
26th August 2013, 09:43 PM   |  #8  
Senior Member
Flag Frankfurt
Thanks Meter: 16
 
128 posts
Join Date:Joined: Nov 2012
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