Password is prompted by getpass.getpass()
call. This method always asks user for the password. Check this doc page: http://docs.python.org/2/library/getpass.html
I am assuming you are doing initialization outside telnet_send
method. Simply setup your password inside this initialization code --- something like self.password = getpass.getpass()
and then use this password elsewhere.
self.password = getpass.getpass()
def telnet_send(self, s):
passCode = '********'
if self.conn:
self.conn.write(s + '\r\n')
if self.password:
self.conn.read_until('Password: ')
self.conn.write(self.password.strip() + '\n')
else:
print s