tools/include/device_utils.py
def remote_shell(cmd):
    '''Run the given command on on the device and return stdout.  Throw an
    exception if the remote command returns a non-zero return code.

    adb shell doesn't check the remote command's error code.  So to check this
    ourselves, we echo $? after running the command and then strip that off
    before returning the command's output.
    
    '''
    out = shell(r"""adb shell '%s; echo -n "\n$?"'""" % cmd)

    # The final '\n' in |out| separates the command output from the return
    # code.  (There's no newline after the return code because we did echo -n.)
    (cmd_out, _, retcode) = out.rpartition('\n')
    retcode = retcode.strip()

    if retcode == '0':
        return cmd_out

    print('Remote command %s failed with error code %s' % (cmd, retcode),
          file=sys.stderr)
    if cmd_out:
        print(cmd_out, file=sys.stderr)
    raise subprocess.CalledProcessError(retcode, cmd, cmd_out)
Run the given command on on the device and return stdout.  Throw an
    exception if the remote command returns a non-zero return code.

    adb shell doesn't check the remote command's error code.  So to check this
    ourselves, we echo $? after running the command and then strip that off
    before returning the command's output.
    
    
Run the given command on on the device and return stdout.  Throw an
exception if the remote command returns a non-zero return code.

adb shell doesn't check the remote command's error code.  So to check this
ourselves, we echo $. after running the command and then strip that off
before returning the command's output.
Run the given command on on the device and return stdout . Throw an exception if the remote command returns a non - zero return code . adb shell doesn ' t check the remote command ' s error code . So to check this ourselves we echo $ . after running the command and then strip that off before returning the command ' s output .
def remote_shell(cmd):
    out = shell(r"""adb shell '%s; echo -n "\n$?"'""" % cmd)
    (cmd_out, _, retcode) = out.rpartition('\n')
    retcode = retcode.strip()
    if retcode == '0':
        return cmd_out
    print('Remote command %s failed with error code %s' % (cmd, retcode),
          file=sys.stderr)
    if cmd_out:
        print(cmd_out, file=sys.stderr)
    raise subprocess.CalledProcessError(retcode, cmd, cmd_out)
def remote_shell ( cmd ) : out = shell ( r"""adb shell '%s; echo -n "\n$?"'""" % cmd ) ( cmd_out , _ , retcode ) = out . rpartition ( '\n' ) retcode = retcode . strip ( ) if retcode == '0' : return cmd_out print ( 'Remote command %s failed with error code %s' % ( cmd , retcode ) , file = sys . stderr ) if cmd_out : print ( cmd_out , file = sys . stderr ) raise subprocess . CalledProcessError ( retcode , cmd , cmd_out )
Run the given command on on the device and return stdout.
Run the given command on on the device and return stdout .
'''Run the given command on on the device and return stdout.  Throw an
    exception if the remote command returns a non-zero return code.

    adb shell doesn't check the remote command's error code.  So to check this
    ourselves, we echo $? after running the command and then strip that off
    before returning the command's output.
    
    ''' # The final '\n' in |out| separates the command output from the return # code.  (There's no newline after the return code because we did echo -n.)
cmd