package_manager/ipk: do not pipe stderr to stdout

Message ID 20220628201152.25066-1-shruthi.ravichandran@ni.com
State New
Headers show
Series package_manager/ipk: do not pipe stderr to stdout | expand

Commit Message

Shruthi Ravichandran June 28, 2022, 8:11 p.m. UTC
When parsing the output of a command, do not pipe stderr to stdout.
Opkg sometimes prints harmless error messages even when the opkg
command succeeds. When stderr is piped to stdout, these error
messages may clobber the stdout and cause unexpected results while
parsing the output.

Signed-off-by: Shruthi Ravichandran <shruthi.ravichandran@ni.com>
---
 meta/lib/oe/package_manager/ipk/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexander Kanavin June 28, 2022, 8:33 p.m. UTC | #1
This needs additional justification. What are the error messages, why are
they harmless and why the solution is to suppress them instead of
addressing the reasons they appear?

Alex

On Tue 28. Jun 2022 at 23.13, Shruthi Ravichandran <
shruthi.ravichandran@ni.com> wrote:

> When parsing the output of a command, do not pipe stderr to stdout.
> Opkg sometimes prints harmless error messages even when the opkg
> command succeeds. When stderr is piped to stdout, these error
> messages may clobber the stdout and cause unexpected results while
> parsing the output.
>
> Signed-off-by: Shruthi Ravichandran <shruthi.ravichandran@ni.com>
> ---
>  meta/lib/oe/package_manager/ipk/__init__.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta/lib/oe/package_manager/ipk/__init__.py
> b/meta/lib/oe/package_manager/ipk/__init__.py
> index 4cd3963111..d7f3f31853 100644
> --- a/meta/lib/oe/package_manager/ipk/__init__.py
> +++ b/meta/lib/oe/package_manager/ipk/__init__.py
> @@ -103,7 +103,7 @@ class OpkgDpkgPM(PackageManager):
>          """
>
>          try:
> -            output = subprocess.check_output(cmd,
> stderr=subprocess.STDOUT, shell=True).decode("utf-8")
> +            output = subprocess.check_output(cmd,
> shell=True).decode("utf-8")
>          except subprocess.CalledProcessError as e:
>              bb.fatal("Unable to list available packages. Command '%s' "
>                       "returned %d:\n%s" % (cmd, e.returncode,
> e.output.decode("utf-8")))
> --
> 2.20.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#167354):
> https://lists.openembedded.org/g/openembedded-core/message/167354
> Mute This Topic: https://lists.openembedded.org/mt/92051989/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>

Patch

diff --git a/meta/lib/oe/package_manager/ipk/__init__.py b/meta/lib/oe/package_manager/ipk/__init__.py
index 4cd3963111..d7f3f31853 100644
--- a/meta/lib/oe/package_manager/ipk/__init__.py
+++ b/meta/lib/oe/package_manager/ipk/__init__.py
@@ -103,7 +103,7 @@  class OpkgDpkgPM(PackageManager):
         """
 
         try:
-            output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True).decode("utf-8")
+            output = subprocess.check_output(cmd, shell=True).decode("utf-8")
         except subprocess.CalledProcessError as e:
             bb.fatal("Unable to list available packages. Command '%s' "
                      "returned %d:\n%s" % (cmd, e.returncode, e.output.decode("utf-8")))