Hi Tomasz, On Fri, Jan 29, 2021 at 12:38:08PM +0100, Tomasz Dziendzielski wrote: > If a function returns any stderr it will be passed to extractPatches and > used as path to patch. > > For example subprocess command output can be: > | sh: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) > | /tmp/oepatchhuqle8fj/0001-foo.patch > | /tmp/oepatchhuqle8fj/0002-bar.patch > > that will result in: > | FileNotFoundError: [Errno 2] No such file or directory: 'sh:' > > To fix this I separated output, made the function return stdout and > print stderr only in case of command error. > > Signed-off-by: Tomasz Dziendzielski <[email protected]> > --- > meta/lib/oe/patch.py | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py > index 40755fbb03..8ad70f53f1 100644 > --- a/meta/lib/oe/patch.py > +++ b/meta/lib/oe/patch.py > @@ -38,15 +38,19 @@ def runcmd(args, dir = None): > args = [ pipes.quote(str(arg)) for arg in args ] > cmd = " ".join(args) > # print("cmd: %s" % cmd) > - (exitstatus, output) = subprocess.getstatusoutput(cmd) > + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, > stderr=subprocess.PIPE, shell=True)
I'd rather avoid having shell=True passed to Popen, read https://docs.python.org/3/library/subprocess.html#security-considerations Can't we just use args directly instead of cmd in Popen to avoid using shell=True? Cheers, Quentin
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#147448): https://lists.openembedded.org/g/openembedded-core/message/147448 Mute This Topic: https://lists.openembedded.org/mt/80207407/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
