mirror of
https://github.com/ARM-software/devlib.git
synced 2025-02-07 13:40:48 +00:00
TelnetConnection: allow username and/or password to be optional
If username is set to None, no '-l' option is appended to the telnet command. If password is set to None, devlib does not wait for a password prompt when connecting.
This commit is contained in:
parent
76b059c6b1
commit
f24493676c
@ -83,9 +83,17 @@ class TelnetConnection(pxssh.pxssh):
|
|||||||
|
|
||||||
def login(self, server, username, password='', login_timeout=10,
|
def login(self, server, username, password='', login_timeout=10,
|
||||||
auto_prompt_reset=True, sync_multiplier=1, port=23):
|
auto_prompt_reset=True, sync_multiplier=1, port=23):
|
||||||
cmd = 'telnet -l {} {} {}'.format(username, server, port)
|
args = ['telnet']
|
||||||
|
if username is not None:
|
||||||
|
args += ['-l', username]
|
||||||
|
args += [server, str(port)]
|
||||||
|
cmd = ' '.join(args)
|
||||||
|
|
||||||
spawn._spawn(self, cmd) # pylint: disable=protected-access
|
spawn._spawn(self, cmd) # pylint: disable=protected-access
|
||||||
|
|
||||||
|
if password is None:
|
||||||
|
i = self.expect([self.original_prompt, 'Login timed out'], timeout=login_timeout)
|
||||||
|
else:
|
||||||
i = self.expect('(?i)(?:password)', timeout=login_timeout)
|
i = self.expect('(?i)(?:password)', timeout=login_timeout)
|
||||||
if i == 0:
|
if i == 0:
|
||||||
self.sendline(password)
|
self.sendline(password)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user