On Fri, Oct 25, 2013 at 9:22 AM, Ben Pfaff <b...@nicira.com> wrote: > This suppresses a testsuite failure when the testsuite is run from a > directory whose name contains a non-ASCII character. I'd rather fix the > problem but webpages like the following make it sound difficult or > impossible on Python 2.x: http://stackoverflow.com/a/11742928 > > Signed-off-by: Ben Pfaff <b...@nicira.com> The code looks correct and it does help in fixing the failed tests.
So, looks good to me. > --- > python/ovs/jsonrpc.py | 5 +++-- > python/ovs/vlog.py | 25 ++++++++++++++++++++++++- > 2 files changed, 27 insertions(+), 3 deletions(-) > > diff --git a/python/ovs/jsonrpc.py b/python/ovs/jsonrpc.py > index c1540eb..6e7a2cc 100644 > --- a/python/ovs/jsonrpc.py > +++ b/python/ovs/jsonrpc.py > @@ -1,4 +1,4 @@ > -# Copyright (c) 2010, 2011, 2012 Nicira, Inc. > +# Copyright (c) 2010, 2011, 2012, 2013 Nicira, Inc. > # > # Licensed under the Apache License, Version 2.0 (the "License"); > # you may not use this file except in compliance with the License. > @@ -226,7 +226,8 @@ class Connection(object): > return self.received_bytes > > def __log_msg(self, title, msg): > - vlog.dbg("%s: %s %s" % (self.name, title, msg)) > + if vlog.dbg_is_enabled(): > + vlog.dbg("%s: %s %s" % (self.name, title, msg)) > > def send(self, msg): > if self.status: > diff --git a/python/ovs/vlog.py b/python/ovs/vlog.py > index f7ace66..d6e0a2b 100644 > --- a/python/ovs/vlog.py > +++ b/python/ovs/vlog.py > @@ -1,5 +1,5 @@ > > -# Copyright (c) 2011, 2012 Nicira, Inc. > +# Copyright (c) 2011, 2012, 2013 Nicira, Inc. > # > # Licensed under the Apache License, Version 2.0 (the "License"); > # you may not use this file except in compliance with the License. > @@ -87,6 +87,29 @@ class Vlog: > def dbg(self, message, **kwargs): > self.__log("DBG", message, **kwargs) > > + def __is_enabled(self, level): > + level = LEVELS.get(level.lower(), logging.DEBUG) > + for f, f_level in Vlog.__mfl[self.name].iteritems(): > + f_level = LEVELS.get(f_level, logging.CRITICAL) > + if level >= f_level: > + return True > + return False > + > + def emer_is_enabled(self): > + return self.__is_enabled("EMER") > + > + def err_is_enabled(self): > + return self.__is_enabled("ERR") > + > + def warn_is_enabled(self): > + return self.__is_enabled("WARN") > + > + def info_is_enabled(self): > + return self.__is_enabled("INFO") > + > + def dbg_is_enabled(self): > + return self.__is_enabled("DBG") > + > def exception(self, message): > """Logs 'message' at ERR log level. Includes a backtrace when in > exception context.""" > -- > 1.7.10.4 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev