Redirect some print statments to stderr

Otherwise they errors will not show up if the console output is
redirected to a file
This commit is contained in:
Philipp Hörist 2019-02-16 10:36:27 +01:00
parent c5d2f8bdab
commit c0178db779
3 changed files with 8 additions and 7 deletions

View File

@ -151,7 +151,7 @@ def ngettext(s_sing, s_plural, n, replace_sing=None, replace_plural=None):
try: try:
locale.setlocale(locale.LC_ALL, '') locale.setlocale(locale.LC_ALL, '')
except locale.Error as error: except locale.Error as error:
print(error) print(error, file=sys.stderr)
try: try:
LANG = get_default_lang() LANG = get_default_lang()
@ -161,7 +161,7 @@ try:
os.environ['LANG'] = LANG os.environ['LANG'] = LANG
print('Found default language: %s' % LANG) print('Found default language: %s' % LANG)
except Exception as error: except Exception as error:
print('Failed to determine default language') print('Failed to determine default language', file=sys.stderr)
import traceback import traceback
traceback.print_exc() traceback.print_exc()
@ -177,6 +177,6 @@ for dir_ in iter_locale_dirs():
else: else:
break break
else: else:
print('No translations found') print('No translations found', file=sys.stderr)
print('Dirs searched: %s' % get_locale_dirs()) print('Dirs searched: %s' % get_locale_dirs(), file=sys.stderr)
_ = _translation.gettext _ = _translation.gettext

View File

@ -28,7 +28,7 @@ def parseLogLevel(arg):
return int(arg) return int(arg)
if arg.isupper() and hasattr(logging, arg): if arg.isupper() and hasattr(logging, arg):
return getattr(logging, arg) return getattr(logging, arg)
print(_('%s is not a valid loglevel') % repr(arg)) print(_('%s is not a valid loglevel') % repr(arg), file=sys.stderr)
return 0 return 0
def parseLogTarget(arg): def parseLogTarget(arg):
@ -69,7 +69,8 @@ def parseAndSetLogLevels(arg):
target = parseLogTarget(target.strip()) target = parseLogTarget(target.strip())
if target: if target:
logging.getLogger(target).setLevel(level) logging.getLogger(target).setLevel(level)
print("Logger %s level set to %d" % (target, level)) print("Logger %s level set to %d" % (target, level),
file=sys.stderr)
class colors: class colors:

View File

@ -85,7 +85,7 @@ class ExceptionDialog():
traceback.print_exception(type_, value, tb, None, trace) traceback.print_exception(type_, value, tb, None, trace)
self.text = self.get_issue_text(trace.getvalue()) self.text = self.get_issue_text(trace.getvalue())
buffer_.set_text(self.text) buffer_.set_text(self.text)
print(self.text) print(self.text, file=sys.stderr)
self.exception_view.set_editable(False) self.exception_view.set_editable(False)
self.dialog.show() self.dialog.show()
if __name__ == '__main__': if __name__ == '__main__':