Enable F821 check: undefined name 'name'
Enable F821 and fix usage of undefined variables. In glance/common/client.py in BaseClient class image_iterator() function returns instances of unexisting classes: - SendFileIterator - ImageBodyIterator Since we have not these classes functionality now, we will use utils.chunkreadable() function instead. Delete image_iterator() function. Change-Id: Ie1a8c66e5df2836e6e9aadfb1013d69fc6f710e6
This commit is contained in:
parent
323aba66cf
commit
0c151d7d7e
@ -503,7 +503,7 @@ class BaseClient(object):
|
|||||||
if use_sendfile or header.lower() != 'content-length':
|
if use_sendfile or header.lower() != 'content-length':
|
||||||
c.putheader(header, str(value))
|
c.putheader(header, str(value))
|
||||||
|
|
||||||
iter = self.image_iterator(c, headers, body)
|
iter = utils.chunkreadable(body)
|
||||||
|
|
||||||
if use_sendfile:
|
if use_sendfile:
|
||||||
# send actual file without copying into userspace
|
# send actual file without copying into userspace
|
||||||
@ -569,14 +569,6 @@ class BaseClient(object):
|
|||||||
def _iterable(self, body):
|
def _iterable(self, body):
|
||||||
return isinstance(body, collections.Iterable)
|
return isinstance(body, collections.Iterable)
|
||||||
|
|
||||||
def image_iterator(self, connection, headers, body):
|
|
||||||
if self._sendable(body):
|
|
||||||
return SendFileIterator(connection, body)
|
|
||||||
elif self._iterable(body):
|
|
||||||
return utils.chunkreadable(body)
|
|
||||||
else:
|
|
||||||
return ImageBodyIterator(body)
|
|
||||||
|
|
||||||
def get_status_code(self, response):
|
def get_status_code(self, response):
|
||||||
"""
|
"""
|
||||||
Returns the integer status code from the response, which
|
Returns the integer status code from the response, which
|
||||||
|
@ -508,7 +508,7 @@ def image_location_update(context, image_id, location):
|
|||||||
|
|
||||||
if not updated:
|
if not updated:
|
||||||
msg = (_("No location found with ID %(loc)s from image %(img)s") %
|
msg = (_("No location found with ID %(loc)s from image %(img)s") %
|
||||||
dict(loc=location_id, img=image_id))
|
dict(loc=loc_id, img=image_id))
|
||||||
LOG.warn(msg)
|
LOG.warn(msg)
|
||||||
raise exception.NotFound(msg)
|
raise exception.NotFound(msg)
|
||||||
|
|
||||||
|
@ -796,7 +796,7 @@ def image_location_update(context, image_id, location, session=None):
|
|||||||
location_ref.save(session=session)
|
location_ref.save(session=session)
|
||||||
except sa_orm.exc.NoResultFound:
|
except sa_orm.exc.NoResultFound:
|
||||||
msg = (_("No location found with ID %(loc)s from image %(img)s") %
|
msg = (_("No location found with ID %(loc)s from image %(img)s") %
|
||||||
dict(loc=location_id, img=image_id))
|
dict(loc=loc_id, img=image_id))
|
||||||
LOG.warn(msg)
|
LOG.warn(msg)
|
||||||
raise exception.NotFound(msg)
|
raise exception.NotFound(msg)
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import urllib
|
|||||||
from glance.common import auth
|
from glance.common import auth
|
||||||
from glance.common import exception
|
from glance.common import exception
|
||||||
from glance.common import swift_store_utils
|
from glance.common import swift_store_utils
|
||||||
|
from glance.common import utils
|
||||||
from glance import i18n
|
from glance import i18n
|
||||||
from glance.openstack.common import excutils
|
from glance.openstack.common import excutils
|
||||||
import glance.openstack.common.log as logging
|
import glance.openstack.common.log as logging
|
||||||
|
3
tox.ini
3
tox.ini
@ -33,11 +33,10 @@ commands = {posargs}
|
|||||||
# TODO(dmllr): Analyze or fix the warnings blacklisted below
|
# TODO(dmllr): Analyze or fix the warnings blacklisted below
|
||||||
# E711 comparison to None should be 'if cond is not None:'
|
# E711 comparison to None should be 'if cond is not None:'
|
||||||
# E712 comparison to True should be 'if cond is True:' or 'if cond:'
|
# E712 comparison to True should be 'if cond is True:' or 'if cond:'
|
||||||
# F821 undefined name 'name'
|
|
||||||
# H302 import only modules
|
# H302 import only modules
|
||||||
# H402 one line docstring needs punctuation.
|
# H402 one line docstring needs punctuation.
|
||||||
# H404 multi line docstring should start with a summary
|
# H404 multi line docstring should start with a summary
|
||||||
ignore = E711,E712,F821,H302,H402,H404
|
ignore = E711,E712,H302,H402,H404
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude = .venv,.git,.tox,dist,doc,etc,*glance/locale*,*openstack/common*,*lib/python*,*egg,build
|
exclude = .venv,.git,.tox,dist,doc,etc,*glance/locale*,*openstack/common*,*lib/python*,*egg,build
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user