Re: [PATCH 5/3] docs: sphinx/kfigure.py: Delegate inkscape msgs to kernellog

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 13 Dec 2021 18:50:51 -0800, Randy Dunlap wrote:
> 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

Now fixed.

        Thanks, Akira
> 
>> exit code.
>>
>> Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx>
>> Cc: Mauro Carvalho Chehab <mchehab@xxxxxxxxxx>
>> Cc: Jonathan Corbet <corbet@xxxxxxx>
>> ---
>> 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):
>>
> 



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux