def __str__(self): username = getattr(self.ssh_client, 'username', None) hostname = getattr(self.ssh_client, 'hostname', None) if username and hostname: return "<SshSession %s@%s>" % (username, hostname) elif hostname: return "<SshSession %s>" % hostname return BaseSession.__str__(self)