diff --git a/.gitignore b/.gitignore index 7118ccf..2ab8caf 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,6 @@ docs/_build/ # PyBuilder target/ + +# IDE +.idea/ diff --git a/wexpect/host.py b/wexpect/host.py index 72e80aa..fbe71af 100644 --- a/wexpect/host.py +++ b/wexpect/host.py @@ -10,6 +10,7 @@ import re import traceback import types +from pathlib import WindowsPath import psutil import signal import socket @@ -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. @@ -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) + '>' diff --git a/wexpect/wexpect_util.py b/wexpect/wexpect_util.py index 7987c2d..79f9cd0 100644 --- a/wexpect/wexpect_util.py +++ b/wexpect/wexpect_util.py @@ -7,7 +7,7 @@ The command line argument parsers, and the Exceptions placed here. """ - +import platform import re import traceback import sys @@ -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