How to use the sarge.__version__ function in sarge

To help you get started, we’ve selected a few sarge examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eyal0 / OctoPrint-PrintTimeGenius / octoprint_PrintTimeGenius / __init__.py View on Github external
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)

sarge

A wrapper for subprocess which provides command pipeline functionality.

BSD-2-Clause
Latest version published 3 years ago

Package Health Score

49 / 100
Full package analysis