Just a couple of minor adjustments
@@ -134,7 +134,8 @@ class Common(object):
""" Run command, capture the output """
# Create the process
process = subprocess.Popen(
- command, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=shell)
+ command, cwd=cwd, shell=shell,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
descriptors = [process.stdout.fileno(), process.stderr.fileno()]
stdout = ''
stderr = ''
@@ -169,8 +170,9 @@ class Common(object):
# Handle the exit code, return output
if process.returncode != 0:
- raise subprocess.CalledProcessError(
- process.returncode, ' '.join(command) if isinstance(command, list) else command)
+ if isinstance(command, list):
+ command = ' '.join(command)
+ raise subprocess.CalledProcessError(process.returncode, command)
return stdout, stderr
def run(self, command, message=None, cwd=None, dry=False, shell=True):
@@ -183,8 +185,8 @@ class Common(object):
"""
# Use a generic message if none given, prepare error message
if not message:
- message = "Run command '{}'.".format(
- ' '.join(command) if isinstance(command, list) else command)
+ line = ' '.join(command) if isinstance(command, list) else command
+ message = f"Run command '{line}'."
self.debug(message)
message = "Failed to " + message[0].lower() + message[1:]
