[pyar] ¿Qué me recomiendan?
Gustavo Campanelli
gedece en gmail.com
Jue Nov 24 09:08:56 ART 2011
2011/11/24 Facundo Batista <facundobatista en gmail.com>
> 2011/11/23 Alejandro Santos <listas en alejolp.com>:
>
> >> Pero a través de SL4A sí!
> >>
> >> http://code.google.com/p/android-scripting/
> >>
> >
> > Negativo.
> >
> > La página de Android Scripting es un poco escueta es cuanto a las
> > limitaciones. La API de ContentProvider no está para Python:
> >
> >
> http://developer.android.com/reference/android/content/ContentProvider.html
>
> O sea, vos decís que con Python no podés acceder a *ninguna* API del
> teléfono?
>
> --
> . Facundo
>
> Blog: http://www.taniquetil.com.ar/plog/
> PyAr: http://www.python.org/ar/
> _______________________________________________
> pyar mailing list pyar en python.org.ar
> http://listas.python.org.ar/listinfo/pyar
>
> PyAr - Python Argentina - Sitio web: http://www.python.org.ar/
>
> La lista de PyAr esta Hosteada en USLA - Usuarios de Software Libre de
> Argentina - http://www.usla.org.ar
>
Esto es extraido de cuando introdujeron Python scripting junto con otros
lenguajes de scripting. Primero está el código Python y luego una
aclaración acerca de las APIs.
http://google-opensource.blogspot.com/2009/06/introducing-android-scripting.html
"""Say chat messages aloud as they are received."""
import android, xmpp
_SERVER = 'talk.google.com', 5223
class SayChat(object):
def __init__(self):
self.droid = android.Android()
username = self.droid.getInput('Username')['result']
password = self.droid.getInput('Password')['result']
jid = xmpp.protocol.JID(username)
self.client = xmpp.Client(jid.getDomain(), debug=[])
self.client.connect(server=_SERVER)
self.client.RegisterHandler('message', self.message_cb)
if not self.client:
print 'Connection failed!'
return
auth = self.client.auth(jid.getNode(), password, 'botty')
if not auth:
print 'Authentication failed!'
return
self.client.sendInitPresence()
def message_cb(self, session, message):
jid = xmpp.protocol.JID(message.getFrom())
username = jid.getNode()
text = message.getBody()
self.droid.speak('%s says %s' % (username, text))
def run(self):
try:
while True:
self.client.Process(1)
except KeyboardInterrupt:
pass
saychat = SayChat()
saychat.run()
These scripts demonstrates several of the available APIs available for both
Lua <http://code.google.com/p/android-scripting/wiki/LuaAndroidAPI> and
Python <http://code.google.com/p/android-scripting/wiki/PythonAndroidAPI>.
It is intended to be run as a service and silences the ringer when the
phone is placed face down. For some scripting languages, like BeanShell,
it's possible to access Android's Java API directly. To simplify things,
ASE provides the AndroidFacade class. For other languages, like Python and
Lua, the API is made available via JSON RPC <http://json-rpc.org/> calls to
a proxy. Naturally this means that only the part of the API which has been
wrapped by the AndroidFacade and AndroidProxy are available to
cross-compiled interpreters like Python and Lua. Thankfully, both
AndroidFacade and AndroidProxy are simple to extend.
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://listas.python.org.ar/pipermail/pyar/attachments/20111124/7c69ffcf/attachment.html>
More information about the pyar
mailing list