Machine.py; more consistent style
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
bd0461a986
commit
f2010cdfb0
@ -45,12 +45,12 @@ class MachineLogFormatter(logging.Formatter):
|
||||
command = ""
|
||||
whoami = currentThread().getName()
|
||||
|
||||
prefix = "%s:%s" % (command, urlencode([('', whoami)])[1:])
|
||||
return "%s:%s:%s" % (severity, prefix, urlencode([('', line)])[1:])
|
||||
prefix = "%s:%s"% (command, urlencode([('', whoami)])[1:])
|
||||
return "%s:%s:%s"% (severity, prefix, urlencode([('', line)])[1:])
|
||||
|
||||
|
||||
class MachineUI(UIBase):
|
||||
def __init__(s, config, loglevel = logging.INFO):
|
||||
def __init__(s, config, loglevel=logging.INFO):
|
||||
super(MachineUI, s).__init__(config, loglevel)
|
||||
s._log_con_handler.createLock()
|
||||
"""lock needed to block on password input"""
|
||||
@ -74,7 +74,7 @@ class MachineUI(UIBase):
|
||||
def _msg(s, msg):
|
||||
s._printData(s.logger.info, '_display', msg)
|
||||
|
||||
def warn(s, msg, minor = 0):
|
||||
def warn(s, msg, minor=0):
|
||||
# TODO, remove and cleanup the unused minor stuff
|
||||
s._printData(s.logger.warning, '', msg)
|
||||
|
||||
@ -96,68 +96,68 @@ class MachineUI(UIBase):
|
||||
s._printData(s.logger.info, 'acctdone', accountname)
|
||||
|
||||
def validityproblem(s, folder):
|
||||
s._printData(s.logger.warning, 'validityproblem', "%s\n%s\n%s\n%s" % \
|
||||
s._printData(s.logger.warning, 'validityproblem', "%s\n%s\n%s\n%s"%
|
||||
(folder.getname(), folder.getrepository().getname(),
|
||||
folder.get_saveduidvalidity(), folder.get_uidvalidity()))
|
||||
|
||||
def connecting(s, hostname, port):
|
||||
s._printData(s.logger.info, 'connecting', "%s\n%s" % (hostname, str(port)))
|
||||
s._printData(s.logger.info, 'connecting', "%s\n%s"% (hostname, str(port)))
|
||||
|
||||
def syncfolders(s, srcrepos, destrepos):
|
||||
s._printData(s.logger.info, 'syncfolders', "%s\n%s" % (s.getnicename(srcrepos),
|
||||
s._printData(s.logger.info, 'syncfolders', "%s\n%s"% (s.getnicename(srcrepos),
|
||||
s.getnicename(destrepos)))
|
||||
|
||||
def syncingfolder(s, srcrepos, srcfolder, destrepos, destfolder):
|
||||
s._printData(s.logger.info, 'syncingfolder', "%s\n%s\n%s\n%s\n" % \
|
||||
s._printData(s.logger.info, 'syncingfolder', "%s\n%s\n%s\n%s\n"%
|
||||
(s.getnicename(srcrepos), srcfolder.getname(),
|
||||
s.getnicename(destrepos), destfolder.getname()))
|
||||
|
||||
def loadmessagelist(s, repos, folder):
|
||||
s._printData(s.logger.info, 'loadmessagelist', "%s\n%s" % (s.getnicename(repos),
|
||||
s._printData(s.logger.info, 'loadmessagelist', "%s\n%s"% (s.getnicename(repos),
|
||||
folder.getvisiblename()))
|
||||
|
||||
def messagelistloaded(s, repos, folder, count):
|
||||
s._printData(s.logger.info, 'messagelistloaded', "%s\n%s\n%d" % \
|
||||
s._printData(s.logger.info, 'messagelistloaded', "%s\n%s\n%d"%
|
||||
(s.getnicename(repos), folder.getname(), count))
|
||||
|
||||
def syncingmessages(s, sr, sf, dr, df):
|
||||
s._printData(s.logger.info, 'syncingmessages', "%s\n%s\n%s\n%s\n" % \
|
||||
s._printData(s.logger.info, 'syncingmessages', "%s\n%s\n%s\n%s\n"%
|
||||
(s.getnicename(sr), sf.getname(), s.getnicename(dr),
|
||||
df.getname()))
|
||||
|
||||
def copyingmessage(s, uid, num, num_to_copy, srcfolder, destfolder):
|
||||
s._printData(s.logger.info, 'copyingmessage', "%d\n%s\n%s\n%s[%s]" % \
|
||||
s._printData(s.logger.info, 'copyingmessage', "%d\n%s\n%s\n%s[%s]"%
|
||||
(uid, s.getnicename(srcfolder), srcfolder.getname(),
|
||||
s.getnicename(destfolder), destfolder))
|
||||
|
||||
def folderlist(s, list):
|
||||
return ("\f".join(["%s\t%s" % (s.getnicename(x), x.getname()) for x in list]))
|
||||
return ("\f".join(["%s\t%s"% (s.getnicename(x), x.getname()) for x in list]))
|
||||
|
||||
def uidlist(s, list):
|
||||
return ("\f".join([str(u) for u in list]))
|
||||
|
||||
def deletingmessages(s, uidlist, destlist):
|
||||
ds = s.folderlist(destlist)
|
||||
s._printData(s.logger.info, 'deletingmessages', "%s\n%s" % (s.uidlist(uidlist), ds))
|
||||
s._printData(s.logger.info, 'deletingmessages', "%s\n%s"% (s.uidlist(uidlist), ds))
|
||||
|
||||
def addingflags(s, uidlist, flags, dest):
|
||||
s._printData(s.logger.info, "addingflags", "%s\n%s\n%s" % (s.uidlist(uidlist),
|
||||
s._printData(s.logger.info, "addingflags", "%s\n%s\n%s"% (s.uidlist(uidlist),
|
||||
"\f".join(flags),
|
||||
dest))
|
||||
|
||||
def deletingflags(s, uidlist, flags, dest):
|
||||
s._printData(s.logger.info, 'deletingflags', "%s\n%s\n%s" % (s.uidlist(uidlist),
|
||||
s._printData(s.logger.info, 'deletingflags', "%s\n%s\n%s"% (s.uidlist(uidlist),
|
||||
"\f".join(flags),
|
||||
dest))
|
||||
|
||||
def threadException(s, thread):
|
||||
s._printData(s.logger.warning, 'threadException', "%s\n%s" % \
|
||||
s._printData(s.logger.warning, 'threadException', "%s\n%s"%
|
||||
(thread.getName(), s.getThreadExceptionString(thread)))
|
||||
s.delThreadDebugLog(thread)
|
||||
s.terminate(100)
|
||||
|
||||
def terminate(s, exitstatus = 0, errortitle = '', errormsg = ''):
|
||||
s._printData(s.logger.info, 'terminate', "%d\n%s\n%s" % (exitstatus, errortitle, errormsg))
|
||||
def terminate(s, exitstatus=0, errortitle='', errormsg=''):
|
||||
s._printData(s.logger.info, 'terminate', "%d\n%s\n%s"% (exitstatus, errortitle, errormsg))
|
||||
sys.exit(exitstatus)
|
||||
|
||||
def mainException(s):
|
||||
@ -168,16 +168,16 @@ class MachineUI(UIBase):
|
||||
UIBase.threadExited(s, thread)
|
||||
|
||||
def sleeping(s, sleepsecs, remainingsecs):
|
||||
s._printData(s.logger.info, 'sleeping', "%d\n%d" % (sleepsecs, remainingsecs))
|
||||
s._printData(s.logger.info, 'sleeping', "%d\n%d"% (sleepsecs, remainingsecs))
|
||||
if sleepsecs > 0:
|
||||
time.sleep(sleepsecs)
|
||||
return 0
|
||||
|
||||
|
||||
def getpass(s, accountname, config, errmsg = None):
|
||||
def getpass(s, accountname, config, errmsg=None):
|
||||
if errmsg:
|
||||
s._printData(s.logger.warning,
|
||||
'getpasserror', "%s\n%s" % (accountname, errmsg),
|
||||
'getpasserror', "%s\n%s"% (accountname, errmsg),
|
||||
False)
|
||||
|
||||
s._log_con_handler.acquire() # lock the console output
|
||||
|
Loading…
Reference in New Issue
Block a user