appease pylint and pep8
* cloudinit/distros/parsers/resolv_conf.py added some pylint overrides with 'plXXXXX' syntax. example: # pl51222 pylint: disable=E0102 The pl51222 there means: http://www.logilab.org/ticket/51222 This specific issue is present in 12.04 pylint, but not 13.04. * pylint doesn't like the requests special handling we have. which makes sense as it is only checking versus one specific version. * general pep8 and pylint cleanups.
This commit is contained in:
parent
48eaf260d6
commit
5055198732
@ -137,8 +137,8 @@ class ResolvConf(object):
|
||||
self._contents.append(('option', ['search', s_list, '']))
|
||||
return flat_sds
|
||||
|
||||
@local_domain.setter
|
||||
def local_domain(self, domain):
|
||||
@local_domain.setter # pl51222 pylint: disable=E1101
|
||||
def local_domain(self, domain): # pl51222 pylint: disable=E0102
|
||||
self.parse()
|
||||
self._remove_option('domain')
|
||||
self._contents.append(('option', ['domain', str(domain), '']))
|
||||
|
@ -145,6 +145,7 @@ def get_instance_userdata(api_version, metadata_address, ssl_details=None):
|
||||
util.logexc(LOG, "Failed fetching userdata from url %s", ud_url)
|
||||
return None
|
||||
|
||||
|
||||
def get_instance_metadata(api_version, metadata_address, ssl_details=None):
|
||||
md_url = combine_url(metadata_address, api_version)
|
||||
md_url = combine_url(md_url, 'meta-data')
|
||||
|
@ -34,12 +34,12 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
# Check if requests has ssl support (added in requests >= 0.8.8)
|
||||
SSL_ENABLED = False
|
||||
CONFIG_ENABLED = False # This was added in 0.7 (but taken out in >=1.0)
|
||||
CONFIG_ENABLED = False # This was added in 0.7 (but taken out in >=1.0)
|
||||
try:
|
||||
import pkg_resources
|
||||
from distutils.version import LooseVersion
|
||||
import pkg_resources
|
||||
_REQ = pkg_resources.get_distribution('requests')
|
||||
_REQ_VER = LooseVersion(_REQ.version)
|
||||
_REQ_VER = LooseVersion(_REQ.version) # pylint: disable=E1103
|
||||
if _REQ_VER >= LooseVersion('0.8.8'):
|
||||
SSL_ENABLED = True
|
||||
if _REQ_VER >= LooseVersion('0.7.0') and _REQ_VER < LooseVersion('1.0.0'):
|
||||
@ -49,7 +49,7 @@ except:
|
||||
|
||||
|
||||
def _cleanurl(url):
|
||||
parsed_url = list(urlparse(url, scheme='http'))
|
||||
parsed_url = list(urlparse(url, scheme='http')) # pylint: disable=E1123
|
||||
if not parsed_url[1] and parsed_url[2]:
|
||||
# Swap these since this seems to be a common
|
||||
# occurrence when given urls like 'www.google.com'
|
||||
@ -108,7 +108,8 @@ def readurl(url, data=None, timeout=None, retries=0, sec_between=1,
|
||||
req_args = {
|
||||
'url': url,
|
||||
}
|
||||
if urlparse(url).scheme == 'https' and ssl_details:
|
||||
scheme = urlparse(url).scheme # pylint: disable=E1101
|
||||
if scheme == 'https' and ssl_details:
|
||||
if not SSL_ENABLED:
|
||||
LOG.warn("SSL is not enabled, cert. verification can not occur!")
|
||||
else:
|
||||
@ -121,7 +122,7 @@ def readurl(url, data=None, timeout=None, retries=0, sec_between=1,
|
||||
ssl_details['key_file']]
|
||||
elif 'cert_file' in ssl_details:
|
||||
req_args['cert'] = str(ssl_details['cert_file'])
|
||||
|
||||
|
||||
req_args['allow_redirects'] = allow_redirects
|
||||
req_args['method'] = 'GET'
|
||||
if timeout is not None:
|
||||
@ -162,16 +163,17 @@ def readurl(url, data=None, timeout=None, retries=0, sec_between=1,
|
||||
try:
|
||||
r = requests.request(**req_args)
|
||||
if check_status:
|
||||
r.raise_for_status()
|
||||
r.raise_for_status() # pylint: disable=E1103
|
||||
LOG.debug("Read from %s (%s, %sb) after %s attempts", url,
|
||||
r.status_code, len(r.content), (i + 1))
|
||||
r.status_code, len(r.content), # pylint: disable=E1103
|
||||
(i + 1))
|
||||
# Doesn't seem like we can make it use a different
|
||||
# subclass for responses, so add our own backward-compat
|
||||
# attrs
|
||||
return UrlResponse(r)
|
||||
except exceptions.RequestException as e:
|
||||
if (isinstance(e, (exceptions.HTTPError))
|
||||
and hasattr(e, 'response') # This appeared in v 0.10.8
|
||||
and hasattr(e, 'response') # This appeared in v 0.10.8
|
||||
and e.response):
|
||||
excps.append(UrlError(e, code=e.response.status_code,
|
||||
headers=e.response.headers))
|
||||
@ -183,7 +185,7 @@ def readurl(url, data=None, timeout=None, retries=0, sec_between=1,
|
||||
time.sleep(sec_between)
|
||||
if excps:
|
||||
raise excps[-1]
|
||||
return None # Should throw before this...
|
||||
return None # Should throw before this...
|
||||
|
||||
|
||||
def wait_for_url(urls, max_wait=None, timeout=None,
|
||||
|
@ -51,8 +51,8 @@ from cloudinit import importer
|
||||
from cloudinit import log as logging
|
||||
from cloudinit import mergers
|
||||
from cloudinit import safeyaml
|
||||
from cloudinit import url_helper
|
||||
from cloudinit import type_utils
|
||||
from cloudinit import url_helper
|
||||
from cloudinit import version
|
||||
|
||||
from cloudinit.settings import (CFG_BUILTIN)
|
||||
@ -81,7 +81,7 @@ class StringResponse(object):
|
||||
self.contents = contents
|
||||
self.url = None
|
||||
|
||||
def ok(self, *args, **kwargs):
|
||||
def ok(self, *args, **kwargs): # pylint: disable=W0613
|
||||
if self.code != 200:
|
||||
return False
|
||||
return True
|
||||
|
Loading…
x
Reference in New Issue
Block a user