Properly handle exceptions other than a non-zero return code for slicing and timelapse rendering
Closes #508
This commit is contained in:
parent
f6e2a59008
commit
be99c59725
2 changed files with 25 additions and 14 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import sarge
|
||||
|
||||
__author__ = "Ross Hendrickson savorywatt"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
|
|
@ -49,14 +51,19 @@ class Cura(object):
|
|||
import threading
|
||||
|
||||
def start_thread(call_back, call_back_args, call_args, cwd):
|
||||
import subprocess
|
||||
self._logger.info("Running %r in %s" % (call_args, cwd))
|
||||
command = " ".join(call_args)
|
||||
try:
|
||||
subprocess.check_call(call_args, cwd=cwd)
|
||||
call_back(*call_back_args)
|
||||
except subprocess.CalledProcessError as (e):
|
||||
self._logger.warn("Could not slice via Cura, got return code %r" % e.returncode)
|
||||
call_back_args.append("Got returncode %r" % e.returncode)
|
||||
p = sarge.run(command, cwd=cwd)
|
||||
if p.returncode == 0:
|
||||
call_back(*call_back_args)
|
||||
else:
|
||||
self._logger.warn("Could not slice via Cura, got return code %r" % p.returncode)
|
||||
call_back_args.append("Got returncode %r" % p.returncode)
|
||||
call_back(*call_back_args)
|
||||
except:
|
||||
self._logger.exception("Could not slice via Cura, got an unknown error")
|
||||
call_back_args.append("Unknown error, please consult the log file")
|
||||
call_back(*call_back_args)
|
||||
|
||||
executable = self.cura_path
|
||||
|
|
|
|||
|
|
@ -305,14 +305,18 @@ class Timelapse(object):
|
|||
command_str = " ".join(command)
|
||||
self._logger.debug("Executing command: %s" % command_str)
|
||||
|
||||
p = sarge.run(command_str, stderr=sarge.Capture())
|
||||
if p.returncode == 0:
|
||||
eventManager().fire(Events.MOVIE_DONE, {"gcode": self._gcodeFile, "movie": output, "movie_basename": os.path.basename(output)})
|
||||
else:
|
||||
returncode = p.returncode
|
||||
stderr_text = p.stderr.text
|
||||
self._logger.warn("Could not render movie, got return code %r: %s" % (returncode, stderr_text))
|
||||
eventManager().fire(Events.MOVIE_FAILED, {"gcode": self._gcodeFile, "movie": output, "movie_basename": os.path.basename(output), "returncode": returncode, "error": stderr_text})
|
||||
try:
|
||||
p = sarge.run(command_str, stderr=sarge.Capture())
|
||||
if p.returncode == 0:
|
||||
eventManager().fire(Events.MOVIE_DONE, {"gcode": self._gcodeFile, "movie": output, "movie_basename": os.path.basename(output)})
|
||||
else:
|
||||
returncode = p.returncode
|
||||
stderr_text = p.stderr.text
|
||||
self._logger.warn("Could not render movie, got return code %r: %s" % (returncode, stderr_text))
|
||||
eventManager().fire(Events.MOVIE_FAILED, {"gcode": self._gcodeFile, "movie": output, "movie_basename": os.path.basename(output), "returncode": returncode, "error": stderr_text})
|
||||
except:
|
||||
self._logger.exception("Could not render movie due to unknown error")
|
||||
eventManager().fire(Events.MOVIE_FAILED, {"gcode": self._gcodeFile, "movie": output, "movie_basename": os.path.basename(output), "returncode": 255, "error": "Unknown error"})
|
||||
|
||||
def cleanCaptureDir(self):
|
||||
if not os.path.isdir(self._captureDir):
|
||||
|
|
|
|||
Loading…
Reference in a new issue