From: Randy Dunlap <rdunlap@infradead.org>
To: Akira Yokosawa <akiyks@gmail.com>,
Jonathan Corbet <corbet@lwn.net>,
Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/3] docs: sphinx/kfigure.py: Delegate inkscape msgs to kernellog
Date: Mon, 13 Dec 2021 18:50:51 -0800 [thread overview]
Message-ID: <623bad19-49e5-ee34-910c-f3caf39319f5@infradead.org> (raw)
In-Reply-To: <ea41dd96-124a-9132-7659-1ae04d82188b@gmail.com>
On 12/13/21 18:34, Akira Yokosawa wrote:
> Instead of redirecting to /dev/null, capture inkscape messages and
> output them via kernelloc.verbose or kerneldoc.warn depending on the
kernellog.verbose or kernellog.warn
> exit code.
>
> Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
> Cc: Jonathan Corbet <corbet@lwn.net>
> ---
> Hi Mauro,
>
> On second thought, I took the path of delegating inkscape warnings
> to kernellog.
>
> Now you can see those warning messages by "SPHINXOPTS=-v".
>
> Does this approach sound reasonable to you?
>
> Thanks, Akira
> --
> Documentation/sphinx/kfigure.py | 28 +++++++++++++---------------
> 1 file changed, 13 insertions(+), 15 deletions(-)
>
> diff --git a/Documentation/sphinx/kfigure.py b/Documentation/sphinx/kfigure.py
> index dbe75ee8ae61..a275ee0fec02 100644
> --- a/Documentation/sphinx/kfigure.py
> +++ b/Documentation/sphinx/kfigure.py
> @@ -126,9 +126,6 @@ rsvg_convert_cmd = None
> inkscape_cmd = None
> # Inkscape prior to 1.0 uses different command options
> inkscape_ver_one = False
> -# Show warning from inkscape(1), enabled by setting env var
> -# SPHINX_SHOW_INKSCAPE_WARN
> -inkscape_show_warn = False
>
>
> def setup(app):
> @@ -178,7 +175,7 @@ def setupTools(app):
> This function is called once, when the builder is initiated.
> """
> global dot_cmd, dot_Tpdf, convert_cmd, rsvg_convert_cmd # pylint: disable=W0603
> - global inkscape_cmd, inkscape_ver_one, inkscape_show_warn # pylint: disable=W0603
> + global inkscape_cmd, inkscape_ver_one # pylint: disable=W0603
> kernellog.verbose(app, "kfigure: check installed tools ...")
>
> dot_cmd = which('dot')
> @@ -211,12 +208,6 @@ def setupTools(app):
> rsvg_convert_cmd = None
> dot_Tpdf = False
>
> - try:
> - if os.environ['SPHINX_SHOW_INKSCAPE_WARN']:
> - inkscape_show_warn = True
> - except KeyError:
> - pass
> -
> else:
> if convert_cmd:
> kernellog.verbose(app, "use convert(1) from: " + convert_cmd)
> @@ -384,14 +375,21 @@ def svg2pdf(app, svg_fname, pdf_fname):
> else:
> cmd = [inkscape_cmd, '-z', '--export-pdf=%s' % pdf_fname, svg_fname]
>
> - # use stdout and stderr from parent
> - if inkscape_show_warn:
> - exit_code = subprocess.call(cmd)
> - else:
> - exit_code = subprocess.call(cmd, stderr=subprocess.DEVNULL)
> + try:
> + warning_msg = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
> + exit_code = 0
> + except subprocess.CalledProcessError as err:
> + warning_msg = err.output
> + exit_code = 1
> + pass
>
> if exit_code != 0:
> kernellog.warn(app, "Error #%d when calling: %s" % (exit_code, " ".join(cmd)))
> + kernellog.warn(app, "Warning msg from inkscape: %s" % str(warning_msg, 'utf-8'))
> + if warning_msg:
> + kernellog.verbose(app, "Warning msg from inkscape (likely harmless):\n%s"
> + % str(warning_msg, 'utf-8'))
> +
> return bool(exit_code == 0)
>
> def svg2pdf_by_rsvg(app, svg_fname, pdf_fname):
>
--
~Randy
next prev parent reply other threads:[~2021-12-14 2:51 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-12 7:59 [PATCH 0/3] docs: sphinx/kfigure.py: Improve conversion to PDF Akira Yokosawa
2021-12-12 8:01 ` [PATCH 1/3] docs: sphinx/kfigure.py: Use rsvg-convert(1) for DOT -> PDF conversion Akira Yokosawa
2021-12-12 8:02 ` [PATCH 2/3] docs: sphinx/kfigure.py: Use inkscape(1) for SVG " Akira Yokosawa
2021-12-12 8:03 ` [PATCH 3/3] docs: sphinx/kfigure.py: Redirect warnings from inkscape to /dev/null Akira Yokosawa
2021-12-12 10:38 ` [PATCH 0/3] docs: sphinx/kfigure.py: Improve conversion to PDF Mauro Carvalho Chehab
2021-12-12 11:57 ` Akira Yokosawa
2021-12-13 6:33 ` Mauro Carvalho Chehab
2021-12-13 7:53 ` Akira Yokosawa
2021-12-29 12:54 ` Status of selection.svg update (was Re: [PATCH 0/3] docs: sphinx/kfigure.py: Improve conversion to PDF) Akira Yokosawa
2021-12-29 22:14 ` Mauro Carvalho Chehab
2021-12-30 2:09 ` Akira Yokosawa
2021-12-13 14:36 ` [PATCH 4/3] docs: sphinx/kfigure.py: Add check of 'dot -Tpdf' Akira Yokosawa
2021-12-14 2:34 ` [PATCH 5/3] docs: sphinx/kfigure.py: Delegate inkscape msgs to kernellog Akira Yokosawa
2021-12-14 2:50 ` Randy Dunlap [this message]
2021-12-14 3:14 ` Akira Yokosawa
2021-12-23 19:56 ` [PATCH 0/3] docs: sphinx/kfigure.py: Improve conversion to PDF Jonathan Corbet
2021-12-23 21:52 ` Akira Yokosawa
2021-12-23 23:48 ` Jonathan Corbet
2021-12-24 1:53 ` Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=623bad19-49e5-ee34-910c-f3caf39319f5@infradead.org \
--to=rdunlap@infradead.org \
--cc=akiyks@gmail.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).