Return-Path: X-Original-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9C131D051 for ; Wed, 31 Oct 2012 17:50:17 +0000 (UTC) Received: (qmail 97788 invoked by uid 500); 31 Oct 2012 17:50:17 -0000 Delivered-To: apmail-incubator-cloudstack-commits-archive@incubator.apache.org Received: (qmail 97372 invoked by uid 500); 31 Oct 2012 17:50:16 -0000 Mailing-List: contact cloudstack-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cloudstack-dev@incubator.apache.org Delivered-To: mailing list cloudstack-commits@incubator.apache.org Received: (qmail 95548 invoked by uid 99); 31 Oct 2012 17:50:14 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Oct 2012 17:50:14 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id CEE99512B1; Wed, 31 Oct 2012 17:50:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bhaisaab@apache.org To: cloudstack-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [6/6] git commit: marvin: check and use logger Message-Id: <20121031175013.CEE99512B1@tyr.zones.apache.org> Date: Wed, 31 Oct 2012 17:50:13 +0000 (UTC) marvin: check and use logger Checks and only then calls logger Signed-off-by: Rohit Yadav Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/d72d3ee2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/d72d3ee2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/d72d3ee2 Branch: refs/heads/master Commit: d72d3ee22bf9cb0b4381b7370b291c9f3856247f Parents: 1c0e2cf Author: Rohit Yadav Authored: Wed Oct 31 22:58:06 2012 +0530 Committer: Rohit Yadav Committed: Wed Oct 31 23:18:06 2012 +0530 ---------------------------------------------------------------------- tools/marvin/marvin/cloudstackConnection.py | 24 ++++++++++++++------- 1 files changed, 16 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d72d3ee2/tools/marvin/marvin/cloudstackConnection.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/cloudstackConnection.py b/tools/marvin/marvin/cloudstackConnection.py index d70c192..98c0214 100644 --- a/tools/marvin/marvin/cloudstackConnection.py +++ b/tools/marvin/marvin/cloudstackConnection.py @@ -69,16 +69,21 @@ class cloudConnection(object): try: self.connection = urllib2.urlopen("http://%s:%d/client/api?%s"%(self.mgtSvr, self.port, requestUrl)) - self.logging.debug("sending GET request: %s"%requestUrl) + if self.logging is not None: + self.logging.debug("sending GET request: %s"%requestUrl) response = self.connection.read() - self.logging.info("got response: %s"%response) + if self.logging is not None: + self.logging.info("got response: %s"%response) except IOError, e: if hasattr(e, 'reason'): - self.logging.critical("failed to reach %s because of %s"%(self.mgtSvr, e.reason)) + if self.logging is not None: + self.logging.critical("failed to reach %s because of %s"%(self.mgtSvr, e.reason)) elif hasattr(e, 'code'): - self.logging.critical("server returned %d error code"%e.code) + if self.logging is not None: + self.logging.critical("server returned %d error code"%e.code) except httplib.HTTPException, h: - self.logging.debug("encountered http Exception %s"%h.args) + if self.logging is not None: + self.logging.debug("encountered http Exception %s"%h.args) if self.retries > 0: self.retries = self.retries - 1 self.make_request_with_auth(command, requests) @@ -95,9 +100,11 @@ class cloudConnection(object): requestUrl = "&".join(["=".join([request[0], urllib.quote_plus(str(request[1]))]) for request in requests]) self.connection = urllib2.urlopen("http://%s:%d/client/api?%s"%(self.mgtSvr, self.port, requestUrl)) - self.logging.debug("sending GET request without auth: %s"%requestUrl) + if self.logging is not None: + self.logging.debug("sending GET request without auth: %s"%requestUrl) response = self.connection.read() - self.logging.info("got response: %s"%response) + if self.logging is not None: + self.logging.info("got response: %s"%response) return response def pollAsyncJob(self, jobId, response): @@ -114,7 +121,8 @@ class cloudConnection(object): return asyncResonse time.sleep(5) - self.logging.debug("job: %s still processing, will timeout in %ds"%(jobId, timeout)) + if self.logging is not None: + self.logging.debug("job: %s still processing, will timeout in %ds"%(jobId, timeout)) timeout = timeout - 5 raise cloudstackException.cloudstackAPIException("asyncquery", "Async job timeout %s"%jobId)