Reputation: 357
I have following block of code:
class HwSwitch(object):
def __init__(self):
pass
def _create_channel(self):
try:
self.channel = self.ssh.invoke_shell()
except SSHException:
raise SSHException("Unable to invoke the SSH Command shell")
def _send_cmd_to_channel(self, cmd):
try:
time.sleep(1)
self.channel.send(cmd + '\r\n')
out = self.channel.recv(9999)
except SSHException:
raise SSHException("Execution of command '%s' failed" % cmd)
return str(out)
But I get always error which says: AttributeError: 'HwSwitch' object has no attribute 'channel'.
It seems that problem is somewhere at self.channel.send(cmd + '\r\n')
but I cannot see where. Is there something wrong (maybe indentation?). Thanks
Upvotes: 0
Views: 2020