diff --git a/README.md b/README.md index 67d4750..9ba1312 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,14 @@ signer = sign_m2crypto.M2CryptoSigner( device = adb_commands.AdbCommands.ConnectDevice( rsa_keys=[signer]) # Now we can use Shell, Pull, Push, etc! -for i in xrange(10): - print device.Shell('echo %d' % i) +for i in range(10): + print(device.Shell('echo %d' % i)) + +# Want to check the kernel version? Do this. +print(device.Shell('uname -a')) + +# Want to check some properties? Do this. +print(device.Shell('getprop | grep dalvik')) ``` ### Pros diff --git a/adb/adb_protocol.py b/adb/adb_protocol.py index af2514c..7d95510 100644 --- a/adb/adb_protocol.py +++ b/adb/adb_protocol.py @@ -277,6 +277,10 @@ def Connect(cls, usb, banner=b'notadb', rsa_keys=None, auth_timeout_ms=100): InvalidResponseError: When the device does authentication in an unexpected way. """ + # In py3, convert unicode to bytes. In py2, convert str to bytes. + # It's later joined into a byte string, so in py2, this ends up kind of being a no-op. + if isinstance(banner, str): + banner = bytearray(banner, 'utf-8') msg = cls( command=b'CNXN', arg0=VERSION, arg1=MAX_ADB_DATA, data=b'host::%s\0' % banner)