[FIX] Windows escape characters

This commit is contained in:
Benedek Racz 2019-05-13 13:06:56 +02:00
parent 2a38f946ce
commit 01898e5087
2 changed files with 3 additions and 5 deletions

View File

@ -12,7 +12,7 @@ sys.path.insert(0, wexpectPath)
import wexpect
# Path of cmd executable:
cmdPathes = [r'C:\\Windows\\System32\\cmd.exe', 'cmd.exe', 'cmd']
cmdPathes = ['C:\Windows\System32\cmd.exe', 'cmd.exe', 'cmd']
cmdPrompt = '>'
for cmdPath in cmdPathes:

View File

@ -284,7 +284,6 @@ def spawn(command, args=[], timeout=30, maxread=2000, searchwindowsize=None, log
log('\t%s=%s' % (name, env[name]))
if cwd:
log('Working directory: %s' % cwd)
log('Spawning %s' % join_args([command] + args))
if sys.platform == 'win32':
return spawn_windows(command, args, timeout, maxread, searchwindowsize, logfile, cwd, env,
codepage)
@ -1413,7 +1412,6 @@ class spawn_unix (object):
raise TIMEOUT ('Timeout exceeded in expect_any().')
# Still have time left, so read more data
c = self.read_nonblocking(self.maxread, timeout)
# c = c.decode("utf-8")
freshlen = len(c)
time.sleep (0.0001)
incoming += c
@ -2843,7 +2841,7 @@ def join_args(args):
commandline.append(arg)
return ' '.join(commandline)
def split_command_line(command_line):
def split_command_line(command_line, escape_char = '^'):
"""This splits a command line into a list of arguments. It splits arguments
on spaces, but handles embedded quotes, doublequotes, and escaped
@ -2863,7 +2861,7 @@ def split_command_line(command_line):
for c in command_line:
if state == state_basic or state == state_whitespace:
if c == '\\': # Escape the next character
if c == escape_char: # Escape the next character
state = state_esc
elif c == r"'": # Handle single quote
state = state_singlequote