Skip to content

Commit

Permalink
fix telnetlib issue
Browse files Browse the repository at this point in the history
  • Loading branch information
engineerjoe440 committed Dec 17, 2023
1 parent b3245e8 commit e244709
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions selprotopy/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,18 @@ def _write(self, data):

# Define Method to Read All Data to Next Relay Prompt
def _read_to_prompt(self, prompt_str=commands.PROMPT):
# Telnetlib Supports a Timeout
if hasattr(self.conn, "read_until"):
response = self.conn.read_until(prompt_str, timeout=self.timeout)
try:
# Telnetlib Supports a Timeout
response = self.conn.read_until(
prompt_str,
timeout=self.timeout
)
# PySerial Does not Support Timeout
except TypeError:
response = self.conn.read_until(prompt_str)
elif hasattr(self.conn, 'socket_read'):
response = socket.socket_read(self.conn)
# PySerial Does not Support Timeout
else:
response = self.conn.read_until(prompt_str)
if self.logger:
self.logger.debug(f'Rx: {response}')
if self.debug:
Expand Down

0 comments on commit e244709

Please sign in to comment.