Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #60, #61 and another issue i found #62

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@ docs/_build/

# PyBuilder
target/

# IDE
.idea/
18 changes: 11 additions & 7 deletions wexpect/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import re
import traceback
import types
from pathlib import WindowsPath
import psutil
import signal
import socket
Expand Down Expand Up @@ -207,6 +208,9 @@ def __init__(self, command, args=[], timeout=30, encoding='UTF-8', decode_errors
self.searchwindowsize = searchwindowsize
self.interact_state = interact

if isinstance(self.cwd, WindowsPath):
self.cwd = str(self.cwd)

logger.info(f'Spawn started. location {os.path.abspath(__file__)}')

# If command is an int type then it may represent a file descriptor.
Expand All @@ -231,13 +235,13 @@ def __init__(self, command, args=[], timeout=30, encoding='UTF-8', decode_errors
self.args = args[:] # work with a copy
self.args.insert(0, command)
self.command = command

command_with_path = shutil.which(self.command)
if command_with_path is None:
logger.warning('The command was not found or was not executable: %s.' % self.command)
raise ExceptionPexpect(
'The command was not found or was not executable: %s.' % self.command)
self.command = command_with_path
#
# command_with_path = shutil.which(self.command)
# if command_with_path is None:
# logger.warning('The command was not found or was not executable: %s.' % self.command)
# raise ExceptionPexpect(
# 'The command was not found or was not executable: %s.' % self.command)
# self.command = command_with_path
self.args[0] = self.command

self.name = '<' + ' '.join(self.args) + '>'
Expand Down
7 changes: 5 additions & 2 deletions wexpect/wexpect_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
The command line argument parsers, and the Exceptions placed here.

"""

import platform
import re
import traceback
import sys
Expand All @@ -16,7 +16,10 @@
import signal

# platform does not define VEOF so assume CTRL-D
EOF_CHAR = b'\x04'
if platform.uname().system == "Windows":
EOF_CHAR = b'^D'
else:
EOF_CHAR = b'\x04'

SIGNAL_CHARS = {
signal.SIGTERM: b'\x011', # Device control 1
Expand Down