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
This commit is contained in:
parent
59a1fc6546
commit
6f90daca7f
@ -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)
|
||||
|
@ -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()
|
Loading…
Reference in New Issue
Block a user