Fix a Recorder bug caused by Python PATH whitespace

This commit is contained in:
Michael Mintz 2023-11-27 20:53:08 -05:00
parent 7d9d5c5203
commit d859281265
2 changed files with 16 additions and 9 deletions

View File

@ -99,6 +99,10 @@ def main():
force_gui = False
rec_behave = False
sys_executable = sys.executable
if " " in sys_executable:
sys_executable = "python"
if "linux" in sys.platform:
use_colors = False
c0, c1, c2, c5, c7, cr = set_colors(use_colors)
@ -189,18 +193,18 @@ def main():
print(success)
run_cmd = None
if not start_page:
run_cmd = "%s -m pytest %s --rec -q -s" % (sys.executable, file_name)
run_cmd = "%s -m pytest %s --rec -q -s" % (sys_executable, file_name)
else:
run_cmd = "%s -m pytest %s --rec -q -s --url=%s" % (
sys.executable, file_name, start_page
sys_executable, file_name, start_page
)
if '"' not in start_page:
run_cmd = '%s -m pytest %s --rec -q -s --url="%s"' % (
sys.executable, file_name, start_page
sys_executable, file_name, start_page
)
elif "'" not in start_page:
run_cmd = "%s -m pytest %s --rec -q -s --url='%s'" % (
sys.executable, file_name, start_page
sys_executable, file_name, start_page
)
if use_edge:
run_cmd += " --edge"
@ -217,7 +221,7 @@ def main():
recorded_filename = file_name[:-3] + "_rec.py"
recordings_dir = os.path.join(dir_name, "recordings")
recorded_file = os.path.join(recordings_dir, recorded_filename)
prefix = "%s -m " % sys.executable
prefix = "%s -m " % sys_executable
if " " not in recorded_file:
os.system("%sseleniumbase print %s -n" % (prefix, recorded_file))
elif '"' not in recorded_file:

View File

@ -24,6 +24,9 @@ from seleniumbase.fixtures import shared_utils
sb_config.rec_subprocess_p = None
sb_config.rec_subprocess_used = False
sys_executable = sys.executable
if " " in sys_executable:
sys_executable = "python"
if sys.version_info <= (3, 7):
current_version = ".".join(str(ver) for ver in sys.version_info[:3])
raise Exception(
@ -139,17 +142,17 @@ def do_recording(file_name, url, overwrite_enabled, use_chrome, window):
add_on = " --rec-behave"
command = (
"%s -m seleniumbase mkrec %s --url=%s --gui"
% (sys.executable, file_name, url)
% (sys_executable, file_name, url)
)
if '"' not in url:
command = (
'%s -m seleniumbase mkrec %s --url="%s" --gui'
% (sys.executable, file_name, url)
% (sys_executable, file_name, url)
)
elif "'" not in url:
command = (
"%s -m seleniumbase mkrec %s --url='%s' --gui"
% (sys.executable, file_name, url)
% (sys_executable, file_name, url)
)
if not use_chrome:
command += " --edge"
@ -185,7 +188,7 @@ def do_playback(file_name, use_chrome, window, demo_mode=False):
'File "%s" does not exist in the current directory!' % file_name,
)
return
command = "%s -m pytest %s -q -s" % (sys.executable, file_name)
command = "%s -m pytest %s -q -s" % (sys_executable, file_name)
if shared_utils.is_linux():
command += " --gui"
if not use_chrome: