def data_received(self, data, datatype): """ Process data recieved events """ if self._first: print('cat <<_EOF >>%s\n%s\n%s\n%s\n_EOF\n' % (self._file, "# "+sanitize(self._cmd), _delimiter*80, data), file=output) log.info('[%s:%s] %s\n%s', self._host, self._usr, self._cmd, data) self._first = False else: print('cat <<_EOF >>%s\n%s\n_EOF' % (self._file, data.strip()), file=output) log.info('[%s:%s] %s\n%s', self._host, self._usr, self._cmd, data)
_start = loop.time() # Begin asynchronous loop execution loop.run_until_complete(SSHManager(_host_queue, args.cmdlist)) finally: _end = loop.time() log.debug(_delimiter*40) _fail_count = 0 for _host_tuple in _hosts: _host = _host_tuple[0] if _host in sessionfailures or _host in connectfailures: _fail_count += 1 log.info('Successfully ran on %d hosts in %.03fs', (_host_count-_fail_count), (_end-_start)) if sessionfailures or connectfailures: # Only report unique failures (_hosts set iterable) for _host_tuple in sorted(_hosts): _host = _host_tuple[0] if _host in sessionfailures: log.warning('%s command failed: %s (%s)', _host, sessionfailures[_host][_CMD], sessionfailures[_host][_STATUS]) if _host in connectfailures: log.warning('%s connection failed: %s', _host, connectfailures[_host]) else: log.info('No errors reported.')