def _WaitUntilReady(self, ssh_diagnostic_log_file=None): logging.info('Connecting to Fuchsia using SSH.') if ssh_diagnostic_log_file is None: ssh_diagnostic_log_file = open(os.devnull, 'w') host, port = self._GetEndpoint() end_time = time.time() + _ATTACH_RETRY_SECONDS while time.time() < end_time: runner = remote_cmd.CommandRunner(self._GetSshConfigPath(), host, port) ssh_proc = runner.RunCommandPiped(['true'], ssh_args=['-v'], stdout=ssh_diagnostic_log_file, stderr=subprocess.STDOUT) if ssh_proc.wait() == 0: logging.info('Connected!') self._started = True return True time.sleep(_ATTACH_RETRY_INTERVAL) logging.error('Timeout limit reached.') log_file.flush() raise FuchsiaTargetException('Couldn\'t connect using SSH.')
def GetCommandRunner(self): """Returns CommandRunner that can be used to execute commands on the target. Most clients should prefer RunCommandPiped() and RunCommand().""" self._AssertIsStarted() if self._command_runner is None: host, port = self._GetEndpoint() self._command_runner = \ remote_cmd.CommandRunner(self._GetSshConfigPath(), host, port) return self._command_runner
def _WaitUntilReady(self, retries=_ATTACH_MAX_RETRIES): logging.info('Connecting to Fuchsia using SSH.') for retry in xrange(retries + 1): host, port = self._GetEndpoint() runner = remote_cmd.CommandRunner(self._GetSshConfigPath(), host, port) if runner.RunCommand(['true'], True) == 0: logging.info('Connected!') self._started = True return True time.sleep(_ATTACH_RETRY_INTERVAL) logging.error('Timeout limit reached.') raise FuchsiaTargetException('Couldn\'t connect using SSH.')
def _WaitUntilReady(self): logging.info('Connecting to Fuchsia using SSH.') host, port = self._GetEndpoint() end_time = time.time() + _ATTACH_RETRY_SECONDS while time.time() < end_time: runner = remote_cmd.CommandRunner(self._GetSshConfigPath(), host, port) if runner.RunCommand(['true'], True) == 0: logging.info('Connected!') self._started = True return True time.sleep(_ATTACH_RETRY_INTERVAL) logging.error('Timeout limit reached.') raise FuchsiaTargetException('Couldn\'t connect using SSH.')
def _ConnectToTarget(self): logging.info('Connecting to Fuchsia using SSH.') host, port = self._GetEndpoint() end_time = time.time() + common.ATTACH_RETRY_SECONDS ssh_diagnostic_log = self._log_manager.Open('ssh_diagnostic_log') while time.time() < end_time: runner = remote_cmd.CommandRunner(self._GetSshConfigPath(), host, port) ssh_proc = runner.RunCommandPiped(['true'], ssh_args=['-v'], stdout=ssh_diagnostic_log, stderr=subprocess.STDOUT) if ssh_proc.wait() == 0: logging.info('Connected!') self._started = True self._command_runner = runner return True time.sleep(_ATTACH_RETRY_INTERVAL) logging.error('Timeout limit reached.') raise FuchsiaTargetException('Couldn\'t connect using SSH.')