fixed some problems wth widget logging, thanks Paolo Pastori
This commit is contained in:
+13
-9
@@ -704,14 +704,9 @@ def start():
|
|||||||
run_system_tests(options)
|
run_system_tests(options)
|
||||||
|
|
||||||
if options.quiet:
|
if options.quiet:
|
||||||
# to prevent writes on stdout set a null stream
|
# mute existing loggers, to do that iterate
|
||||||
class NullFile(object):
|
# over all loggers (root logger included) and remove
|
||||||
def write(self, x):
|
# attached logging.StreamHandler instances currently
|
||||||
pass
|
|
||||||
sys.stdout = NullFile()
|
|
||||||
# but still has to mute existing loggers, to do that iterate
|
|
||||||
# over all existing loggers (root logger included) and remove
|
|
||||||
# all attached logging.StreamHandler instances currently
|
|
||||||
# streaming on sys.stdout or sys.stderr
|
# streaming on sys.stdout or sys.stderr
|
||||||
loggers = [logging.getLogger()]
|
loggers = [logging.getLogger()]
|
||||||
loggers.extend(logging.Logger.manager.loggerDict.values())
|
loggers.extend(logging.Logger.manager.loggerDict.values())
|
||||||
@@ -721,9 +716,18 @@ def start():
|
|||||||
if isinstance(h, logging.StreamHandler) and \
|
if isinstance(h, logging.StreamHandler) and \
|
||||||
h.stream in (sys.stdout, sys.stderr):
|
h.stream in (sys.stdout, sys.stderr):
|
||||||
l.removeHandler(h)
|
l.removeHandler(h)
|
||||||
|
# this is to avoid the warning
|
||||||
|
# ``No handlers could be found for logger "..."``
|
||||||
|
# emitted by logging module when no handler is found
|
||||||
|
logging.Logger.manager.emittedNoHandlerWarning = 1
|
||||||
|
# to prevent writes on stdout set a null stream
|
||||||
|
class NullFile(object):
|
||||||
|
def write(self, x):
|
||||||
|
pass
|
||||||
|
sys.stdout = NullFile()
|
||||||
# NOTE: stderr.write() is still working
|
# NOTE: stderr.write() is still working
|
||||||
|
|
||||||
if not options.no_banner:
|
elif not options.no_banner:
|
||||||
# banner
|
# banner
|
||||||
print(ProgramName)
|
print(ProgramName)
|
||||||
print(ProgramAuthor)
|
print(ProgramAuthor)
|
||||||
|
|||||||
Reference in New Issue
Block a user