original_docstring: 
          Waiting for device loading in ADB or fastboot state depends of **mode** variable.
  
          Args:
              mode (str): Required mode to wait device
              timeout (int, default :data:`.constants.DEFAULT_WAIT_DEVICE_TIMEOUT`): Timeout in seconds
              sleep_time (int, default :data:`.constants.DEFAULT_SLEEP_FOR_WAIT_ADB`): Sleep time in second after device
                  was detected in ADB
  
          Keyword 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
              InconsistentStateError when device detected in wrong mode after timeout
          
docstring: Waiting for device loading in ADB or fastboot state depends of **mode** variable.
  
  Keyword args:
  allow_adb_kill (bool, default :data:`.constants.DEFAULT_ADB_SERVER_KILL_ALLOWED`): Allow to kill ADB server
  
  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
  InconsistentStateError when device detected in wrong mode after timeout
docstring_tokens: Waiting for device loading in ADB or fastboot state depends of ** mode ** variable . Keyword args : allow_adb_kill ( bool default : data : ` . constants . DEFAULT_ADB_SERVER_KILL_ALLOWED ` ) : Allow to kill ADB server 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 InconsistentStateError when device detected in wrong mode after timeout
code: def wait_for(self, mode, timeout=DEFAULT_WAIT_DEVICE_TIMEOUT, sleep_time=DEFAULT_SLEEP_FOR_WAIT_ADB, **kwargs):
          """
          Waiting for device loading in ADB or fastboot state depends of **mode** variable.
  
          Args:
              mode (str): Required mode to wait device
              timeout (int, default :data:`.constants.DEFAULT_WAIT_DEVICE_TIMEOUT`): Timeout in seconds
              sleep_time (int, default :data:`.constants.DEFAULT_SLEEP_FOR_WAIT_ADB`): Sleep time in second after device
                  was detected in ADB
  
          Keyword 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
              InconsistentStateError when device detected in wrong mode after timeout
          """
          # check mode variable
          req_mode = mode.lower().strip()
          if req_mode in ADB_MODE_ALIASES:
              req_mode = 'adb'
          elif req_mode in FASTBOOT_MODE_ALIASES:
              req_mode = 'fastboot'
          else:
              raise CommandExecuteError('%s device mode is not supported' % req_mode.upper())
  
          verbose = kwargs.get('verbose', DEFAULT_MANAGER_COMMAND_VERBOSE)
          # wait for device
          t = time()
          printed = False  # use for print message once
          current = None
          start_time = time()  # use to reduce timeout in each cycles
          mode_timeout = timeout
          while (time() - t) <= timeout:
              current = self.get_mode(timeout=mode_timeout, **kwargs)
              if current == req_mode:
                  # sleep after detect device but only once
                  if req_mode == 'adb' and current != self.saved_mode:
                      sleep(sleep_time)
                  # update saved mode to skip sleep timeout next time
                  self.__update_saved_mode(current)
                  if verbose and printed:
                      self.logger.done()
                  return
              # print message once if required
              elif not printed and verbose:
                  printed = True
                  self.logger.info('Waiting for device in %s mode...' % req_mode.upper())
              sleep(1)
              mode_timeout, start_time = self._reduce_timeout(start_time, timeout)
  
          if current is not None and current != req_mode:
              raise InconsistentStateError('Device found in %s mode, but excepted in %s mode'
                                           % (current.upper(), req_mode.upper()))
          raise TimeoutExpiredError('Device not found !')
code_tokens: def wait_for ( self , mode , timeout = DEFAULT_WAIT_DEVICE_TIMEOUT , sleep_time = DEFAULT_SLEEP_FOR_WAIT_ADB , ** kwargs ) : req_mode = mode . lower ( ) . strip ( ) if req_mode in ADB_MODE_ALIASES : req_mode = 'adb' elif req_mode in FASTBOOT_MODE_ALIASES : req_mode = 'fastboot' else : raise CommandExecuteError ( '%s device mode is not supported' % req_mode . upper ( ) ) verbose = kwargs . get ( 'verbose' , DEFAULT_MANAGER_COMMAND_VERBOSE ) t = time ( ) printed = False current = None start_time = time ( ) mode_timeout = timeout while ( time ( ) - t ) <= timeout : current = self . get_mode ( timeout = mode_timeout , ** kwargs ) if current == req_mode : if req_mode == 'adb' and current != self . saved_mode : sleep ( sleep_time ) self . __update_saved_mode ( current ) if verbose and printed : self . logger . done ( ) return elif not printed and verbose : printed = True self . logger . info ( 'Waiting for device in %s mode...' % req_mode . upper ( ) ) sleep ( 1 ) mode_timeout , start_time = self . _reduce_timeout ( start_time , timeout ) if current is not None and current != req_mode : raise InconsistentStateError ( 'Device found in %s mode, but excepted in %s mode' % ( current . upper ( ) , req_mode . upper ( ) ) ) raise TimeoutExpiredError ( 'Device not found !' )
short_docstring: Waiting for device loading in ADB or fastboot state depends of **mode** variable.
short_docstring_tokens: Waiting for device loading in ADB or fastboot state depends of ** mode ** variable .
comment: """
          Waiting for device loading in ADB or fastboot state depends of **mode** variable.
  
          Args:
              mode (str): Required mode to wait device
              timeout (int, default :data:`.constants.DEFAULT_WAIT_DEVICE_TIMEOUT`): Timeout in seconds
              sleep_time (int, default :data:`.constants.DEFAULT_SLEEP_FOR_WAIT_ADB`): Sleep time in second after device
                  was detected in ADB
  
          Keyword 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
              InconsistentStateError when device detected in wrong mode after timeout
          """$SEP$# check mode variable$SEP$# wait for device$SEP$# use for print message once$SEP$# use to reduce timeout in each cycles$SEP$# sleep after detect device but only once$SEP$# update saved mode to skip sleep timeout next time$SEP$# print message once if required