本文整理汇总了Python中Milter.set_exception_policy方法的典型用法代码示例。如果您正苦于以下问题:Python Milter.set_exception_policy方法的具体用法?Python Milter.set_exception_policy怎么用?Python Milter.set_exception_policy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Milter
的用法示例。
在下文中一共展示了Milter.set_exception_policy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_exception_policy [as 别名]
def main():
# Load the whitelist into memory
WhiteListLoad()
HashTableLoad()
thread_pool = create_and_start_worker_threads()
# Register to have the Milter factory create instances of the class:
Milter.factory = MacroMilter
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags) # tell Sendmail which features we use
# start milter processing
print "%s Macro milter startup - Version %s" % (time.strftime('%d.%b.%Y %H:%M:%S'), __version__)
sys.stdout.flush()
# set the "last" fall back to ACCEPT if exception occur
Milter.set_exception_policy(Milter.ACCEPT)
# start the milter
Milter.runmilter("MacroMilter", SOCKET, TIMEOUT)
shutdown_worker_threads(thread_pool)
cleanup_queues()
print "%s Macro milter shutdown" % time.strftime('%d.%b.%Y %H:%M:%S')
示例2: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_exception_policy [as 别名]
def main():
# banner
print('mraptor_milter v%s - http://decalage.info/python/oletools' % __version__)
print('logging to file %s' % LOGFILE_PATH)
print('Press Ctrl+C to stop.')
# make sure the log directory exists:
try:
os.makedirs(LOGFILE_DIR)
except:
pass
# Add the log message handler to the logger
# log to files rotating once a day:
handler = logging.handlers.TimedRotatingFileHandler(LOGFILE_PATH, when='D', encoding='utf8')
# create formatter and add it to the handlers
formatter = logging.Formatter('%(asctime)s - %(levelname)8s: %(message)s')
handler.setFormatter(formatter)
log.addHandler(handler)
# enable logging:
log.setLevel(logging.DEBUG)
log.info('Starting mraptor_milter v%s - listening on %s' % (__version__, SOCKET))
log.debug('Python version: %s' % sys.version)
# Register to have the Milter factory create instances of the class:
Milter.factory = MacroRaptorMilter
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags) # tell Sendmail which features we use
# set the "last" fall back to ACCEPT if exception occur
Milter.set_exception_policy(Milter.ACCEPT)
# start the milter
Milter.runmilter("mraptor_milter", SOCKET, TIMEOUT)
log.info('Stopping mraptor_milter.')
示例3: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_exception_policy [as 别名]
def main():
# Load the whitelist into memory
WhiteListLoad()
HashTableLoad()
# create helper threads
bt = Thread(target=background)
perft = Thread(target=writeperformacedata)
ha = Thread(target=writehashtofile)
ex = Thread(target=writeExData)
# start helper threads
ex.start()
perft.start()
bt.start()
ha.start()
# Register to have the Milter factory create instances of the class:
Milter.factory = MacroMilter
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags) # tell Sendmail which features we use
# start milter processing
print "%s Macro milter startup - Version %s" % (time.strftime('%d.%b.%Y %H:%M:%S'), __version__)
sys.stdout.flush()
# set the "last" fall back to ACCEPT if exception occur
Milter.set_exception_policy(Milter.ACCEPT)
# start the milter
Milter.runmilter("MacroMilter",SOCKET,TIMEOUT)
# wait for helper threads
bt.join() # stop logging thread
perft.join() # stop performance data thread
ha.join() # stop hash data thread
ex.join() # stop filename thread - obsolete - delete in next version
# cleanup the queues
logq.put(None)
extension_data.put(None)
hash_to_write.put(None)
performace_data.put(None)
print "%s Macro milter shutdown" % time.strftime('%d.%b.%Y %H:%M:%S')
示例4: main
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_exception_policy [as 别名]
def main():
# TODO: log to file with rotation
logging.basicConfig(format='%(levelname)8s: %(message)s', level=logging.DEBUG)
logging.info('Starting MacroRaptorMilter - listening on %s' % SOCKET)
logging.info('Press Ctrl+C to stop.')
# Register to have the Milter factory create instances of the class:
Milter.factory = MacroRaptorMilter
flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
flags += Milter.ADDRCPT
flags += Milter.DELRCPT
Milter.set_flags(flags) # tell Sendmail which features we use
# set the "last" fall back to ACCEPT if exception occur
Milter.set_exception_policy(Milter.ACCEPT)
# start the milter
Milter.runmilter("MacroRaptorMilter", SOCKET, TIMEOUT)
logging.info('Stopping MacroRaptorMilter.')
示例5: read_config
# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import set_exception_policy [as 别名]
"%s has been blacklisted by %s." % (q.s,receiver))
return Milter.REJECT
self.add_header('Received-SPF',q.get_header(res,receiver),0)
if hres and q.h != q.o:
self.add_header('X-Hello-SPF',hres,0)
return Milter.CONTINUE
if __name__ == "__main__":
Milter.factory = spfMilter
Milter.set_flags(Milter.CHGHDRS + Milter.ADDHDRS)
global config
config = read_config(
['spfmilter.cfg','/etc/mail/spfmilter.cfg','/etc/postfix/spfmilter.cfg'])
ue = config.untrapped_exception.upper()
if ue == 'CONTINUE':
Milter.set_exception_policy(Milter.CONTINUE)
elif ue == 'REJECT':
Milter.set_exception_policy(Milter.REJECT)
elif ue == 'TEMPFAIL':
Milter.set_exception_policy(Milter.TEMPFAIL)
else:
print("WARNING: invalid untrapped_exception policy: %s"%ue)
miltername = config.miltername
socketname = config.socketname
# FIXME: set process umask based on config
print("""To use this with sendmail, add the following to sendmail.cf:
O InputMailFilters=%s
X%s, S=local:%s