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

Hotfix: enclose executable paths in quotes #366

Merged
merged 6 commits into from
Feb 24, 2024
Merged
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
15 changes: 14 additions & 1 deletion Render/renderers/Appleseed.py
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,18 @@ def set_denoiser(root):
)
return root

def enclose_rpath(rpath):
"""Enclose rpath in quotes, if needed."""
if not rpath:
return ""
if rpath[0] == rpath[-1] == '"':
# Already enclosed (double quotes)
return rpath
if rpath[0] == rpath[-1] == "'":
# Already enclosed (simple quotes)
return rpath
return f'"{rpath}"'

# Here starts render

# Make various adjustments on file:
Expand Down Expand Up @@ -1466,7 +1478,7 @@ def set_denoiser(root):
with open(input_file, "wb") as f:
f.write(template)

# Prepare command line parameters
# Prepare command line parameters and rpath
params = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Render")
if not batch:
# GUI
Expand All @@ -1489,6 +1501,7 @@ def set_denoiser(root):
"Edit -> Preferences -> Render\n"
)
return None, None
rpath = enclose_rpath(rpath)
if args:
args += " "

Expand Down
14 changes: 14 additions & 0 deletions Render/renderers/Cycles.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,19 @@ def render(
The command to run renderer (string)
A path to output image file (string)
"""

def enclose_rpath(rpath):
"""Enclose rpath in quotes, if needed."""
if not rpath:
return ""
if rpath[0] == rpath[-1] == '"':
# Already enclosed (double quotes)
return rpath
if rpath[0] == rpath[-1] == "'":
# Already enclosed (simple quotes)
return rpath
return f'"{rpath}"'

# Denoise
if denoise:
tree = et.parse(input_file)
Expand Down Expand Up @@ -984,6 +997,7 @@ def render(
"Edit -> Preferences -> Render\n"
)
return None, None
rpath = enclose_rpath(rpath)
args += " --width " + str(width)
args += " --height " + str(height)
filepath = f'"{input_file}"'
Expand Down
15 changes: 14 additions & 1 deletion Render/renderers/Luxcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,18 @@ def export_section(section, prefix, suffix):
output.write("\n".join(result))
return f_path

def enclose_rpath(rpath):
"""Enclose rpath in quotes, if needed."""
if not rpath:
return ""
if rpath[0] == rpath[-1] == '"':
# Already enclosed (double quotes)
return rpath
if rpath[0] == rpath[-1] == "'":
# Already enclosed (simple quotes)
return rpath
return f'"{rpath}"'

# LuxCore requires 2 files:
# - a configuration file, with rendering parameters (engine, sampler...)
# - a scene file, with the scene objects (camera, lights, meshes...)
Expand Down Expand Up @@ -735,7 +747,7 @@ def export_section(section, prefix, suffix):
scene = pageresult["Scene"]
scn_path = export_section(scene, project.Name, "scn")

# Get rendering parameters
# Get rendering parameters and rpath
params = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Render")
args = params.GetString("LuxCoreParameters", "")
rpath = params.GetString(
Expand All @@ -748,6 +760,7 @@ def export_section(section, prefix, suffix):
)
App.Console.PrintError(msg)
return None, None
rpath = enclose_rpath(rpath)

# Prepare command line and return
cmd = f"""{prefix}{rpath} {args} -o "{cfg_path}" -f "{scn_path}"\n"""
Expand Down
14 changes: 14 additions & 0 deletions Render/renderers/Ospray.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,19 @@ def render(
The command to run renderer (string)
A path to output image file (string)
"""

def enclose_rpath(rpath):
"""Enclose rpath in quotes, if needed."""
if not rpath:
return ""
if rpath[0] == rpath[-1] == '"':
# Already enclosed (double quotes)
return rpath
if rpath[0] == rpath[-1] == "'":
# Already enclosed (simple quotes)
return rpath
return f'"{rpath}"'

# Read scene_graph (json)
with open(input_file, "r", encoding="utf8") as f:
scene_graph = json.load(f)
Expand Down Expand Up @@ -1107,6 +1120,7 @@ def render(
"Edit -> Preferences -> Render\n"
)
return None, None
rpath = enclose_rpath(rpath)

cmd = prefix + rpath + " " + args + " " + f'"{input_file}"'

Expand Down
14 changes: 14 additions & 0 deletions Render/renderers/Pbrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,19 @@ def render(
The command to run renderer (string)
A path to output image file (string)
"""

def enclose_rpath(rpath):
"""Enclose rpath in quotes, if needed."""
if not rpath:
return ""
if rpath[0] == rpath[-1] == '"':
# Already enclosed (double quotes)
return rpath
if rpath[0] == rpath[-1] == "'":
# Already enclosed (simple quotes)
return rpath
return f'"{rpath}"'

# Make various adjustments on file:
# Reorder camera declarations and set width/height
with open(input_file, "r", encoding="utf-8") as f:
Expand Down Expand Up @@ -703,6 +716,7 @@ def render(
"Edit -> Preferences -> Render\n"
)
return None, None
rpath = enclose_rpath(rpath)

filepath = f'"{input_file}"'

Expand Down
14 changes: 14 additions & 0 deletions Render/renderers/Povray.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,19 @@ def render(
The command to run renderer (string)
A path to output image file (string)
"""

def enclose_rpath(rpath):
"""Enclose rpath in quotes, if needed."""
if not rpath:
return ""
if rpath[0] == rpath[-1] == '"':
# Already enclosed (double quotes)
return rpath
if rpath[0] == rpath[-1] == "'":
# Already enclosed (simple quotes)
return rpath
return f'"{rpath}"'

params = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Render")

prefix = params.GetString("Prefix", "")
Expand All @@ -845,6 +858,7 @@ def render(
"Edit -> Preferences -> Render\n"
)
return None, None
rpath = enclose_rpath(rpath)

# Prepare command line parameters
args = params.GetString("PovRayParameters", "")
Expand Down
Loading