With the announcement of the Android Scripting Engine, I had to check it out, what with the ability to code python on the G1. It has one large inconvenience at the moment. There is no built in way to use scripts on the SD card. I have a workaround for the time being. With the following script, which runs with ASE, you will be able to import scripts from the ase folder of your SD card into ASE's normal script directory.

import android
import os
import shutil

src = '/sdcard/ase'
dst = '/data/data/com.google.ase/scripts'

droid = android.Android()
for file in os.listdir(src):
    shutil.copy(os.path.join(src, file), dst)
    # Interesting permissions on Android
    os.chmod(os.path.join(dst, file), 0666)

droid.makeToast('Import Complete')

Note that you will be typing this into your Android device through ASE. The last script you will have to do that way. You will have to close and reopen ASE before the scripts appear.

Posted by Tyler Lesmann on June 10, 2009 at 11:56
Tagged as: android fix python
Post a comment