mirror of
https://github.com/ceph/ceph
synced 2025-01-03 01:22:53 +00:00
cephadm: annotate call()
yet another small step in order to increase testing coverage. Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
This commit is contained in:
parent
253968a2ba
commit
1a70b239d7
@ -50,7 +50,7 @@ import tempfile
|
||||
import time
|
||||
import errno
|
||||
try:
|
||||
from typing import Dict, List, Tuple, Optional, Union
|
||||
from typing import Dict, List, Tuple, Optional, Union, Any
|
||||
except ImportError:
|
||||
pass
|
||||
import uuid
|
||||
@ -70,7 +70,7 @@ if sys.version_info >= (3, 2):
|
||||
else:
|
||||
from ConfigParser import SafeConfigParser
|
||||
|
||||
container_path = None
|
||||
container_path = ''
|
||||
|
||||
class Error(Exception):
|
||||
pass
|
||||
@ -373,11 +373,11 @@ class FileLock(object):
|
||||
##################################
|
||||
# Popen wrappers, lifted from ceph-volume
|
||||
|
||||
def call(command,
|
||||
desc=None,
|
||||
verbose=False,
|
||||
verbose_on_failure=True,
|
||||
timeout=DEFAULT_TIMEOUT,
|
||||
def call(command, # type: List[str]
|
||||
desc=None, # type: Optional[str]
|
||||
verbose=False, # type: bool
|
||||
verbose_on_failure=True, # type: bool
|
||||
timeout=DEFAULT_TIMEOUT, # type: Optional[int]
|
||||
**kwargs):
|
||||
"""
|
||||
Wrap subprocess.Popen to
|
||||
@ -436,9 +436,11 @@ def call(command,
|
||||
)
|
||||
for fd in reads:
|
||||
try:
|
||||
message = os.read(fd, 1024)
|
||||
if not isinstance(message, str):
|
||||
message = message.decode('utf-8')
|
||||
message_b = os.read(fd, 1024)
|
||||
if isinstance(message_b, bytes):
|
||||
message = message_b.decode('utf-8')
|
||||
if isinstance(message_b, str):
|
||||
message = message_b
|
||||
if fd == process.stdout.fileno():
|
||||
out += message
|
||||
message = out_buffer + message
|
||||
@ -489,6 +491,7 @@ def call(command,
|
||||
|
||||
|
||||
def call_throws(command, **kwargs):
|
||||
# type: (List[str], Any) -> Tuple[str, str, int]
|
||||
out, err, ret = call(command, **kwargs)
|
||||
if ret:
|
||||
raise RuntimeError('Failed command: %s' % ' '.join(command))
|
||||
|
Loading…
Reference in New Issue
Block a user