summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Edwards <joeledwards@gmail.com>2013-12-10 14:22:11 -0700
committerJoel Edwards <joeledwards@gmail.com>2013-12-11 07:37:57 -0700
commit06c3c574c8b5d2fd5ba877413e826a2f33075d48 (patch)
tree4b8846d381e1024db1f3012dde4767974b3bc83b
parente7c86c71985abd601530c84d30f9700b0b34d3b2 (diff)
downloadpexpect-06c3c574c8b5d2fd5ba877413e826a2f33075d48.tar.gz
Switched to a simpler approache for appending to the prompt
in try_read_prompt thanks to a suggestion from takluyver
-rw-r--r--pexpect/pxssh.py14
1 files changed, 3 insertions, 11 deletions
diff --git a/pexpect/pxssh.py b/pexpect/pxssh.py
index 0fef996..cbc07fe 100644
--- a/pexpect/pxssh.py
+++ b/pexpect/pxssh.py
@@ -159,18 +159,14 @@ class pxssh (spawn):
# maximum time for reading the entire prompt
total_timeout = timeout_multiplier * 3.0
- prompt = None
+ prompt = b''
begin = time.time()
expired = 0.0
timeout = first_char_timeout
while expired < total_timeout:
try:
- c = self.read_nonblocking(size=1, timeout=timeout)
- if prompt is None:
- prompt = c
- else:
- prompt += c
+ prompt += self.read_nonblocking(size=1, timeout=timeout)
expired = time.time() - begin # updated total time expired
timeout = inter_char_timeout
except TIMEOUT:
@@ -178,11 +174,7 @@ class pxssh (spawn):
# inter_char_timeout will drop us out of the loop quickly
expired = total_timeout
- result = ''
- if prompt is not None:
- result = prompt
-
- return result
+ return prompt
def sync_original_prompt (self, sync_multiplier=1.0):