Introducing XDA:DevCon – A Conference For Developers By Developers
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
anantshri
Old
#1  
Senior Member - OP
Thanks Meter 310
Posts: 672
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.
whoami : Technology Enthusiast : My Website | MY Blog

My Work
DROIDCAT : Information Security Application Collection
Whitepaper : Security Issues in android custom ROMs

My Threads :
DEVELOPMENT : Ubuntu Lucid CHROOT: updated scripts
[DEV] BACKTRACK 5 on Xperia X10 chroot

My Devices
Phone : Xperia X10i (Self customized 2.3.3)
Tablet : Kindle Fire 6.3 (Stock rooted)
Music Player : iPod Touch 4G (8GB) - Jailbroken(5.1.1)
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 20548
Posts: 10,056
Join Date: Jul 2010
Location: Indian Institute of Management, Ahmedabad (IIMA)
very interesting

I am on a tour right now... will not be available for discussions for a while...



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 Z, T, S, ARC, PLAY

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





** NEW *** Xperia SDCARD Mounter App! (supports Xperia Z, ZL, Tablet Z, T/TL, TX, V, S/SL/NX, Ion, Acro S/HD, P, U, Go, Sola, J, Miro, Tipo, Tipo Dual, E, E Dual!)
 
iridaki
Old
#3  
iridaki's Avatar
Retired Forum Moderator / Recognized Themer
Thanks Meter 4402
Posts: 3,594
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 85
Posts: 419
Join Date: Mar 2011
Location: Sydney

 
DONATE TO ME
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
blog | http://pheelx3.me/
twitter | http://twitter.com/#!/Pheelx3
tumblr | http://pheelx3.tumblr.com/

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

 
Hzu
Old
#5  
Senior Member
Thanks Meter 463
Posts: 1,360
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 85
Posts: 419
Join Date: Mar 2011
Location: Sydney

 
DONATE TO ME
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
blog | http://pheelx3.me/
twitter | http://twitter.com/#!/Pheelx3
tumblr | http://pheelx3.tumblr.com/

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

 
krzych
Old
#7  
Senior Member
Thanks Meter 259
Posts: 982
Join Date: Jul 2009
Location: Warsaw
Is this thread alive? Any news on console running python?
HTC Desire HD
ROM history: Stock, LeeDroid, CM7, Virtuous Affinity, Ice Cold SandwiTch, Blackout ICS Incredible, ViperDHD - because it makes Sense
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...

 
Post Reply+
Tags
python, scripting, standalone
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

report this ad
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Go to top of page...

XDA PORTAL POSTS

Careers in Android: What Hiring Managers Won’t Tell You – XDA Developer TV

XDA Developer TV Producer Jayce released a video a … more

Coloring Your Logcat World

Getting feedback for your app during development is as simple as adding logging info where necessary and looking … more

Guide Your Sheep to Safety with Finger Shepherd

Just a coupe of days ago, we brought you news about a game calledAgent Sheep. In that … more

Nandroid Manager Receives Major Update

Do you find yourself obsessively jumping from ROM to ROM? And do you hate having to restore a full … more