exscript
exscript copied to clipboard
How to connect to the emulator terminal of Android Studio for Android Emulator
I tried:
from Exscript.protocols import Telnet
conn = Telnet()
conn.connect('localhost',5554)
print(conn.response)
But I only get one "None"
After that I also tried:
from Exscript.util.start import start
from Exscript import Account
a=Account('pcxlk','')
def do_something(job, host, conn):
conn.send('auth lklk\r\n')
print(conn.response)
start(a,'telnet://localhost:5554', do_something)
The correct text is output, but it ends up exiting with an error, but print(conn.response)
doesn't run, it exits with an error
❯ /bin/python "/home/pcxlk/Desktop/from Exscript.py"
Android Console: Authentication required
Android Console: type 'auth <auth_token>' to authenticate
Android Console: you can find your <auth_token> in
'/home/pcxlk/.emulator_console_auth_token'
OK
localhost error: Buffer: "Android Console: Authentication required\r\nAndroid Console: type 'auth <auth_token>' to authenticate\r\nAndroid Console: you can find your <auth_token> in \r\n'/home/pcxlk/.emulator_console_auth_token'\r\nOK\r\n"
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/Exscript/protocols/protocol.py", line 769, in _app_authenticate
index, match = self._waitfor(prompt_list)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/Exscript/protocols/protocol.py", line 986, in _waitfor
result = self._domatch(re_list, False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/Exscript/protocols/telnet.py", line 99, in _domatch
raise TimeoutException(error)
Exscript.protocols.exception.TimeoutException: Error while waiting for response from device
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/Exscript/workqueue/job.py", line 78, in run
self.function(self)
File "/usr/lib/python3.11/site-packages/Exscript/queue.py", line 102, in _wrapped
result = func(job, host, conn, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/Exscript/util/decorator.py", line 117, in decorated
conn.login(flush=flush)
File "/usr/lib/python3.11/site-packages/Exscript/protocols/protocol.py", line 675, in login
self.authenticate(account, flush=False)
File "/usr/lib/python3.11/site-packages/Exscript/protocols/protocol.py", line 701, in authenticate
self.app_authenticate(app_account, flush=flush)
File "/usr/lib/python3.11/site-packages/Exscript/protocols/protocol.py", line 870, in app_authenticate
self._app_authenticate(account, password, flush, bailout)
File "/usr/lib/python3.11/site-packages/Exscript/protocols/protocol.py", line 774, in _app_authenticate
raise TimeoutException(msg)
Exscript.protocols.exception.TimeoutException: Buffer: "Android Console: Authentication required\r\nAndroid Console: type 'auth <auth_token>' to authenticate\r\nAndroid Console: you can find your <auth_token> in \r\n'/home/pcxlk/.emulator_console_auth_token'\r\nOK\r\n"
localhost finally failed.