parameters: (cmd)
return_statement: return '\n'.join(lines[:-1])
docstring: Run the given ADB shell command and emulate the exit code.
docstring_summary: Run the given ADB shell command and emulate the exit code.
docstring_tokens: Run the given ADB shell command and emulate the exit code .
function: def adb_shell(cmd):
    """Run the given ADB shell command and emulate the exit code."""
    output = check_output(['adb', 'shell', cmd + '; echo $?']).strip()
    lines = output.splitlines()
    if lines[-1] != '0':
      raise Exception('ADB command failed: %s\n\nOutput:\n%s' % (cmd, output))
    return '\n'.join(lines[:-1])
function_tokens: def adb_shell ( cmd ) : output = check_output ( [ 'adb' , 'shell' , cmd + '; echo $?' ] ) . strip ( ) lines = output . splitlines ( ) if lines [ - 1 ] != '0' : raise Exception ( 'ADB command failed: %s\n\nOutput:\n%s' % ( cmd , output ) ) return '\n' . join ( lines [ : - 1 ] )