5,594,282 Members 43,276 Now Online
XDA Developers Android and Mobile Development Forum

[DEV] Standalone python scripts

Tip us?
 
anantshri
Old
#1  
Senior Member - OP
Thanks Meter 316
Posts: 678
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 34113
Posts: 12,226
Join Date: Jul 2010
Location: Pune, Maharashtra
very interesting
Like my work? Please consider donating via PayPal

Lead Developer of Team UtterChaos & Member of Team ICX

Creator of DooMKernel making those Snapdragons fly higher and faster

Android Devices I use : Sony Xperia Z1, Z, SP, T | WISHLIST: Sony Xperia Z2

Contributions : Generic Android / Xperia X10 / Xperia 2011 devices / Samsung Galaxy S2 / Huawei Ideos X6 / Samsung Galaxy SCL (i9003) / HTC Flyer / Kindle Fire / HTC JetStream / Xperia P, Sola, U / HTC One X / Xperia S / Xperia T, V, TX / Xperia Z, ZL, Tablet Z / Xperia SP / Xperia Z1 / Sony ZU GPe / Xperia Z1 Compact / Xperia Z2, Z2 Tablet / Xperia T2 Ultra

My Apps on Google Play Store | Follow me on Twitter!
 
iridaki
Old
#3  
iridaki's Avatar
Retired Forum Moderator / Recognized Themer
Thanks Meter 4621
Posts: 3,673
Join Date: Feb 2007
Location: Athens

 
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 93
Posts: 474
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 521
Posts: 1,450
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 93
Posts: 474
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 15
Posts: 126
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


XDA PORTAL POSTS

HTC Releases Dual Lens SDK for the HTC One M8 (2014)

One of the highlights of the HTC One M8is its new dual lens camera system. Termed … more

Google ATAP Reveals Project Ara Developer Kits and 100K Prize Challenge

Today, Paul Eremenko from Google’s Advanced Technology and … more

Configure Your System Settings on a Per-App Basis

Do you ever like to make sure that certain device settings are enabled prior to entering a … more

How to Hack An Android App (Don’t Try This at Home) – XDA Developer TV

Listen, don’t cheat in your games. So don’t … more