From 1553e843b34afaf6ee0b402d751d799a16cd13fb Mon Sep 17 00:00:00 2001 From: Nicolas Sebrecht Date: Fri, 8 Jan 2016 17:30:54 +0100 Subject: [PATCH] Revert "Don't output initial blurb in "quiet" mode" This reverts commit a1dc76ae917d93d0c387bbd506faea3487211a6c. Causes a crash when using Blinkenlights UI with -l CLI option. $ ./offlineimap.py -c offlineimap.conf.minimal -u blinkenlights -l foo Traceback (most recent call last): File "./offlineimap.py", line 36, in oi.run() File "/tmp/offlineimap/offlineimap/init.py", line 50, in run options, args = self.__parse_cmd_options() File "/tmp/offlineimap/offlineimap/init.py", line 205, in __parse_cmd_options self.ui.setlogfile(options.logfile) File "/tmp/offlineimap/offlineimap/ui/UIBase.py", line 119, in setlogfile self.logger.info(msg) File "/usr/lib/python2.7/logging/__init__.py", line 1159, in info self._log(INFO, msg, args, **kwargs) File "/usr/lib/python2.7/logging/__init__.py", line 1278, in _log self.handle(record) File "/usr/lib/python2.7/logging/__init__.py", line 1288, in handle self.callHandlers(record) File "/usr/lib/python2.7/logging/__init__.py", line 1328, in callHandlers hdlr.handle(record) File "/usr/lib/python2.7/logging/__init__.py", line 751, in handle self.emit(record) File "/tmp/offlineimap/offlineimap/ui/Curses.py", line 305, in emit color = self.ui.gettf().curses_color AttributeError: 'CursesLogHandler' object has no attribute 'ui' Reported-by: iliastsi Github-issue: #293 Signed-off-by: Nicolas Sebrecht --- offlineimap/ui/UIBase.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/offlineimap/ui/UIBase.py b/offlineimap/ui/UIBase.py index bc53ae6..427c8c7 100644 --- a/offlineimap/ui/UIBase.py +++ b/offlineimap/ui/UIBase.py @@ -107,6 +107,7 @@ class UIBase(object): """Create file handler which logs to file.""" fh = logging.FileHandler(logfile, 'at') + #fh.setLevel(logging.DEBUG) file_formatter = logging.Formatter("%(asctime)s %(levelname)s: " "%(message)s", '%Y-%m-%d %H:%M:%S') fh.setFormatter(file_formatter) @@ -116,7 +117,9 @@ class UIBase(object): msg = "OfflineImap %s starting...\n Python: %s Platform: %s\n "\ "Args: %s"% (offlineimap.__bigversion__, p_ver, sys.platform, " ".join(sys.argv)) - self.logger.info(msg) + record = logging.LogRecord('OfflineImap', logging.INFO, __file__, + None, msg, None, None) + fh.emit(record) def _msg(self, msg): """Display a message."""