From 3eb9321c53939d689203ba261e96e4152d8a8089 Mon Sep 17 00:00:00 2001 From: b3yond Date: Tue, 25 Jul 2017 15:13:54 +0200 Subject: [PATCH] reverted so called "fix" and try-excepted the problem --- retootbot.py | 10 +++++++--- retweetbot.py | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/retootbot.py b/retootbot.py index 75df2a5..b655750 100644 --- a/retootbot.py +++ b/retootbot.py @@ -39,11 +39,15 @@ class RetootBot(object): time = str(datetime.datetime.now()) if tb: message = message + " The traceback is located at " + os.path.join("logs" + time) - with open(os.path.join("logs", time, encoding='utf-8'), 'w+') as f: + with open(os.path.join("logs", time), 'w+') as f: f.write(tb) line = "[" + time + "] "+ message + "\n" - with open(self.logpath, 'a', encoding='utf-8') as f: - f.write(line) + with open(self.logpath, 'a') as f: + try: + f.write(line) + except UnicodeEncodeError: + self.log("Failed to save log message due to UTF-8 error. ") + traceback.print_exc() print line, def register(self): diff --git a/retweetbot.py b/retweetbot.py index a60e071..aab66c7 100644 --- a/retweetbot.py +++ b/retweetbot.py @@ -85,11 +85,15 @@ class RetweetBot(object): time = str(datetime.datetime.now()) if tb: message = message + " The traceback is located at " + os.path.join("logs" + time) - with open(os.path.join("logs", time, encoding='utf-8'), 'w+') as f: + with open(os.path.join("logs", time), 'w+') as f: f.write(tb) line = "[" + time + "] "+ message + "\n" - with open(self.logpath, 'a', encoding='utf-8') as f: - f.write(line) + with open(self.logpath, 'a') as f: + try: + f.write(line) + except UnicodeEncodeError: + self.log("Failed to save log message due to UTF-8 error. ") + traceback.print_exc() print line, def get_history(self, path):