Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't treat dot's output into stderr as error. check dot's return code #72

Closed
375gnu opened this issue Jun 29, 2013 · 2 comments
Closed
Milestone

Comments

@375gnu
Copy link

375gnu commented Jun 29, 2013

In my Debian Sid I've got the following:

/usr/lib/ruby/vendor_ruby/graphviz/utils.rb:76:in `output_from_command': Error from "/usr/bin/dot" -q1   -Tpng -ohello_world.png   /tmp/graphviz.rb20130629-29282-1uhwdt2: (RuntimeError)
Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 9: reading configurations from ~/.fonts.conf is deprecated.
  from /usr/lib/ruby/vendor_ruby/graphviz.rb:655:in `output'
  from tst.rb:15:in `<main>'

As you can see there is warning from fontconfig which you treat as dot's error. Please, don't do that, check return code first.

@375gnu
Copy link
Author

375gnu commented Jun 29, 2013

Possible patch which uses Open3.capture3 may look like

--- utils.rb.orig   2013-06-29 21:38:23.000000000 +0300
+++ utils.rb    2013-06-29 21:47:41.000000000 +0300
@@ -55,11 +55,8 @@
      end
    end
    begin
-     Open3.popen3( cmd ) do |stdin, stdout, stderr|
-       stdin.close
-       stdout.binmode
-       [stdout.read, stderr.read]
-     end
+     outstr, errstr, status = Open3.capture3( cmd )
+     [outstr, errstr, status.exitstatus]
    rescue NotImplementedError, NoMethodError
      IO.popen( cmd ) do |stdout|
        stdout.binmode
@@ -69,8 +66,8 @@
   end

   def output_from_command(cmd) #:nodoc:
-   output, errors = output_and_errors_from_command(cmd)
-   if errors.nil? || errors.strip.empty?
+   output, errors, exitstatus = output_and_errors_from_command(cmd)
+   if exitstatus.zero?
      output
    else
      raise "Error from #{cmd}:\n#{errors}"

@glejeune
Copy link
Owner

glejeune commented Jun 9, 2014

done

@glejeune glejeune closed this as completed Jun 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants