#NEWLINE# def execute( self , command , timeout = default_timeout , check_exit_code = True , background = False , as_root = False , strip_colors = True , **kwargs ) : #NEWLINE# #INDENT# '\n        Execute the specified command on the device using adb.\n\n        Parameters:\n\n            :param command: The command to be executed. It should appear exactly\n                            as if you were typing it into a shell.\n            :param timeout: Time, in seconds, to wait for adb to return before aborting\n                            and raising an error. Defaults to ``AndroidDevice.default_timeout``.\n            :param check_exit_code: If ``True``, the return code of the command on the Device will\n                                    be check and exception will be raised if it is not 0.\n                                    Defaults to ``True``.\n            :param background: If ``True``, will execute create a new ssh shell rather than using\n                               the default session and will return it immediately. If this is ``True``,\n                               ``timeout``, ``strip_colors`` and (obvisously) ``check_exit_code`` will\n                               be ignored; also, with this, ``as_root=True``  is only valid if ``username``\n                               for the device was set to ``root``.\n            :param as_root: If ``True``, will attempt to execute command in privileged mode. The device\n                            must be rooted, otherwise an error will be raised. Defaults to ``False``.\n\n                            Added in version 2.1.3\n\n        :returns: If ``background`` parameter is set to ``True``, the subprocess object will\n                  be returned; otherwise, the contents of STDOUT from the device will be returned.\n\n        ' #NEWLINE# self . _check_ready ( ) #NEWLINE# try : #NEWLINE# #INDENT# if background : #NEWLINE# #INDENT# if ( as_root and ( self . username != 'root' ) ) : #NEWLINE# #INDENT# raise DeviceError ( 'Cannot execute in background with as_root=True unless user is root.' ) #NEWLINE# #UNINDENT# return self . shell . background ( command ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . _is_root_user : #NEWLINE# #INDENT# as_root = False #NEWLINE# #UNINDENT# return self . shell . execute ( command , timeout , check_exit_code , as_root , strip_colors ) #NEWLINE# #UNINDENT# #UNINDENT# except CalledProcessError as e : #NEWLINE# #INDENT# raise DeviceError ( e )