You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2012/08/21 13:41:45 UTC
[4/8] git commit: Trivial whitespace cleanup in Python deltacloud
client
Trivial whitespace cleanup in Python deltacloud client
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/e6a49a54
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/e6a49a54
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/e6a49a54
Branch: refs/heads/master
Commit: e6a49a54daabf5c10b34655eea9601e618b59334
Parents: 64e01be
Author: Martin Packman <ma...@canonical.com>
Authored: Mon May 14 17:15:51 2012 +0100
Committer: Tomas Sedovic <to...@sedovic.cz>
Committed: Tue Aug 21 12:06:56 2012 +0200
----------------------------------------------------------------------
clients/python/deltacloud.py | 38 ++++++++++++++++++------------------
1 files changed, 19 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/e6a49a54/clients/python/deltacloud.py
----------------------------------------------------------------------
diff --git a/clients/python/deltacloud.py b/clients/python/deltacloud.py
index 8dc72eb..02611b8 100644
--- a/clients/python/deltacloud.py
+++ b/clients/python/deltacloud.py
@@ -21,7 +21,7 @@ import libxml2
class SimpleRestClient:
"""A simple REST client library"""
-
+
def __init__(self, api_url, api_user, api_password):
self.url, self.user, self.password = api_url, api_user, api_password
self.client = Http()
@@ -30,37 +30,37 @@ class SimpleRestClient:
def GET(self, uri):
if uri.startswith('http://'):
- current_url = ''
+ current_url = ''
else:
- current_url = self.url
+ current_url = self.url
status, response = self.client.request('{url}{uri}'.format(url=current_url, uri=uri), 'GET', headers={'accept':'application/xml'})
response = self.parse_xml(response)
return status, response
def POST(self, uri, params={}):
if uri.startswith('http://'):
- current_url = ''
+ current_url = ''
else:
- current_url = self.url
+ current_url = self.url
if not params:
- params = {}
+ params = {}
status, response = self.client.request('{url}{uri}'.format(url=current_url, uri=uri), 'POST',
- urlencode(params), headers={'accept':'application/xml'})
+ urlencode(params), headers={'accept':'application/xml'})
response = self.parse_xml(response)
return status, response
def DELETE(self, uri):
if uri.startswith('http://'):
- current_url = ''
+ current_url = ''
else:
- current_url = self.url
+ current_url = self.url
return self.client.request('{url}{uri}'.format(url=current_url, uri=uri), 'DELETE')
def PUT(self, uri):
if uri.startswith('http://'):
- current_url = ''
+ current_url = ''
else:
- current_url = self.url
+ current_url = self.url
return self.client.request('{url}{uri}'.format(url=current_url, uri=uri), 'PUT')
def parse_xml(self, response):
@@ -144,9 +144,9 @@ class Instance(Deltacloud):
return False
else:
if self.deltacloud.client.POST(action[0].xpathEval("@href")[0].content, {})[0]['status'] == '200':
- return True
+ return True
else:
- return False
+ return False
def stop(self):
action = self.instance.xpathEval("actions/link[@rel='stop']")
@@ -154,9 +154,9 @@ class Instance(Deltacloud):
return False
else:
if self.deltacloud.client.POST(action[0].xpathEval("@href")[0].content, {})[0]['status'] == '200':
- return True
+ return True
else:
- return False
+ return False
def reboot(self):
action = self.instance.xpathEval("actions/link[@rel='reboot']")
@@ -164,9 +164,9 @@ class Instance(Deltacloud):
return False
else:
if self.deltacloud.client.POST(action[0].xpathEval("@href")[0].content, {})[0]['status'] == '200':
- return True
+ return True
else:
- return False
+ return False
def destroy(self):
action = self.instance.xpathEval("actions/link[@rel='destroy']")
@@ -174,9 +174,9 @@ class Instance(Deltacloud):
return False
else:
if self.deltacloud.client.POST(action[0].xpathEval("@href")[0].content, {})[0]['status'] == '200':
- return True
+ return True
else:
- return False
+ return False
class Image(Deltacloud):