Looks good.
Ethan On Mon, Sep 19, 2011 at 11:18, Ben Pfaff <[email protected]> wrote: > Found by pychecker. > --- > python/ovs/daemon.py | 26 +++++++++++++------------- > python/ovs/db/schema.py | 4 ++-- > python/ovs/db/types.py | 6 +++--- > python/ovs/fatal_signal.py | 8 ++++---- > python/ovs/json.py | 6 +++--- > python/ovs/jsonrpc.py | 10 +++++----- > python/ovs/util.py | 16 ++++++++-------- > 7 files changed, 38 insertions(+), 38 deletions(-) > > diff --git a/python/ovs/daemon.py b/python/ovs/daemon.py > index ba18d86..2378278 100644 > --- a/python/ovs/daemon.py > +++ b/python/ovs/daemon.py > @@ -128,25 +128,25 @@ def _make_pidfile(): > # This is global to keep Python from garbage-collecting and > # therefore closing our file after this function exits. That would > # unlock the lock for us, and we don't want that. > - global file > + global file_ > > - file = open(tmpfile, "w") > + file_ = open(tmpfile, "w") > except IOError, e: > _fatal("%s: create failed (%s)" % (tmpfile, e.strerror)) > > try: > - s = os.fstat(file.fileno()) > + s = os.fstat(file_.fileno()) > except IOError, e: > _fatal("%s: fstat failed (%s)" % (tmpfile, e.strerror)) > > try: > - file.write("%s\n" % pid) > - file.flush() > + file_.write("%s\n" % pid) > + file_.flush() > except OSError, e: > _fatal("%s: write failed: %s" % (tmpfile, e.strerror)) > > try: > - fcntl.lockf(file, fcntl.LOCK_EX | fcntl.LOCK_NB) > + fcntl.lockf(file_, fcntl.LOCK_EX | fcntl.LOCK_NB) > except IOError, e: > _fatal("%s: fcntl failed: %s" % (tmpfile, e.strerror)) > > @@ -386,7 +386,7 @@ def __read_pidfile(pidfile, delete_if_stale): > pass > > try: > - file = open(pidfile, "r+") > + file_ = open(pidfile, "r+") > except IOError, e: > if e.errno == errno.ENOENT and delete_if_stale: > return 0 > @@ -396,11 +396,11 @@ def __read_pidfile(pidfile, delete_if_stale): > # Python fcntl doesn't directly support F_GETLK so we have to just try > # to lock it. > try: > - fcntl.lockf(file, fcntl.LOCK_EX | fcntl.LOCK_NB) > + fcntl.lockf(file_, fcntl.LOCK_EX | fcntl.LOCK_NB) > > # pidfile exists but wasn't locked by anyone. Now we have the lock. > if not delete_if_stale: > - file.close() > + file_.close() > logging.warning("%s: pid file is stale" % pidfile) > return -errno.ESRCH > > @@ -408,7 +408,7 @@ def __read_pidfile(pidfile, delete_if_stale): > try: > raced = False > s = os.stat(pidfile) > - s2 = os.fstat(file.fileno()) > + s2 = os.fstat(file_.fileno()) > if s.st_ino != s2.st_ino or s.st_dev != s2.st_dev: > raced = True > except IOError: > @@ -426,7 +426,7 @@ def __read_pidfile(pidfile, delete_if_stale): > return -e.errno > else: > logging.debug("%s: deleted stale pidfile" % pidfile) > - file.close() > + file_.close() > return 0 > except IOError, e: > if e.errno not in [errno.EACCES, errno.EAGAIN]: > @@ -436,7 +436,7 @@ def __read_pidfile(pidfile, delete_if_stale): > # Someone else has the pidfile locked. > try: > try: > - return int(file.readline()) > + return int(file_.readline()) > except IOError, e: > logging.warning("%s: read: %s" % (pidfile, e.strerror)) > return -e.errno > @@ -445,7 +445,7 @@ def __read_pidfile(pidfile, delete_if_stale): > return -errno.EINVAL > finally: > try: > - file.close() > + file_.close() > except IOError: > pass > > diff --git a/python/ovs/db/schema.py b/python/ovs/db/schema.py > index 29fe986..65ddca6 100644 > --- a/python/ovs/db/schema.py > +++ b/python/ovs/db/schema.py > @@ -249,10 +249,10 @@ class ColumnSchema(object): > parser = ovs.db.parser.Parser(json, "schema for column %s" % name) > mutable = parser.get_optional("mutable", [bool], True) > ephemeral = parser.get_optional("ephemeral", [bool], False) > - type = types.Type.from_json(parser.get("type", [dict, unicode])) > + type_ = types.Type.from_json(parser.get("type", [dict, unicode])) > parser.finish() > > - return ColumnSchema(name, mutable, not ephemeral, type) > + return ColumnSchema(name, mutable, not ephemeral, type_) > > def to_json(self): > json = {"type": self.type.to_json()} > diff --git a/python/ovs/db/types.py b/python/ovs/db/types.py > index 8b29000..dc19f85 100644 > --- a/python/ovs/db/types.py > +++ b/python/ovs/db/types.py > @@ -539,9 +539,9 @@ class Type(object): > 'OVSDB_TYPE_VOID);' % (indent, var)) > initMin = "%s%s.n_min = %s;" % (indent, var, self.n_min) > if self.n_max == sys.maxint: > - max = "UINT_MAX" > + n_max = "UINT_MAX" > else: > - max = self.n_max > - initMax = "%s%s.n_max = %s;" % (indent, var, max) > + n_max = self.n_max > + initMax = "%s%s.n_max = %s;" % (indent, var, n_max) > return "\n".join((initKey, initValue, initMin, initMax)) > > diff --git a/python/ovs/fatal_signal.py b/python/ovs/fatal_signal.py > index 765f683..de8f37c 100644 > --- a/python/ovs/fatal_signal.py > +++ b/python/ovs/fatal_signal.py > @@ -68,8 +68,8 @@ def unlink_file_now(file): > return error > > def _unlink_files(): > - for file in _files: > - _unlink(file) > + for file_ in _files: > + _unlink(file_) > > def _cancel_files(): > global _added_hook > @@ -77,9 +77,9 @@ def _cancel_files(): > _added_hook = False > _files = {} > > -def _unlink(file): > +def _unlink(file_): > try: > - os.unlink(file) > + os.unlink(file_) > return 0 > except OSError, e: > return e.errno > diff --git a/python/ovs/json.py b/python/ovs/json.py > index dd7606b..85c66fa 100644 > --- a/python/ovs/json.py > +++ b/python/ovs/json.py > @@ -23,9 +23,9 @@ escapes = {ord('"'): u"\\\"", > ord("\n"): u"\\n", > ord("\r"): u"\\r", > ord("\t"): u"\\t"} > -for i in range(32): > - if i not in escapes: > - escapes[i] = u"\\u%04x" % i > +for esc in range(32): > + if esc not in escapes: > + escapes[esc] = u"\\u%04x" % esc > > def __dump_string(stream, s): > stream.write(u'"%s"' % ''.join(escapes.get(ord(c), c) for c in s)) > diff --git a/python/ovs/jsonrpc.py b/python/ovs/jsonrpc.py > index 5117944..7aea31b 100644 > --- a/python/ovs/jsonrpc.py > +++ b/python/ovs/jsonrpc.py > @@ -119,7 +119,7 @@ class Message(object): > params = json.pop("params", None) > result = json.pop("result", None) > error = json.pop("error", None) > - id = json.pop("id", None) > + id_ = json.pop("id", None) > if len(json): > return "message has unexpected member \"%s\"" % json.popitem()[0] > > @@ -127,12 +127,12 @@ class Message(object): > msg_type = Message.T_REPLY > elif error is not None: > msg_type = Message.T_ERROR > - elif id is not None: > + elif id_ is not None: > msg_type = Message.T_REQUEST > else: > msg_type = Message.T_NOTIFY > > - msg = Message(msg_type, method, params, result, error, id) > + msg = Message(msg_type, method, params, result, error, id_) > validation_error = msg.is_valid() > if validation_error is not None: > return validation_error > @@ -289,13 +289,13 @@ class Connection(object): > poller.block() > > def transact_block(self, request): > - id = request.id > + id_ = request.id > > error = self.send(request) > reply = None > while not error: > error, reply = self.recv_block() > - if reply and reply.type == Message.T_REPLY and reply.id == id: > + if reply and reply.type == Message.T_REPLY and reply.id == id_: > break > return error, reply > > diff --git a/python/ovs/util.py b/python/ovs/util.py > index aa4b9bc..d218d3d 100644 > --- a/python/ovs/util.py > +++ b/python/ovs/util.py > @@ -18,26 +18,26 @@ import sys > > PROGRAM_NAME = os.path.basename(sys.argv[0]) > > -def abs_file_name(dir, file_name): > +def abs_file_name(dir_, file_name): > """If 'file_name' starts with '/', returns a copy of 'file_name'. > Otherwise, returns an absolute path to 'file_name' considering it relative > - to 'dir', which itself must be absolute. 'dir' may be None or the empty > + to 'dir_', which itself must be absolute. 'dir_' may be None or the > empty > string, in which case the current working directory is used. > > - Returns None if 'dir' is null and getcwd() fails. > + Returns None if 'dir_' is None and getcwd() fails. > > This differs from os.path.abspath() in that it will never change the > meaning of a file name.""" > if file_name.startswith('/'): > return file_name > else: > - if dir is None or dir == "": > + if dir_ is None or dir_ == "": > try: > - dir = os.getcwd() > + dir_ = os.getcwd() > except OSError: > return None > > - if dir.endswith('/'): > - return dir + file_name > + if dir_.endswith('/'): > + return dir_ + file_name > else: > - return "%s/%s" % (dir, file_name) > + return "%s/%s" % (dir_, file_name) > -- > 1.7.4.4 > > _______________________________________________ > dev mailing list > [email protected] > http://openvswitch.org/mailman/listinfo/dev > _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
