summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
diff options
context:
space:
mode:
authorSoren Hansen <soren.hansen@rackspace.com>2010-09-22 13:26:36 +0200
committerSoren Hansen <soren.hansen@rackspace.com>2010-09-22 13:26:36 +0200
commitd42e168763d232476407a07b79056fb745c6075e (patch)
tree25e98655b2fcf9a05ecc832ee17e0c1d9e7f2221 /nova/utils.py
parent28336ed41e0d44d7600588a6014f6253e4b87a42 (diff)
parent4e727faf450154d89687b1a33dae2159d5b691a0 (diff)
downloadnova-d42e168763d232476407a07b79056fb745c6075e.tar.gz
nova-d42e168763d232476407a07b79056fb745c6075e.tar.xz
nova-d42e168763d232476407a07b79056fb745c6075e.zip
Merge trunk
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py18
1 files changed, 5 insertions, 13 deletions
diff --git a/nova/utils.py b/nova/utils.py
index 011a5cb09..d18dd9843 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -33,22 +33,12 @@ from twisted.internet.threads import deferToThread
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"""
mod_str, _sep, class_str = import_str.rpartition('.')
@@ -129,8 +119,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):