From b7a04a4616a8b8d70aa49039a973e372d12c4083 Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Tue, 12 Apr 2022 15:53:23 -0500 Subject: [PATCH] Return a namedtuple from subp() (#1376) Reference:https://github.com/canonical/cloud-init/commit/b7a04a4616a8b8d70aa49039a973e372d12c4083 Conflict:only add SubpResult This provides a minor readability improvement. subp.subp(cmd)[0] -> subp.subp(cmd).stdout subp.subp(cmd)[1] -> subp.subp(cmd).stderr --- cloudinit/subp.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cloudinit/subp.py b/cloudinit/subp.py index 024e1a9..267142e 100644 --- a/cloudinit/subp.py +++ b/cloudinit/subp.py @@ -1,6 +1,7 @@ # This file is part of cloud-init. See LICENSE file for license information. """Common utility functions for interacting with subprocess.""" +import collections import logging import os import subprocess @@ -9,6 +10,7 @@ from errno import ENOEXEC LOG = logging.getLogger(__name__) +SubpResult = collections.namedtuple("SubpResult", ["stdout", "stderr"]) def prepend_base_command(base_command, commands): """Ensure user-provided commands start with base_command; warn otherwise. -- 2.33.0