parameters: (self, command, expect_status=0, timeout=DEFAULT_TIMEOUT,
              retries=DEFAULT_RETRIES)
return_statement: return output
docstring: Runs a shell command on the device.
  
      Args:
        command: A string with the shell command to run.
        expect_status: (optional) Check that the command's exit status matches
          this value. Default is 0. If set to None the test is skipped.
        timeout: (optional) Timeout per try in seconds.
        retries: (optional) Number of retries to attempt.
  
      Returns:
        The output of the shell command as a string.
  
      Raises:
        device_errors.AdbCommandFailedError: If the exit status doesn't match
          |expect_status|.
docstring_summary: Runs a shell command on the device.
docstring_tokens: Runs a shell command on the device .
function: def Shell(self, command, expect_status=0, timeout=DEFAULT_TIMEOUT,
              retries=DEFAULT_RETRIES):
      """Runs a shell command on the device.
  
      Args:
        command: A string with the shell command to run.
        expect_status: (optional) Check that the command's exit status matches
          this value. Default is 0. If set to None the test is skipped.
        timeout: (optional) Timeout per try in seconds.
        retries: (optional) Number of retries to attempt.
  
      Returns:
        The output of the shell command as a string.
  
      Raises:
        device_errors.AdbCommandFailedError: If the exit status doesn't match
          |expect_status|.
      """
      if expect_status is None:
        args = ['shell', command]
      else:
        args = ['shell', '( %s );echo %%$?' % command.rstrip()]
      output = self._RunDeviceAdbCmd(args, timeout, retries, check_error=False)
      if expect_status is not None:
        output_end = output.rfind('%')
        if output_end < 0:
          # causes the status string to become empty and raise a ValueError
          output_end = len(output)
  
        try:
          status = int(output[output_end + 1:])
        except ValueError:
          logger.warning('exit status of shell command %r missing.', command)
          raise device_errors.AdbShellCommandFailedError(
              command, output, status=None, device_serial=self._device_serial)
        output = output[:output_end]
        if status != expect_status:
          raise device_errors.AdbShellCommandFailedError(
              command, output, status=status, device_serial=self._device_serial)
      return output
function_tokens: def Shell ( self , command , expect_status = 0 , timeout = DEFAULT_TIMEOUT , retries = DEFAULT_RETRIES ) : if expect_status is None : args = [ 'shell' , command ] else : args = [ 'shell' , '( %s );echo %%$?' % command . rstrip ( ) ] output = self . _RunDeviceAdbCmd ( args , timeout , retries , check_error = False ) if expect_status is not None : output_end = output . rfind ( '%' ) if output_end < 0 : # causes the status string to become empty and raise a ValueError output_end = len ( output ) try : status = int ( output [ output_end + 1 : ] ) except ValueError : logger . warning ( 'exit status of shell command %r missing.' , command ) raise device_errors . AdbShellCommandFailedError ( command , output , status = None , device_serial = self . _device_serial ) output = output [ : output_end ] if status != expect_status : raise device_errors . AdbShellCommandFailedError ( command , output , status = status , device_serial = self . _device_serial ) return output