我想从python运行adb命令,我已经找到了google自己的库,但是它不起作用。
https://github.com/google/python-adb
这是我使用的代码:(它来自示例)import os.path as op
from adb import adb_commands
from adb import sign_m2crypto
signer = sign_m2crypto.M2CryptoSigner(
op.expanduser('~/.android/adbkey'))
device = adb_commands.AdbCommands.ConnectDevice(rsa_keys=[signer])
这是我得到的错误:Traceback (most recent call last):
File "/home/elichai2/PycharmProjects/Test/python_adb.py", line 9, in
device = adb_commands.AdbCommands.ConnectDevice(rsa_keys=[signer])
File "/usr/local/lib/python2.7/dist-packages/adb/adb_commands.py", line 76, in ConnectDevice
return cls.Connect(handle, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/adb/adb_commands.py", line 99, in Connect
device_state = cls.protocol_handler.Connect(usb, banner=banner, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/adb/adb_protocol.py", line 277, in Connect
cmd, arg0, arg1, banner = cls.Read(usb, ['CNXN', 'AUTH'])
File "/usr/local/lib/python2.7/dist-packages/adb/adb_protocol.py", line 235, in Read
actual_checksum = cls.CalculateChecksum(data)
File "/usr/local/lib/python2.7/dist-packages/adb/adb_protocol.py", line 187, in CalculateChecksum
return sum(map(ord, data)) & 0xFFFFFFFF
TypeError: ord() expected string of length 1, but int found
有什么想法吗?