How to Control Both Moto G and Moto E LEDs

Notification LEDs offer a great way to check for notification at a glance on the Moto G (2013) and … more

LG G3 Receives Oversharpening Fix via Modified Kernel

Nothing is perfect, as they say. No matter how alluring or seemingly perfect, … more

APKTool Updated with Android Lollipop Support

One of the beauties of Android is the level of flexibility we have over our devices. Whether … more

Lollipop Leak for Sprint Galaxy S5, TWRP for Micromax Canvas Magnus – XDA TV

Android 5.0 Lollipop has been leaked for the Sprint … 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

ASE Scripts

OP twistedumbrella

10th June 2009, 04:07 PM   |  #1  
I wanted to start a thread to post ASE scripts. They support three different languages and while gscript is amazing, this seems to have a lot of availability for saving the time of making entire programs for one or two functions that don't need an entire UI. Plus they can run after you close ASE, so its not a once and done environment. I would like to compile scripts here to make them easy to find.

Mods: This is not a build related topic, it spans all builds. It is not a duplicate, as the only searchable post was a link to the program. It is development because while the scripts can replace programs (in which case id post in app forum), I want to use this to do nodding and on-the-fly enhancements (development forum)
13th June 2009, 02:52 PM   |  #2  
Senior Member
Thanks Meter: 12
 
1,364 posts
Join Date:Joined: Mar 2009
Good idea. I'm going to bump this
13th June 2009, 06:40 PM   |  #3  
Senior Member
Flag naperville il
Thanks Meter: 30
 
154 posts
Join Date:Joined: Feb 2009
This just rocked my world.

ASE Blog

ASE Google Code page

ASE Faq

ASE Lua API

ASE Python API

ASE User Guide

Download ASE 0.7a
14th June 2009, 11:05 AM   |  #4  
Junior Member
Thanks Meter: 0
 
2 posts
Join Date:Joined: Feb 2009
Am I the only person who thinks that ASE is completely useless ?

Actually, the method used is a HUGE hack (using JSON embedded in a TCP socket is not the cleaner thing I saw) -- ok I'm not so deeply into ASE source code, but still.

... and, the API available is very very lightweight compared to Android's standard library.

Why not having an app which just exports the current Context object into a Beanshell context ? (and maybe having access to the interpreter via adb). Here, we could have access to the whole Java APIs and do nearly exactly what we can do know using plain Java code. It would be clearly awesome !

A better thing would be using Groovy, but it doesn't seem to like dx.

I've already tried to launch the Beanshell interpreter via ASE, but it fails (when the same script works on my computer).
14th June 2009, 08:29 PM   |  #5  
Paul22000's Avatar
Senior Member
Thanks Meter: 140
 
3,473 posts
Join Date:Joined: Jan 2008
Donate to Me
Anyone make (or find) any cool scripts?
14th June 2009, 09:02 PM   |  #6  
corp769's Avatar
Senior Member
Thanks Meter: 0
 
211 posts
Join Date:Joined: Feb 2009
I honestly like the idea of the ASE scripting because it gives people the ability to write scripts and learn about it.
15th June 2009, 02:02 AM   |  #7  
Junior Member
Thanks Meter: 0
 
22 posts
Join Date:Joined: Dec 2008
Great!
This is great. Just one thing I'd change: It would be nice to split the daemon package and the language support packages.

I, for one, have debian installed and already running a python environment with many extensions installed. I'd prefer to install just the "service" part of ASE, copy android.py to my site-packages directory and integrate it into existing scripts. I'd keep ASE running on a fixed port and start modifying existing scripts to utilize the ASE service.
15th June 2009, 03:27 AM   |  #8  
Junior Member
Thanks Meter: 0
 
22 posts
Join Date:Joined: Dec 2008
Mini Howto: Using ASE from debian
I wanted to use ASE from the debian installed on my android phone and did some minor patching to accommodate the fact that debian still uses python 2.5 whereas ASE requires python 2.6.

Here's how you do it:

Install the required packages:

Code:
# if you don't have python already
apt-get install python
# python 2.5 doesn't have json but this package will do.
apt-get install python-simplejson
Copy android.py from ASE to debian:

Code:
cp /data/data/com.google.ase/python/lib/python2.6/android.py /usr/lib/python2.5/site-packages/android.py
Apply this patch to android.py, to remove python 2.6 dependencies:

Code:
cd /
patch -p0 <<EOF
--- /data/data/com.google.ase/python/lib/python2.6/android.py   2009-06-14 22:48:06.000000000 +0000
+++ /usr/lib/python2.5/site-packages/android.py 2009-06-15 00:58:31.000000000 +0000
@@ -14,7 +14,7 @@
 
 __author__ = 'Damon Kohler <damonkohler@gmail.com>'
 
-import json
+import simplejson as json
 import os
 import socket
 import sys
@@ -25,7 +25,8 @@
 class Android(object):
 
   def __init__(self):
-    self.conn = socket.create_connection(('localhost', PORT))
+    self.conn = socket.socket()
+    self.conn.connect(('localhost', int(PORT)))
     self.client = self.conn.makefile()
     self.id = 0
 
EOF
That's it.

To use it:

Activate ASE and start a terminal. (I hope future versions of ASE will run the service independent of the terminal and will no longer require this).

In your debian terminal:
Code:
export AP_PORT=$(netstat -napt|sed -n 's/^tcp.*127.0.0.1:\([0-9]*\).*LISTEN.*ase$/\1/gp')
python
The above export is required because ASE currently uses a random port. I hope future versions of ASE will allow selecting a fixed one.

Now you can use ASE from your debian's python, the same way you would in ASE's terminal:

Code:
Python 2.5.2 (r252:60911, Nov 15 2008, 00:34:24) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import android
>>> a=android.Android()
>>> a.makeToast('debian')
{u'result': None, u'id': 0, u'error': None}
>>>
Now you can start porting scripts to use ASE
13th July 2009, 02:40 AM   |  #9  
Senior Member
Thanks Meter: 5
 
295 posts
Join Date:Joined: May 2009
I have been trying to figure out how to reboot my phone using any of the interpreters in ASE.

I have tried the following in Lua.

os.execute("reboot")

and I get permission denied.

I have tried
os.execute("su")
os.execute("reboot")
but then the terminal changes from $ to # and nothing happens.

Get the same results using os.system() commands in python.

Anyone have any ideas on how to make this work? Seems like it ought to be simple but I have no experience in these languages.
14th July 2009, 07:28 PM   |  #10  
Junior Member
Thanks Meter: 0
 
22 posts
Join Date:Joined: Dec 2008
Try "su -c /system/bin/reboot".

Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes