original_docstring: 
          Check device mode. Base function for :func:`get_mode` and :func:`find_device` functions
  
          Args:
              allow_adb_kill (bool, default :data:`.constants.DEFAULT_ADB_SERVER_KILL_ALLOWED`): Allow to kill ADB server
  
          Warning:
              allow_adb_kill == True may affect other script and not recommended to use except Framework was started
              isolated via Docker or Virtual Machine.
  
          Raises:
              TimeoutExpiredError when device not found and timeout expired
              DeviceEnumeratedError when device detected in wrong status
  
          Returns:
              tuple: (str: 'adb' or 'fastboot', bool: allow_adb_kill)
          
docstring: Check device mode.
  
  allow_adb_kill == True may affect other script and not recommended to use except Framework was started
  isolated via Docker or Virtual Machine.
  
  TimeoutExpiredError when device not found and timeout expired
  DeviceEnumeratedError when device detected in wrong status
  
  'adb' or 'fastboot', bool: allow_adb_kill)
docstring_tokens: Check device mode . allow_adb_kill == True may affect other script and not recommended to use except Framework was started isolated via Docker or Virtual Machine . TimeoutExpiredError when device not found and timeout expired DeviceEnumeratedError when device detected in wrong status ' adb ' or ' fastboot ' bool : allow_adb_kill )
code: def __check_mode(self, allow_adb_kill=DEFAULT_ADB_SERVER_KILL_ALLOWED, **kwargs):
          """
          Check device mode. Base function for :func:`get_mode` and :func:`find_device` functions
  
          Args:
              allow_adb_kill (bool, default :data:`.constants.DEFAULT_ADB_SERVER_KILL_ALLOWED`): Allow to kill ADB server
  
          Warning:
              allow_adb_kill == True may affect other script and not recommended to use except Framework was started
              isolated via Docker or Virtual Machine.
  
          Raises:
              TimeoutExpiredError when device not found and timeout expired
              DeviceEnumeratedError when device detected in wrong status
  
          Returns:
              tuple: (str: 'adb' or 'fastboot', bool: allow_adb_kill)
          """
          a_devices, a_status = self.adb.devices(**kwargs)
          if self.serial.upper() in a_devices:
              if a_status[a_devices.index(self.serial.upper())] == 'offline' and allow_adb_kill is True:
                  # restart adb server once
                  self.adb.restart_server(**kwargs)
                  allow_adb_kill = False
              elif a_status[a_devices.index(self.serial.upper())] == 'device':
                  return 'adb', allow_adb_kill
              else:
                  raise DeviceEnumeratedError('Device %s was detected with %s status'
                                              % (NAME.safe_substitute(name=self.serial),
                                                 NAME.safe_substitute(
                                                     name=a_status[a_devices.index(self.serial.upper())])))
          else:
              f_devices, f_status = self.fb.devices(**kwargs)
              if self.serial.upper() in f_devices:
                  return 'fastboot', allow_adb_kill
          return None, allow_adb_kill
code_tokens: def __check_mode ( self , allow_adb_kill = DEFAULT_ADB_SERVER_KILL_ALLOWED , ** kwargs ) : a_devices , a_status = self . adb . devices ( ** kwargs ) if self . serial . upper ( ) in a_devices : if a_status [ a_devices . index ( self . serial . upper ( ) ) ] == 'offline' and allow_adb_kill is True : self . adb . restart_server ( ** kwargs ) allow_adb_kill = False elif a_status [ a_devices . index ( self . serial . upper ( ) ) ] == 'device' : return 'adb' , allow_adb_kill else : raise DeviceEnumeratedError ( 'Device %s was detected with %s status' % ( NAME . safe_substitute ( name = self . serial ) , NAME . safe_substitute ( name = a_status [ a_devices . index ( self . serial . upper ( ) ) ] ) ) ) else : f_devices , f_status = self . fb . devices ( ** kwargs ) if self . serial . upper ( ) in f_devices : return 'fastboot' , allow_adb_kill return None , allow_adb_kill
short_docstring: Check device mode.
short_docstring_tokens: Check device mode .
comment: """
          Check device mode. Base function for :func:`get_mode` and :func:`find_device` functions
  
          Args:
              allow_adb_kill (bool, default :data:`.constants.DEFAULT_ADB_SERVER_KILL_ALLOWED`): Allow to kill ADB server
  
          Warning:
              allow_adb_kill == True may affect other script and not recommended to use except Framework was started
              isolated via Docker or Virtual Machine.
  
          Raises:
              TimeoutExpiredError when device not found and timeout expired
              DeviceEnumeratedError when device detected in wrong status
  
          Returns:
              tuple: (str: 'adb' or 'fastboot', bool: allow_adb_kill)
          """$SEP$# restart adb server once