summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jfr_playoff/dto.py7
-rw-r--r--jfr_playoff/logger.py6
-rw-r--r--jfr_playoff/settings.py4
3 files changed, 13 insertions, 4 deletions
diff --git a/jfr_playoff/dto.py b/jfr_playoff/dto.py
index 44fe8cb..605493a 100644
--- a/jfr_playoff/dto.py
+++ b/jfr_playoff/dto.py
@@ -1,6 +1,9 @@
from math import ceil, floor
import sys
+from jfr_playoff.logger import log_encoding
+
+
def coalesce(*arg):
for el in arg:
if el is not None:
@@ -39,7 +42,7 @@ class Team(object):
return u'%s (%.1f)' % (coalesce(self.name, '<None>'), self.score)
def __repr__(self):
- return unicode(self).encode(sys.stdin.encoding)
+ return unicode(self).encode(log_encoding())
class Match(object):
@@ -61,7 +64,7 @@ class Match(object):
self.id, coalesce(self.link, '<None>'), [unicode(team) for team in self.teams],
u'finished' if self.running < 0 else (
u'%d boards' % self.running))
- ).encode(sys.stdin.encoding)
+ ).encode(log_encoding())
class Phase(object):
diff --git a/jfr_playoff/logger.py b/jfr_playoff/logger.py
index 1218022..3f15c49 100644
--- a/jfr_playoff/logger.py
+++ b/jfr_playoff/logger.py
@@ -1,4 +1,10 @@
import logging as log
+import sys
+
+
+def log_encoding():
+ # if there's no sys.stdin (e.g. console-less GUI), revert to default
+ return sys.stdin.encoding or 'utf8'
class PlayoffLogger:
diff --git a/jfr_playoff/settings.py b/jfr_playoff/settings.py
index b12ffef..d997e42 100644
--- a/jfr_playoff/settings.py
+++ b/jfr_playoff/settings.py
@@ -4,7 +4,7 @@ import readline
import requests
import sys
-from jfr_playoff.logger import PlayoffLogger
+from jfr_playoff.logger import PlayoffLogger, log_encoding
def complete_filename(text, state):
@@ -47,7 +47,7 @@ class PlayoffSettings(object):
readline.parse_and_bind("tab: complete")
readline.set_completer(complete_filename)
self.settings_file = raw_input(
- 'JSON settings file: ').decode(sys.stdin.encoding)
+ 'JSON settings file: ').decode(log_encoding())
if self.settings is None:
PlayoffLogger.get('settings').info(