more style consistency
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
@ -23,7 +23,7 @@ from offlineimap import banner
|
||||
from offlineimap.ui.UIBase import UIBase
|
||||
|
||||
class TTYFormatter(logging.Formatter):
|
||||
"""Specific Formatter that adds thread information to the log output"""
|
||||
"""Specific Formatter that adds thread information to the log output."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
#super() doesn't work in py2.6 as 'logging' uses old-style class
|
||||
@ -31,7 +31,8 @@ class TTYFormatter(logging.Formatter):
|
||||
self._last_log_thread = None
|
||||
|
||||
def format(self, record):
|
||||
"""Override format to add thread information"""
|
||||
"""Override format to add thread information."""
|
||||
|
||||
#super() doesn't work in py2.6 as 'logging' uses old-style class
|
||||
log_str = logging.Formatter.format(self, record)
|
||||
# If msg comes from a different thread than our last, prepend
|
||||
@ -44,7 +45,7 @@ class TTYFormatter(logging.Formatter):
|
||||
self._last_log_thread = t_name
|
||||
log_str = "%s:\n %s" % (t_name, log_str)
|
||||
else:
|
||||
log_str = " %s" % log_str
|
||||
log_str = " %s"% log_str
|
||||
return log_str
|
||||
|
||||
|
||||
@ -69,15 +70,15 @@ class TTYUI(UIBase):
|
||||
return ch
|
||||
|
||||
def isusable(self):
|
||||
"""TTYUI is reported as usable when invoked on a terminal"""
|
||||
"""TTYUI is reported as usable when invoked on a terminal."""
|
||||
|
||||
return sys.stdout.isatty() and sys.stdin.isatty()
|
||||
|
||||
def getpass(self, accountname, config, errmsg=None):
|
||||
"""TTYUI backend is capable of querying the password"""
|
||||
"""TTYUI backend is capable of querying the password."""
|
||||
|
||||
if errmsg:
|
||||
self.warn("%s: %s" % (accountname, errmsg))
|
||||
self.warn("%s: %s"% (accountname, errmsg))
|
||||
self._log_con_handler.acquire() # lock the console output
|
||||
try:
|
||||
return getpass("Enter password for account '%s': " % accountname)
|
||||
@ -87,7 +88,7 @@ class TTYUI(UIBase):
|
||||
def mainException(self):
|
||||
if isinstance(sys.exc_info()[1], KeyboardInterrupt):
|
||||
self.logger.warn("Timer interrupted at user request; program "
|
||||
"terminating.\n")
|
||||
"terminating.\n")
|
||||
self.terminate()
|
||||
else:
|
||||
UIBase.mainException(self)
|
||||
@ -100,12 +101,11 @@ class TTYUI(UIBase):
|
||||
|
||||
This implementation in UIBase does not support this, but some
|
||||
implementations return 0 for successful sleep and 1 for an
|
||||
'abort', ie a request to sync immediately.
|
||||
"""
|
||||
'abort', ie a request to sync immediately."""
|
||||
|
||||
if sleepsecs > 0:
|
||||
if remainingsecs//60 != (remainingsecs-sleepsecs)//60:
|
||||
self.logger.info("Next refresh in %.1f minutes" % (
|
||||
remainingsecs/60.0))
|
||||
remainingsecs/60.0))
|
||||
time.sleep(sleepsecs)
|
||||
return 0
|
||||
|
@ -393,11 +393,11 @@ class UIBase(object):
|
||||
uid, dest, num, num_to_set, ", ".join(labels)))
|
||||
|
||||
def collectingdata(self, uidlist, source):
|
||||
if uidlist:
|
||||
self.logger.info("Collecting data from %d messages on %s" % (
|
||||
if uidlist:
|
||||
self.logger.info("Collecting data from %d messages on %s"% (
|
||||
len(uidlist), source))
|
||||
else:
|
||||
self.logger.info("Collecting data from messages on %s" % source)
|
||||
else:
|
||||
self.logger.info("Collecting data from messages on %s"% source)
|
||||
|
||||
def serverdiagnostics(self, repository, type):
|
||||
"""Connect to repository and output useful information for debugging."""
|
||||
|
@ -28,7 +28,8 @@ class DebuggingLock:
|
||||
def acquire(self, blocking = 1):
|
||||
self.print_tb("Acquire lock")
|
||||
self.lock.acquire(blocking)
|
||||
self.logmsg("===== %s: Thread %s acquired lock\n" % (self.name, currentThread().getName()))
|
||||
self.logmsg("===== %s: Thread %s acquired lock\n"%
|
||||
(self.name, currentThread().getName()))
|
||||
|
||||
def release(self):
|
||||
self.print_tb("Release lock")
|
||||
@ -41,7 +42,7 @@ class DebuggingLock:
|
||||
loglock.release()
|
||||
|
||||
def print_tb(self, msg):
|
||||
self.logmsg(".... %s: Thread %s attempting to %s\n" % \
|
||||
self.logmsg(".... %s: Thread %s attempting to %s\n"% \
|
||||
(self.name, currentThread().getName(), msg) + \
|
||||
"\n".join(traceback.format_list(traceback.extract_stack())))
|
||||
|
||||
|
Reference in New Issue
Block a user