From 0c151d7d7ea00627fad182898958db55b1fef3fd Mon Sep 17 00:00:00 2001 From: Julia Varlamova Date: Tue, 28 Jan 2014 17:49:47 +0400 Subject: [PATCH] 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 --- glance/common/client.py | 10 +--------- glance/db/simple/api.py | 2 +- glance/db/sqlalchemy/api.py | 2 +- glance/store/swift.py | 1 + tox.ini | 3 +-- 5 files changed, 5 insertions(+), 13 deletions(-) diff --git a/glance/common/client.py b/glance/common/client.py index 5ee4234756..b2791a63bf 100644 --- a/glance/common/client.py +++ b/glance/common/client.py @@ -503,7 +503,7 @@ class BaseClient(object): if use_sendfile or header.lower() != 'content-length': c.putheader(header, str(value)) - iter = self.image_iterator(c, headers, body) + iter = utils.chunkreadable(body) if use_sendfile: # send actual file without copying into userspace @@ -569,14 +569,6 @@ class BaseClient(object): def _iterable(self, body): 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): """ Returns the integer status code from the response, which diff --git a/glance/db/simple/api.py b/glance/db/simple/api.py index ed3f90e9a4..f5a985e6bd 100644 --- a/glance/db/simple/api.py +++ b/glance/db/simple/api.py @@ -508,7 +508,7 @@ def image_location_update(context, image_id, location): if not updated: 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) raise exception.NotFound(msg) diff --git a/glance/db/sqlalchemy/api.py b/glance/db/sqlalchemy/api.py index 3874b24f0b..e2bf57b619 100644 --- a/glance/db/sqlalchemy/api.py +++ b/glance/db/sqlalchemy/api.py @@ -796,7 +796,7 @@ def image_location_update(context, image_id, location, session=None): location_ref.save(session=session) except sa_orm.exc.NoResultFound: 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) raise exception.NotFound(msg) diff --git a/glance/store/swift.py b/glance/store/swift.py index 4533433a13..078e3fe6fa 100644 --- a/glance/store/swift.py +++ b/glance/store/swift.py @@ -28,6 +28,7 @@ import urllib from glance.common import auth from glance.common import exception from glance.common import swift_store_utils +from glance.common import utils from glance import i18n from glance.openstack.common import excutils import glance.openstack.common.log as logging diff --git a/tox.ini b/tox.ini index 4d78636504..d471aa3212 100644 --- a/tox.ini +++ b/tox.ini @@ -33,11 +33,10 @@ commands = {posargs} # TODO(dmllr): Analyze or fix the warnings blacklisted below # E711 comparison to None should be 'if cond is not None:' # E712 comparison to True should be 'if cond is True:' or 'if cond:' -# F821 undefined name 'name' # H302 import only modules # H402 one line docstring needs punctuation. # H404 multi line docstring should start with a summary -ignore = E711,E712,F821,H302,H402,H404 +ignore = E711,E712,H302,H402,H404 builtins = _ exclude = .venv,.git,.tox,dist,doc,etc,*glance/locale*,*openstack/common*,*lib/python*,*egg,build