summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/exception.py12
-rw-r--r--nova/process.py4
-rw-r--r--nova/utils.py17
3 files changed, 19 insertions, 14 deletions
diff --git a/nova/exception.py b/nova/exception.py
index 29bcb17f8..b8894758f 100644
--- a/nova/exception.py
+++ b/nova/exception.py
@@ -26,6 +26,18 @@ import sys
import traceback
+class ProcessExecutionError(IOError):
+ def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
+ description=None):
+ if description is None:
+ description = "Unexpected error while running command."
+ if exit_code is None:
+ exit_code = '-'
+ message = "%s\nCommand: %s\nExit code: %s\nStdout: %r\nStderr: %r" % (
+ description, cmd, exit_code, stdout, stderr)
+ IOError.__init__(self, message)
+
+
class Error(Exception):
def __init__(self, message=None):
super(Error, self).__init__(message)
diff --git a/nova/process.py b/nova/process.py
index c3b077dc2..5a5d8cbd2 100644
--- a/nova/process.py
+++ b/nova/process.py
@@ -29,7 +29,7 @@ from twisted.internet import protocol
from twisted.internet import reactor
from nova import flags
-from nova.utils import ProcessExecutionError
+from nova.exception import ProcessExecutionError
FLAGS = flags.FLAGS
flags.DEFINE_integer('process_pool_size', 4,
@@ -126,7 +126,7 @@ def get_process_output(executable, args=None, env=None, path=None,
deferred = defer.Deferred()
cmd = executable
if args:
- cmd = cmd + " " + ' '.join(args)
+ cmd = " ".join([cmd] + args)
process_handler = BackRelayWithInput(
deferred,
cmd,
diff --git a/nova/utils.py b/nova/utils.py
index b8abb5388..d302412ad 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -31,21 +31,12 @@ import sys
from nova import exception
from nova import flags
+from nova.exception import ProcessExecutionError
FLAGS = flags.FLAGS
TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
-class ProcessExecutionError(IOError):
- def __init__( self, stdout=None, stderr=None, exit_code=None, cmd=None,
- description=None):
- if description is None:
- description = "Unexpected error while running command."
- if exit_code is None:
- exit_code = '-'
- message = "%s\nCommand: %s\nExit code: %s\nStdout: %r\nStderr: %r" % (
- description, cmd, exit_code, stdout, stderr)
- IOError.__init__(self, message)
def import_class(import_str):
"""Returns a class from a string including module and class"""
@@ -118,8 +109,10 @@ def runthis(prompt, cmd, check_exit_code = True):
exit_code = subprocess.call(cmd.split(" "))
logging.debug(prompt % (exit_code))
if check_exit_code and exit_code <> 0:
- raise Exception( "Unexpected exit code: %s from cmd: %s"
- % (exit_code, cmd))
+ raise ProcessExecutionError(exit_code=exit_code,
+ stdout=None,
+ stderr=None,
+ cmd=cmd)
def generate_uid(topic, size=8):