Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
except AnalysisAborted as e:
logger.info("Probably starting printing, aborting built-in analysis.")
raise # Reraise it
logger.info("Result: {}".format(results))
self._finished_callback(self._current, results)
else:
logger.info("Not running built-in analysis.")
for analyzer in self._plugin._settings.get(["analyzers"]):
command = analyzer["command"].format(gcode=self._current.absolute_path, mcodes=self._plugin.get_printer_config())
if not analyzer["enabled"]:
logger.info("Disabled: {}".format(command))
continue
logger.info("Running: {}".format(command))
results_err = ""
try:
if parse_version(sarge.__version__) >= parse_version('0.1.5'):
# Because in version 0.1.5 the name was changed in sarge.
async_kwarg = 'async_'
else:
async_kwarg = 'async'
sarge_job = sarge.capture_both(command, **{async_kwarg: True})
# Wait for sarge to begin
while not sarge_job.processes or not sarge_job.processes[0]:
time.sleep(0.5)
try:
process = psutil.Process(sarge_job.processes[0].pid)
for p in [process] + process.children(recursive=True):
try:
if "IDLE_PRIORITY_CLASS" in dir(psutil):
p.nice(psutil.IDLE_PRIORITY_CLASS)
else:
p.nice(19)