def _run_tool(self): '''runs the tool, returns a value in RunCode''' rv = RunCode.SUCCESS # parameter order matters! k must come first # use --verbose for verbose printing params = [self.tool_path, "-k", "0", self.model_path, "--verbose", "--visualize"] print "Calling dreach with params:", params if not run_check_stderr(params): rv = RunCode.ERROR return rv
def _run_tool(self): '''runs the tool, returns a value in RunCode''' rv = RunCode.SUCCESS # flowstar reads from stdin try: f = open(self.model_path, 'r') except IOError as e: print "Could not read from model file: " + self.model_path + " (" + e.strerror + ")" rv = RunCode.ERROR with f: # run through stdbuf to prevent flow* stdout i/o buffering if not run_check_stderr(["stdbuf", "-oL", self.tool_path], stdin=f): print "Error running flowstar tool" rv = RunCode.ERROR return rv
def _run_tool(self, image_requested): '''runs the tool, returns a value in RunCode''' rv = RunCode.SUCCESS # flowstar reads from stdin try: f = open(self.model_path, 'r') except IOError as e: print "Could not read from model file: " + self.model_path + " (" + e.strerror + ")" rv = RunCode.ERROR with f: # run through stdbuf to prevent flow* stdout i/o buffering if not run_check_stderr(["stdbuf", "-oL", self.tool_path], stdin=f): print "Error running flowstar tool" rv = RunCode.ERROR return rv
def _make_image(self): '''makes the image after the tool runs, returns True on success''' rv = True gnuplot_error = False print "Plotting with gnuplot..." try: exit_code = subprocess.call(["gnuplot", "outputs/out.plt"], stderr=subprocess.STDOUT) if exit_code != 0: print "Gnuplot had an error... probably no plot data because flow* exited prematurely" gnuplot_error = True # gnuplot error... probably no plot data except OSError as e: print "Exception while trying to run gnuplot: " + str(e) rv = False # run gimp to convert eps to png if rv and not gnuplot_error: print "Converting output using GIMP..." script_fu = '(gimp-file-load RUN-NONINTERACTIVE "images/out.eps" "images/out.eps")' script_fu += '(gimp-image-rotate 1 ROTATE-90)' script_fu += '(gimp-file-save RUN-NONINTERACTIVE 1 (car (gimp-image-get-active-layer 1)) "' \ + self.image_path + '" "' + self.image_path + '")' script_fu += '(gimp-quit TRUE)' exit_script_fu = '(gimp-quit TRUE)' # this is done separately in case the first part errors # gimp -i -b <script> params = ["gimp", "-i", "-b", script_fu, "-b", exit_script_fu] # ignore internal warnings -- some GIMP versions always output some warnings, e.g.: # (gimp:16102): GLib-GObject-WARNING **: g_object_set_valist: object class 'GeglConfig' has no property named 'cache-size' stderr_ignore_regexp='.*WARNING \*\*:' if not run_check_stderr(params, stdin=None, stderr_ignore_regexp=stderr_ignore_regexp): print "Gimp errored" rv = False return rv
def _make_image(self): '''makes the image after the tool runs, returns True on success''' rv = True print "Plotting with gnuplot..." try: exit_code = subprocess.call(["gnuplot", "outputs/out.plt"]) if exit_code != 0: print "Gnuplot errored; exit code: " + str(exit_code) rv = False except OSError as e: print "Exception while trying to run gnuplot: " + str(e) rv = False # run gimp to convert eps to png if rv: print "Converting output using GIMP..." script_fu = '(gimp-file-load RUN-NONINTERACTIVE "images/out.eps" "images/out.eps")' script_fu += '(gimp-image-rotate 1 ROTATE-90)' script_fu += '(gimp-file-save RUN-NONINTERACTIVE 1 (car (gimp-image-get-active-layer 1)) "' \ + self.image_path + '" "' + self.image_path + '")' script_fu += '(gimp-quit TRUE)' exit_script_fu = '(gimp-quit TRUE)' # this is done separately in case the first part errors # gimp -i -b <script> params = ["gimp", "-i", "-b", script_fu, "-b", exit_script_fu] if not run_check_stderr(params): print "Gimp errored" rv = False return rv