Fix some bugs discovered by pylint, ignore other false positives.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/cbc34ea1 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/cbc34ea1 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/cbc34ea1 Branch: refs/heads/trunk Commit: cbc34ea1215872edacb16344e77faf17becf35c2 Parents: e6a1c48 Author: Tomaz Muraus <[email protected]> Authored: Tue Apr 19 19:52:37 2016 +0200 Committer: Tomaz Muraus <[email protected]> Committed: Tue Apr 19 19:52:37 2016 +0200 ---------------------------------------------------------------------- libcloud/common/abiquo.py | 2 +- libcloud/common/aliyun.py | 2 +- libcloud/common/aws.py | 4 +++- libcloud/common/azure.py | 1 + libcloud/common/base.py | 4 ++++ libcloud/common/dimensiondata.py | 1 + libcloud/common/durabledns.py | 2 ++ libcloud/common/gandi.py | 1 + libcloud/common/gogrid.py | 3 +++ libcloud/common/google.py | 3 ++- libcloud/common/liquidweb.py | 4 ++-- libcloud/common/openstack.py | 1 + libcloud/common/openstack_identity.py | 1 + libcloud/common/runabove.py | 1 + libcloud/common/worldwidedns.py | 7 +++++-- libcloud/common/xmlrpc.py | 1 + libcloud/common/zonomi.py | 2 ++ 17 files changed, 32 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/abiquo.py ---------------------------------------------------------------------- diff --git a/libcloud/common/abiquo.py b/libcloud/common/abiquo.py index a972243..0aa99a7 100644 --- a/libcloud/common/abiquo.py +++ b/libcloud/common/abiquo.py @@ -271,4 +271,4 @@ class ForbiddenError(LibcloudError): def __init__(self, driver): message = 'User has not permission to perform this task.' - super(LibcloudError, self).__init__(message, driver) + super(ForbiddenError, self).__init__(message, driver) http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/aliyun.py ---------------------------------------------------------------------- diff --git a/libcloud/common/aliyun.py b/libcloud/common/aliyun.py index 4e91dbb..062f389 100644 --- a/libcloud/common/aliyun.py +++ b/libcloud/common/aliyun.py @@ -200,7 +200,7 @@ class SignedAliyunConnection(AliyunConnection): self.signer = signer_cls(access_key=self.user_id, access_secret=self.key, - version=self.version) + version=signature_version) def add_default_params(self, params): params = self.signer.get_request_params(params=params, http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/aws.py ---------------------------------------------------------------------- diff --git a/libcloud/common/aws.py b/libcloud/common/aws.py index 74922a6..c26bcaa 100644 --- a/libcloud/common/aws.py +++ b/libcloud/common/aws.py @@ -81,7 +81,7 @@ class AWSGenericResponse(AWSBaseResponse): # exception class that is raised immediately. # If a custom exception class is not defined, errors are accumulated and # returned from the parse_error method. - expections = {} + exceptions = {} def success(self): return self.status in [httplib.OK, httplib.CREATED, httplib.ACCEPTED] @@ -347,6 +347,8 @@ class AWSRequestSignerAlgorithmV4(AWSRequestSigner): class SignedAWSConnection(AWSTokenConnection): + version = None + def __init__(self, user_id, key, secure=True, host=None, port=None, url=None, timeout=None, proxy_url=None, token=None, retry_delay=None, backoff=None, http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/azure.py ---------------------------------------------------------------------- diff --git a/libcloud/common/azure.py b/libcloud/common/azure.py index bd3c504..b7f9ffc 100644 --- a/libcloud/common/azure.py +++ b/libcloud/common/azure.py @@ -71,6 +71,7 @@ class AzureResponse(XmlResponse): # Some APIs respond with an XML error. Others just dump HTML body = self.parse_body() + # pylint: disable=no-member if type(body) == ET.Element: code = body.findtext(fixxpath(xpath='Code')) message = body.findtext(fixxpath(xpath='Message')) http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/base.py ---------------------------------------------------------------------- diff --git a/libcloud/common/base.py b/libcloud/common/base.py index 5d4c3e9..bda758b 100644 --- a/libcloud/common/base.py +++ b/libcloud/common/base.py @@ -413,6 +413,8 @@ class LoggingConnection(): return (rr, rv) def _log_curl(self, method, url, body, headers): + # pylint: disable=no-member + cmd = ["curl"] if self.http_proxy_used: @@ -625,6 +627,8 @@ class Connection(object): connection = None secure = self.secure + # pylint: disable=no-member + if getattr(self, 'base_url', None) and base_url is None: (host, port, secure, request_path) = self._tuple_from_url(self.base_url) http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/dimensiondata.py ---------------------------------------------------------------------- diff --git a/libcloud/common/dimensiondata.py b/libcloud/common/dimensiondata.py index 8bb4742..50870e7 100644 --- a/libcloud/common/dimensiondata.py +++ b/libcloud/common/dimensiondata.py @@ -470,6 +470,7 @@ class DimensionDataConnection(ConnectionUserAndKey): data, headers, method).object yield paged_resp + paged_resp = paged_resp or {} while paged_resp.get('pageCount') >= paged_resp.get('pageSize'): params['pageNumber'] = int(paged_resp.get('pageNumber')) + 1 http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/durabledns.py ---------------------------------------------------------------------- diff --git a/libcloud/common/durabledns.py b/libcloud/common/durabledns.py index 5859f6e..7e95c37 100644 --- a/libcloud/common/durabledns.py +++ b/libcloud/common/durabledns.py @@ -148,6 +148,8 @@ class DurableResponse(XmlResponse): zone_dict = {} record_dict = {} xml_obj = self.parse_body() + + # pylint: disable=no-member envelop_body = xml_obj.getchildren()[0] method_resp = envelop_body.getchildren()[0] # parse the xml_obj http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/gandi.py ---------------------------------------------------------------------- diff --git a/libcloud/common/gandi.py b/libcloud/common/gandi.py index be326f3..75ce4fe 100644 --- a/libcloud/common/gandi.py +++ b/libcloud/common/gandi.py @@ -90,6 +90,7 @@ class BaseGandiDriver(object): for i in range(0, timeout, check_interval): try: + # pylint: disable=no-member op = self.connection.request('operation.info', int(id)).object if op['step'] == 'DONE': http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/gogrid.py ---------------------------------------------------------------------- diff --git a/libcloud/common/gogrid.py b/libcloud/common/gogrid.py index e2448de..0710bda 100644 --- a/libcloud/common/gogrid.py +++ b/libcloud/common/gogrid.py @@ -127,6 +127,7 @@ class BaseGoGridDriver(object): for el in object['list']] def _to_location(self, element): + # pylint: disable=no-member location = NodeLocation(id=element['id'], name=element['name'], country="US", @@ -170,6 +171,7 @@ class BaseGoGridDriver(object): if "location" in kwargs and kwargs['location'] is not None: params['datacenter'] = kwargs['location'].id + # pylint: disable=no-member response = self.connection.request('/api/grid/ip/list', params=params) ips = self._to_ips(response.object) return ips @@ -179,5 +181,6 @@ class BaseGoGridDriver(object): try: return ips[0].ip except IndexError: + # pylint: disable=no-member raise LibcloudError('No public unassigned IPs left', self.driver) http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/google.py ---------------------------------------------------------------------- diff --git a/libcloud/common/google.py b/libcloud/common/google.py index ca248d5..2912817 100644 --- a/libcloud/common/google.py +++ b/libcloud/common/google.py @@ -160,7 +160,7 @@ class ResourceNotFoundError(GoogleBaseError): "error may be an authentication issue. " \ "Please ensure your auth credentials match " \ "your project. " - super(GoogleBaseError, self).__init__(value, http_code, driver) + super(ResourceNotFoundError, self).__init__(value, http_code, driver) class QuotaExceededError(GoogleBaseError): @@ -377,6 +377,7 @@ class GoogleBaseAuthConnection(ConnectionUserAndKey): :return: A dictionary containing updated token information. :rtype: ``dict`` """ + # pylint: disable=no-member return self.get_new_token() http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/liquidweb.py ---------------------------------------------------------------------- diff --git a/libcloud/common/liquidweb.py b/libcloud/common/liquidweb.py index 123e82f..cdbacc1 100644 --- a/libcloud/common/liquidweb.py +++ b/libcloud/common/liquidweb.py @@ -51,10 +51,10 @@ class LiquidWebException(ProviderError): super(LiquidWebException, self).__init__(value, http_code, driver=None) def __str__(self): - return "%s %s" % (self.code, self.value) + return "%s %s" % (self.http_code, self.value) def __repr__(self): - return "LiquidWebException %s %s" % (self.code, self.value) + return "LiquidWebException %s %s" % (self.http_code, self.value) class APIException(LiquidWebException): http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/openstack.py ---------------------------------------------------------------------- diff --git a/libcloud/common/openstack.py b/libcloud/common/openstack.py index e63ee8a..cfdef79 100644 --- a/libcloud/common/openstack.py +++ b/libcloud/common/openstack.py @@ -125,6 +125,7 @@ class OpenStackBaseConnection(ConnectionUserAndKey): service_type = None service_name = None service_region = None + accept_format = None _auth_version = None def __init__(self, user_id, key, secure=True, http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/openstack_identity.py ---------------------------------------------------------------------- diff --git a/libcloud/common/openstack_identity.py b/libcloud/common/openstack_identity.py index e8cc6a8..24c12d0 100644 --- a/libcloud/common/openstack_identity.py +++ b/libcloud/common/openstack_identity.py @@ -569,6 +569,7 @@ class OpenStackIdentityConnection(ConnectionUserAndKey): """ responseCls = OpenStackAuthResponse timeout = None + auth_version = None def __init__(self, auth_url, user_id, key, tenant_name=None, timeout=None, parent_conn=None): http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/runabove.py ---------------------------------------------------------------------- diff --git a/libcloud/common/runabove.py b/libcloud/common/runabove.py index 4d45241..0f08b59 100644 --- a/libcloud/common/runabove.py +++ b/libcloud/common/runabove.py @@ -54,6 +54,7 @@ class RunAboveException(Exception): class RunAboveResponse(JsonResponse): def parse_error(self): response = super(RunAboveResponse, self).parse_body() + response = response or {} if response.get('errorCode', None) == 'INVALID_SIGNATURE': raise InvalidCredsError('Signature validation failed, probably ' http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/worldwidedns.py ---------------------------------------------------------------------- diff --git a/libcloud/common/worldwidedns.py b/libcloud/common/worldwidedns.py index 1c02a12..6dce6b1 100644 --- a/libcloud/common/worldwidedns.py +++ b/libcloud/common/worldwidedns.py @@ -190,6 +190,9 @@ class WorldWideDNSConnection(ConnectionUserAndKey): """ params["NAME"] = self.user_id params["PASSWORD"] = self.key - if hasattr(self, 'reseller_id'): - params["ID"] = self.reseller_id + + reseller_id = getattr(self, 'reseller_id', None) + if reseller_id: + params["ID"] = reseller_id + return params http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/xmlrpc.py ---------------------------------------------------------------------- diff --git a/libcloud/common/xmlrpc.py b/libcloud/common/xmlrpc.py index 2502ea6..237bf27 100644 --- a/libcloud/common/xmlrpc.py +++ b/libcloud/common/xmlrpc.py @@ -85,6 +85,7 @@ class XMLRPCConnection(Connection): """ responseCls = XMLRPCResponse + endpoint = None def add_default_headers(self, headers): headers['Content-Type'] = 'text/xml' http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbc34ea1/libcloud/common/zonomi.py ---------------------------------------------------------------------- diff --git a/libcloud/common/zonomi.py b/libcloud/common/zonomi.py index 3ef913d..cabfa54 100644 --- a/libcloud/common/zonomi.py +++ b/libcloud/common/zonomi.py @@ -65,6 +65,8 @@ class ZonomiResponse(XmlResponse): data = [] errors = [] xml_body = super(ZonomiResponse, self).parse_body() + + # pylint: disable=no-member # Error handling if xml_body.text is not None and xml_body.tag == 'error': error_dict['ERRORCODE'] = self.status
