summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-09-20 19:17:36 -0700
committerVishvananda Ishaya <vishvananda@yahoo.com>2010-09-20 19:17:36 -0700
commit026f6f2b7f5457f15a258ebed66bb8dda3263eec (patch)
tree146dcfe5e69bd4c7bea76e46fa97fbeb39828581 /nova/utils.py
parentc791229d11e3baf2a5828ee8efe98ed827a35dde (diff)
parentd8861d04a85044ae57ffd7eb9ab682879beecf7d (diff)
downloadnova-026f6f2b7f5457f15a258ebed66bb8dda3263eec.tar.gz
nova-026f6f2b7f5457f15a258ebed66bb8dda3263eec.tar.xz
nova-026f6f2b7f5457f15a258ebed66bb8dda3263eec.zip
merged 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):