From 1317daee5362e826fa88fe80bae2b47dca6b6415 Mon Sep 17 00:00:00 2001 From: Garth Minette Date: Tue, 16 Feb 2021 23:18:07 -0800 Subject: [PATCH] Bugfix for --camera. Added verbose mode. --- openscad_runner/__init__.py | 13 +++++++++++-- setup.py | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/openscad_runner/__init__.py b/openscad_runner/__init__.py index 3abc8f5..1f40b62 100755 --- a/openscad_runner/__init__.py +++ b/openscad_runner/__init__.py @@ -79,7 +79,8 @@ def __init__( customizer_file=None, customizer_params={}, hard_warnings=False, - quiet=False + quiet=False, + verbose=False ): """ Initializer method. Arguments are: @@ -107,6 +108,7 @@ def __init__( - customizer_params = An optional dictionary of customizer parameter names and values to set. - hard_warnings = Stop at first WARNING, as if it were an ERROR. Default: False - quiet = Suppresses non-error, non-warning messages. Default: False + - verbose = Print the command-line to stdout on each execution. Default: False """ if platform.system() == "Darwin": self.OPENSCAD = "/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD" @@ -136,6 +138,7 @@ def __init__( self.customizer_params = customizer_params self.hard_warnings = hard_warnings self.quiet = quiet + self.verbose = verbose self.cmdline = [] self.script = [] @@ -191,7 +194,7 @@ def run(self): if self.camera is not None: while len(self.camera) < 6: self.camera.append(0) - scadcmd.extend(["--camera", ",".join(self.camera)]) + scadcmd.extend(["--camera", ",".join(str(x) for x in self.camera)]) if self.color_scheme != ColorScheme.cornfield: scadcmd.extend(["--colorscheme", self.color_scheme]) if self.orthographic: @@ -227,6 +230,12 @@ def run(self): if self.quiet: scadcmd.append("--quiet") scadcmd.append(self.scriptfile) + if self.verbose: + line = " ".join([ + "'{}'".format(arg) if ' ' in arg or arg=='' else arg + for arg in scadcmd + ]) + print(line) p = subprocess.Popen(scadcmd, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) (stdoutdata, stderrdata) = p.communicate(None) stdoutdata = stdoutdata.decode('utf-8') diff --git a/setup.py b/setup.py index f8e9005..c083b11 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup -VERSION = "1.0.5" +VERSION = "1.0.6" with open('README.rst') as f: @@ -19,7 +19,7 @@ author='Revar Desmera', author_email='revarbat@gmail.com', url='https://github.com/revarbat/openscad_runner', - download_url='https://github.com/revarbat/openscad_runner/archive/v1.0.5.zip', + download_url='https://github.com/revarbat/openscad_runner/archive/v1.0.6.zip', packages=['openscad_runner'], license='MIT License', classifiers=[