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

Fix Snap launch of OpenSCAD #7182

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 30 additions & 6 deletions src/Mod/OpenSCAD/OpenSCADUtils.py
Expand Up @@ -142,12 +142,31 @@ def getopenscadversion(osfilename=None):
"User parameter:BaseApp/Preferences/Mod/OpenSCAD").\
GetString('openscadexecutable')
if osfilename and os.path.isfile(osfilename):
with subprocess.Popen([osfilename, '-v'],\
stdout = subprocess.PIPE,stderr=subprocess.PIPE, universal_newlines=True) as p:
env = os.environ.copy()
try:
env.pop('LD_LIBRARY_PATH')
except KeyError:
None
def check_output2(*args, **kwargs):
env = os.environ.copy()
try:
env.pop('LD_LIBRARY_PATH')
except KeyError:
None
Comment on lines +145 to +155
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't line 151-155 duplicate of 146-150? The commands are already run once?

kwargs.update({'stdout':subprocess.PIPE,'stderr':subprocess.PIPE,'env':env})
p = subprocess.Popen(*args, **kwargs)
p.wait()
stdout = p.stdout.read().strip()
stderr = p.stderr.read().strip()
return (stdout or stderr)
stdoutd = p.stdout.read().decode("utf8")
stderrd = p.stderr.read().decode("utf8")
if p.returncode != 0:
raise OpenSCADError('%s %s\n' % (stdoutd.strip(),stderrd.strip()))
#raise Exception,'stdout %s\n stderr%s' %(stdoutd,stderrd)
if stderrd.strip():
FreeCAD.Console.PrintWarning(stderrd+u'\n')
if stdoutd.strip():
FreeCAD.Console.PrintMessage(stdoutd+u'\n')
return (stdoutd or stderrd)
return check_output2([osfilename, '-v'])


def newtempfilename():
Expand All @@ -173,7 +192,12 @@ def callopenscad(inputfilename,outputfilename=None, outputext='csg', keepname=Fa
import time

def check_output2(*args, **kwargs):
kwargs.update({'stdout':subprocess.PIPE,'stderr':subprocess.PIPE})
env = os.environ.copy()
try:
env.pop('LD_LIBRARY_PATH')
except KeyError:
None
kwargs.update({'stdout':subprocess.PIPE,'stderr':subprocess.PIPE,'env':env})
p = subprocess.Popen(*args, **kwargs)
stdoutd, stderrd = p.communicate()
stdoutd = stdoutd.decode("utf8")
Expand Down