From 6f90daca7fd824e2ea34bdc52904a94337270c61 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Tue, 9 May 2017 15:49:39 +1000 Subject: [PATCH] Use check_output The await function is essentially a non-standard check_output call. Let's use standard calls to increase maintainability. Change-Id: I2c25e1cd7122791fcaa86b46bd801e661471bc9e --- .../tests/functional/test_blockdevice.py | 7 +++---- diskimage_builder/utils.py | 20 ------------------- 2 files changed, 3 insertions(+), 24 deletions(-) delete mode 100644 diskimage_builder/utils.py diff --git a/diskimage_builder/tests/functional/test_blockdevice.py b/diskimage_builder/tests/functional/test_blockdevice.py index 3bd1723fc..ed89f1263 100644 --- a/diskimage_builder/tests/functional/test_blockdevice.py +++ b/diskimage_builder/tests/functional/test_blockdevice.py @@ -12,12 +12,12 @@ import fixtures import logging +import subprocess import testtools from diskimage_builder import block_device from diskimage_builder.block_device.level0 import localloop from diskimage_builder.logging_config import setup -from diskimage_builder import utils as dib_utils # Setup Logging @@ -80,8 +80,7 @@ class TestBlockDevice(testtools.TestCase): lb_dev = bd.state['image0']['device'] # partprobe loopback so we can get partition info args = ['sudo', 'partprobe', lb_dev] - subp, rval = dib_utils.await_popen_cmd(logging, args) - self.assertEqual(0, rval) - + logging.info("Call: %s" % args) + subprocess.check_call(args) bd.cmd_cleanup() self._assert_loopbacks_cleaned(bd) diff --git a/diskimage_builder/utils.py b/diskimage_builder/utils.py deleted file mode 100644 index 87885a1ad..000000000 --- a/diskimage_builder/utils.py +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -import subprocess - - -def await_popen_cmd(logger, *args, **kwargs): - if logger is not None: - logger.debug("Running command: %s", args) - subproc = subprocess.Popen(*args, **kwargs) - return subproc, subproc.wait()