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, '']))
|
self._contents.append(('option', ['search', s_list, '']))
|
||||||
return flat_sds
|
return flat_sds
|
||||||
|
|
||||||
@local_domain.setter
|
@local_domain.setter # pl51222 pylint: disable=E1101
|
||||||
def local_domain(self, domain):
|
def local_domain(self, domain): # pl51222 pylint: disable=E0102
|
||||||
self.parse()
|
self.parse()
|
||||||
self._remove_option('domain')
|
self._remove_option('domain')
|
||||||
self._contents.append(('option', ['domain', str(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)
|
util.logexc(LOG, "Failed fetching userdata from url %s", ud_url)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_instance_metadata(api_version, metadata_address, ssl_details=None):
|
def get_instance_metadata(api_version, metadata_address, ssl_details=None):
|
||||||
md_url = combine_url(metadata_address, api_version)
|
md_url = combine_url(metadata_address, api_version)
|
||||||
md_url = combine_url(md_url, 'meta-data')
|
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)
|
# Check if requests has ssl support (added in requests >= 0.8.8)
|
||||||
SSL_ENABLED = False
|
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:
|
try:
|
||||||
import pkg_resources
|
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
|
import pkg_resources
|
||||||
_REQ = pkg_resources.get_distribution('requests')
|
_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'):
|
if _REQ_VER >= LooseVersion('0.8.8'):
|
||||||
SSL_ENABLED = True
|
SSL_ENABLED = True
|
||||||
if _REQ_VER >= LooseVersion('0.7.0') and _REQ_VER < LooseVersion('1.0.0'):
|
if _REQ_VER >= LooseVersion('0.7.0') and _REQ_VER < LooseVersion('1.0.0'):
|
||||||
@ -49,7 +49,7 @@ except:
|
|||||||
|
|
||||||
|
|
||||||
def _cleanurl(url):
|
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]:
|
if not parsed_url[1] and parsed_url[2]:
|
||||||
# Swap these since this seems to be a common
|
# Swap these since this seems to be a common
|
||||||
# occurrence when given urls like 'www.google.com'
|
# 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 = {
|
req_args = {
|
||||||
'url': url,
|
'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:
|
if not SSL_ENABLED:
|
||||||
LOG.warn("SSL is not enabled, cert. verification can not occur!")
|
LOG.warn("SSL is not enabled, cert. verification can not occur!")
|
||||||
else:
|
else:
|
||||||
@ -162,16 +163,17 @@ def readurl(url, data=None, timeout=None, retries=0, sec_between=1,
|
|||||||
try:
|
try:
|
||||||
r = requests.request(**req_args)
|
r = requests.request(**req_args)
|
||||||
if check_status:
|
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,
|
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
|
# Doesn't seem like we can make it use a different
|
||||||
# subclass for responses, so add our own backward-compat
|
# subclass for responses, so add our own backward-compat
|
||||||
# attrs
|
# attrs
|
||||||
return UrlResponse(r)
|
return UrlResponse(r)
|
||||||
except exceptions.RequestException as e:
|
except exceptions.RequestException as e:
|
||||||
if (isinstance(e, (exceptions.HTTPError))
|
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):
|
and e.response):
|
||||||
excps.append(UrlError(e, code=e.response.status_code,
|
excps.append(UrlError(e, code=e.response.status_code,
|
||||||
headers=e.response.headers))
|
headers=e.response.headers))
|
||||||
@ -183,7 +185,7 @@ def readurl(url, data=None, timeout=None, retries=0, sec_between=1,
|
|||||||
time.sleep(sec_between)
|
time.sleep(sec_between)
|
||||||
if excps:
|
if excps:
|
||||||
raise excps[-1]
|
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,
|
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 log as logging
|
||||||
from cloudinit import mergers
|
from cloudinit import mergers
|
||||||
from cloudinit import safeyaml
|
from cloudinit import safeyaml
|
||||||
from cloudinit import url_helper
|
|
||||||
from cloudinit import type_utils
|
from cloudinit import type_utils
|
||||||
|
from cloudinit import url_helper
|
||||||
from cloudinit import version
|
from cloudinit import version
|
||||||
|
|
||||||
from cloudinit.settings import (CFG_BUILTIN)
|
from cloudinit.settings import (CFG_BUILTIN)
|
||||||
@ -81,7 +81,7 @@ class StringResponse(object):
|
|||||||
self.contents = contents
|
self.contents = contents
|
||||||
self.url = None
|
self.url = None
|
||||||
|
|
||||||
def ok(self, *args, **kwargs):
|
def ok(self, *args, **kwargs): # pylint: disable=W0613
|
||||||
if self.code != 200:
|
if self.code != 200:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user