You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/11/15 14:14:12 UTC
[3/3] git commit: cli: Handle HTTP and URL errors
cli: Handle HTTP and URL errors
Signed-off-by: Rohit Yadav <bh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/08d16cf4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/08d16cf4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/08d16cf4
Branch: refs/heads/master
Commit: 08d16cf4d196531821e897a291a1078982231be9
Parents: 4c86b15
Author: Rohit Yadav <bh...@apache.org>
Authored: Thu Nov 15 18:43:28 2012 +0530
Committer: Rohit Yadav <bh...@apache.org>
Committed: Thu Nov 15 18:43:51 2012 +0530
----------------------------------------------------------------------
tools/cli/cloudmonkey/cloudmonkey.py | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/08d16cf4/tools/cli/cloudmonkey/cloudmonkey.py
----------------------------------------------------------------------
diff --git a/tools/cli/cloudmonkey/cloudmonkey.py b/tools/cli/cloudmonkey/cloudmonkey.py
index 4ba6dbf..185ad4e 100644
--- a/tools/cli/cloudmonkey/cloudmonkey.py
+++ b/tools/cli/cloudmonkey/cloudmonkey.py
@@ -31,6 +31,7 @@ try:
from clint.textui import colored
from ConfigParser import ConfigParser, SafeConfigParser
+ from urllib2 import HTTPError, URLError
from version import __version__
from marvin.cloudstackConnection import cloudConnection
@@ -138,6 +139,7 @@ class CloudStackShell(cmd.Cmd):
def print_shell(self, *args):
try:
for arg in args:
+ arg = str(arg)
if isinstance(type(args), types.NoneType):
continue
if self.color == 'true':
@@ -208,10 +210,13 @@ class CloudStackShell(cmd.Cmd):
logging=logging.getLogger("cloudConnection"))
try:
response = conn.make_request(command, requests)
+ return response
except cloudstackAPIException, e:
- self.print_shell("API Error", e)
- return None
- return response
+ self.print_shell("API Error:", e)
+ except HTTPError, e:
+ self.print_shell(e)
+ except URLError, e:
+ self.print_shell("Connection Error:", e)
def get_api_module(self, api_name, api_class_strs=[]):
try: