|
|
|
@ -24,6 +24,7 @@ from os.path import join as pathjoin, exists as pathexists
|
|
|
|
|
from shutil import copy as copyfile, move as movefile
|
|
|
|
|
from optparse import OptionParser
|
|
|
|
|
from threading import Lock
|
|
|
|
|
from functools import reduce
|
|
|
|
|
|
|
|
|
|
# fix ecre in email module
|
|
|
|
|
email.header.ecre = re.compile(r'''
|
|
|
|
@ -63,7 +64,7 @@ class Logger:
|
|
|
|
|
self.logfile.flush()
|
|
|
|
|
except:
|
|
|
|
|
sys.stderr.write(strftime("%Y%m%d%H%M%S ") +
|
|
|
|
|
"".join(apply(traceback.format_exception, sys.exc_info())))
|
|
|
|
|
"".join(traceback.format_exception(*sys.exc_info())))
|
|
|
|
|
self.lock.release()
|
|
|
|
|
|
|
|
|
|
def printDEBUG(self,s):
|
|
|
|
@ -96,7 +97,7 @@ class Logger:
|
|
|
|
|
def dbg_except():
|
|
|
|
|
"""Debug function, for try-except block"""
|
|
|
|
|
Logger().printLOG(strftime("%Y%m%d%H%M%S ") +
|
|
|
|
|
"".join(apply(traceback.format_exception, sys.exc_info())))
|
|
|
|
|
"".join(traceback.format_exception(*sys.exc_info())))
|
|
|
|
|
|
|
|
|
|
def strstime(format="%Y-%m-%d_%H:%M",seconds=0):
|
|
|
|
|
return strftime(format, localtime(seconds))
|
|
|
|
@ -186,7 +187,7 @@ class Letter:
|
|
|
|
|
try:
|
|
|
|
|
if charset and charset[0] and not charset[0].lower() in ['utf-8','utf8']:
|
|
|
|
|
letter_text = letter_text.decode(charset[0]).encode('utf-8')
|
|
|
|
|
except Exception,e:
|
|
|
|
|
except Exception as e:
|
|
|
|
|
Logger().printDEBUG("wrong decode from %s: %s" % (charset[0], e))
|
|
|
|
|
return letter_text
|
|
|
|
|
|
|
|
|
|