mirror of
https://github.com/clearml/wexpect-venv
synced 2025-02-07 05:20:52 +00:00
[FIX] Windows escape characters
This commit is contained in:
parent
2a38f946ce
commit
01898e5087
@ -12,7 +12,7 @@ sys.path.insert(0, wexpectPath)
|
|||||||
import wexpect
|
import wexpect
|
||||||
|
|
||||||
# Path of cmd executable:
|
# Path of cmd executable:
|
||||||
cmdPathes = [r'C:\\Windows\\System32\\cmd.exe', 'cmd.exe', 'cmd']
|
cmdPathes = ['C:\Windows\System32\cmd.exe', 'cmd.exe', 'cmd']
|
||||||
cmdPrompt = '>'
|
cmdPrompt = '>'
|
||||||
|
|
||||||
for cmdPath in cmdPathes:
|
for cmdPath in cmdPathes:
|
||||||
|
@ -284,7 +284,6 @@ def spawn(command, args=[], timeout=30, maxread=2000, searchwindowsize=None, log
|
|||||||
log('\t%s=%s' % (name, env[name]))
|
log('\t%s=%s' % (name, env[name]))
|
||||||
if cwd:
|
if cwd:
|
||||||
log('Working directory: %s' % cwd)
|
log('Working directory: %s' % cwd)
|
||||||
log('Spawning %s' % join_args([command] + args))
|
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
return spawn_windows(command, args, timeout, maxread, searchwindowsize, logfile, cwd, env,
|
return spawn_windows(command, args, timeout, maxread, searchwindowsize, logfile, cwd, env,
|
||||||
codepage)
|
codepage)
|
||||||
@ -1413,7 +1412,6 @@ class spawn_unix (object):
|
|||||||
raise TIMEOUT ('Timeout exceeded in expect_any().')
|
raise TIMEOUT ('Timeout exceeded in expect_any().')
|
||||||
# Still have time left, so read more data
|
# Still have time left, so read more data
|
||||||
c = self.read_nonblocking(self.maxread, timeout)
|
c = self.read_nonblocking(self.maxread, timeout)
|
||||||
# c = c.decode("utf-8")
|
|
||||||
freshlen = len(c)
|
freshlen = len(c)
|
||||||
time.sleep (0.0001)
|
time.sleep (0.0001)
|
||||||
incoming += c
|
incoming += c
|
||||||
@ -2843,7 +2841,7 @@ def join_args(args):
|
|||||||
commandline.append(arg)
|
commandline.append(arg)
|
||||||
return ' '.join(commandline)
|
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
|
"""This splits a command line into a list of arguments. It splits arguments
|
||||||
on spaces, but handles embedded quotes, doublequotes, and escaped
|
on spaces, but handles embedded quotes, doublequotes, and escaped
|
||||||
@ -2863,7 +2861,7 @@ def split_command_line(command_line):
|
|||||||
|
|
||||||
for c in command_line:
|
for c in command_line:
|
||||||
if state == state_basic or state == state_whitespace:
|
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
|
state = state_esc
|
||||||
elif c == r"'": # Handle single quote
|
elif c == r"'": # Handle single quote
|
||||||
state = state_singlequote
|
state = state_singlequote
|
||||||
|
Loading…
Reference in New Issue
Block a user