You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by je...@apache.org on 2010/02/09 14:49:46 UTC
svn commit: r908026 - /incubator/libcloud/trunk/libcloud/drivers/linode.py
Author: jerry
Date: Tue Feb 9 13:49:46 2010
New Revision: 908026
URL: http://svn.apache.org/viewvc?rev=908026&view=rev
Log:
80-col formatting update: drivers/linode.py
Modified:
incubator/libcloud/trunk/libcloud/drivers/linode.py
Modified: incubator/libcloud/trunk/libcloud/drivers/linode.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/libcloud/drivers/linode.py?rev=908026&r1=908025&r2=908026&view=diff
==============================================================================
--- incubator/libcloud/trunk/libcloud/drivers/linode.py (original)
+++ incubator/libcloud/trunk/libcloud/drivers/linode.py Tue Feb 9 13:49:46 2010
@@ -60,14 +60,16 @@
self.status = response.status
self.headers = dict(response.getheaders())
self.error = response.reason
- self.invalid = LinodeException(0xFF, "Invalid JSON received from server")
+ self.invalid = LinodeException(0xFF,
+ "Invalid JSON received from server")
# Move parse_body() to here; we can't be sure of failure until we've
# parsed the body into JSON.
self.action, self.object, self.errors = self.parse_body()
if self.error == "Moved Temporarily":
- raise LinodeException(0xFA, "Redirected to error page by API. Bug?")
+ raise LinodeException(0xFA,
+ "Redirected to error page by API. Bug?")
if not self.success():
# Raise the first error, as there will usually only be one
@@ -79,7 +81,10 @@
# (action, data, errorarray)
try:
js = json.loads(self.body)
- if "DATA" not in js or "ERRORARRAY" not in js or "ACTION" not in js:
+ if ("DATA" not in js
+ or "ERRORARRAY" not in js
+ or "ACTION" not in js):
+
return (None, None, [self.invalid])
errs = [self._make_excp(e) for e in js["ERRORARRAY"]]
return (js["ACTION"], js["DATA"], errs)
@@ -250,7 +255,8 @@
# Distribution ID
distros = self.list_images()
if image.id not in [d.id for d in distros]:
- raise LinodeException(0xFB, "Invalid distro -- avail.distributions")
+ raise LinodeException(0xFB,
+ "Invalid distro -- avail.distributions")
# Kernel
kernel = 60 if "kernel" not in kwargs else kwargs["kernel"]
@@ -376,17 +382,25 @@
elif dc["LOCATION"][-2:] == "UK":
country = "GB"
else:
- raise LinodeException(0xFD, "Unable to convert data center location to country: '%s'" % dc["LOCATION"])
- nl.append(NodeLocation(dc["DATACENTERID"], dc["LOCATION"], country, self))
+ raise LinodeException(
+ 0xFD,
+ "Unable to convert data center location to country: '%s'"
+ % dc["LOCATION"]
+ )
+ nl.append(NodeLocation(dc["DATACENTERID"],
+ dc["LOCATION"],
+ country,
+ self))
return nl
def linode_set_datacenter(self, did):
# Set the datacenter for create requests.
#
- # Create will try to guess, based on where all of the API key's Linodes
- # are located; if they are all in one location, Create will make a new
- # node there. If there are NO Linodes on the account or Linodes are in
- # multiple locations, it is imperative to set this or creates will fail.
+ # Create will try to guess, based on where all of the API key's
+ # Linodes are located; if they are all in one location, Create will
+ # make a new node there. If there are NO Linodes on the account or
+ # Linodes are in multiple locations, it is imperative to set this or
+ # creates will fail.
params = { "api_action": "avail.datacenters" }
data = self.connection.request(LINODE_ROOT, params=params).object
for dc in data: