当前位置: 首页>>代码示例>>Python>>正文


Python Milter.runmilter方法代码示例

本文整理汇总了Python中Milter.runmilter方法的典型用法代码示例。如果您正苦于以下问题:Python Milter.runmilter方法的具体用法?Python Milter.runmilter怎么用?Python Milter.runmilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Milter的用法示例。


在下文中一共展示了Milter.runmilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [as 别名]
def main():
  # Run as a specific user
  if run_as_user != None:
    run_as_uid = getpwnam(run_as_user).pw_uid
    run_as_gid = getpwnam(run_as_user).pw_gid
    print "%s running as %s (uid=%s,gid=%s)" % (time.strftime('%Y%b%d %H:%M:%S'), run_as_user, run_as_uid, run_as_gid)
    # always set gid first, because once we've set uid, we can't set gid anymore
    os.setgid(run_as_gid)
    os.setuid(run_as_uid)

  # Log startup
  print "%s milter startup" % time.strftime('%Y%b%d %H:%M:%S')
  sys.stdout.flush()

  # Handle log printing in the background
  bt = Thread(target=background)
  bt.start()

  # Register to have the Milter factory create instances of your class:
  Milter.factory = MilterSysUser
  #Milter.set_flags(Milter.ADDHDRS) # we only need to add a header

  flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
  flags += Milter.ADDRCPT
  flags += Milter.DELRCPT
  Milter.set_flags(flags)       # tell Sendmail which features we use

  Milter.runmilter("pythonfilter", socketname, timeout)

  # Wait for logger to complete
  logq.put(None)
  bt.join()
  print "%s milter shutdown" % time.strftime('%Y%b%d %H:%M:%S')
开发者ID:mensink,项目名称:milter-sysuser,代码行数:35,代码来源:milter-sysuser.py

示例2: main

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [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.')
开发者ID:hutton,项目名称:oletools,代码行数:37,代码来源:mraptor_milter.py

示例3: main

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [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')
开发者ID:sbidy,项目名称:MacroMilter,代码行数:28,代码来源:macromilter.py

示例4: run

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [as 别名]
 def run(self):
     utils.log_to_syslog()
     logger.info('DSPAM Milter startup (v{})'.format(VERSION))
     self.configure()
     utils.daemonize(self.pidfile)
     Milter.factory = DspamMilter
     Milter.runmilter('DspamMilter', self.socket, self.timeout)
     logger.info('DSPAM Milter shutdown (v{})'.format(VERSION))
     logging.shutdown()
开发者ID:cirrax,项目名称:pydspam,代码行数:11,代码来源:milter.py

示例5: main

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [as 别名]
def main():
  bt = Thread()
  bt.start()
  timeout = 60
  # Register with Milter factory 
  Milter.factory = pgpMilter
  # we don't modify mails, so no flags
  Milter.set_flags(0)
  Milter.runmilter("pgpmilter",socket,timeout)
  bt.join()
开发者ID:glamrock,项目名称:pgpmilter,代码行数:12,代码来源:pgpmilter.py

示例6: main

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [as 别名]
def main():
  socketname = "/var/run/nomixsock"
  timeout = 600
  # Register to have the Milter factory create instances of your class:
  Milter.factory = NoMixMilter
  print("%s milter startup" % time.strftime('%Y%b%d %H:%M:%S'))
  sys.stdout.flush()
  Milter.runmilter("nomixfilter",socketname,timeout)
  logq.put(None)
  bt.join()
  print("%s nomix milter shutdown" % time.strftime('%Y%b%d %H:%M:%S'))
开发者ID:sdgathman,项目名称:pymilter,代码行数:13,代码来源:milter-nomix.py

示例7: main

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [as 别名]
def main():
    bt = Thread(target=background)
    bt.start()
    socketname = "/var/run/pagure/paguresock"
    timeout = 600
    # Register to have the Milter factory create instances of your class:
    Milter.factory = PagureMilter
    print "%s pagure milter startup" % time.strftime("%Y%b%d %H:%M:%S")
    sys.stdout.flush()
    Milter.runmilter("paguremilter", socketname, timeout)
    logq.put(None)
    bt.join()
    print "%s pagure milter shutdown" % time.strftime("%Y%b%d %H:%M:%S")
开发者ID:DhritiShikhar,项目名称:pagure,代码行数:15,代码来源:comment_email_milter.py

示例8: main

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [as 别名]
def main():
  parser = OptionParser()
  parser.add_option('-s', '--socket', dest='socket', help='Socket to listen (e.g. inet:[email protected])')
  parser.add_option('-t', '--timeout', type='int', dest='timeout', default='10', help='MTA timeout (default is 10 sec)')
  (options, args) = parser.parse_args()
  if not options.socket:
    parser.print_help()
    sys.exit(0)
    
  Milter.factory = TuMilter
  print "%s TuMilter startup" % time.strftime('%Y %b %d %H:%M:%S')
  sys.stdout.flush()
  Milter.runmilter("tumilter",options.socket,options.timeout)
开发者ID:k0ste,项目名称:tumilter,代码行数:15,代码来源:tumilter.py

示例9: main

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [as 别名]
def main():
    os.umask(007)
    Milter.set_flags(  Milter.QUARANTINE
                     + Milter.CHGHDRS
                     + Milter.DELRCPT
                     + Milter.ADDRCPT
                     + Milter.CHGFROM)

    config = getConfig()

    def instantiate():
        return DMARCMilter(config)

    Milter.factory = instantiate
    Milter.runmilter("dmarc_milter", config.socket, config.timeout)
开发者ID:matthias-mo,项目名称:dmarc_milter,代码行数:17,代码来源:dmarc.py

示例10: main

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [as 别名]
def main():
  bt = Thread(target=background)
  bt.start()
  socketname = "/home/stuart/pythonsock"
  timeout = 600
  # Register to have the Milter factory create instances of your class:
  Milter.factory = myMilter
  flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
  flags += Milter.ADDRCPT
  flags += Milter.DELRCPT
  Milter.set_flags(flags)       # tell Sendmail which features we use
  print("%s milter startup" % time.strftime('%Y%b%d %H:%M:%S'))
  sys.stdout.flush()
  Milter.runmilter("pythonfilter",socketname,timeout)
  logq.put(None)
  bt.join()
  print("%s bms milter shutdown" % time.strftime('%Y%b%d %H:%M:%S'))
开发者ID:sdgathman,项目名称:pymilter,代码行数:19,代码来源:milter-template.py

示例11: main

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [as 别名]
def main():
  bt = Thread(target=background)
  bt.start()
  socketname = "/home/stuart/pythonsock"
  timeout = 600
 
  Milter.factory = myMilter
  flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
  flags += Milter.ADDRCPT
  flags += Milter.DELRCPT
  Milter.set_flags(flags)      
  print "%s milter startup" % time.strftime('%Y%b%d %H:%M:%S')
  sys.stdout.flush()
  Milter.runmilter("pythonfilter",socketname,timeout)
  logq.put(None)
  bt.join()
  print "%s bms milter shutdown" % time.strftime('%Y%b%d %H:%M:%S')
开发者ID:naruto0323,项目名称:Milters,代码行数:19,代码来源:timeanduser.py

示例12: main

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [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')
开发者ID:Gulaschcowboy,项目名称:MacroMilter,代码行数:48,代码来源:macromilter.py

示例13: main

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [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.')
开发者ID:elafonizi,项目名称:oletools,代码行数:20,代码来源:mraptor_milter.py

示例14: main

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [as 别名]
def main(args=None):
	import argparse
	parser = argparse.ArgumentParser(
		description='Ad-hoc dspam milter that does --deliver=summary'
			' and only adds result as header, never rejecting or dropping messages.' )
	parser.add_argument('socket',
		nargs='?', default='local:/tmp/dspam_milter.sock',
		help='libmilter-format socket spec to listen on (default: %(default)s).'
			' Examples: local:/tmp/dspam_milter.sock, inet:[email protected], inet6:[email protected]')
	parser.add_argument('-u', '--user',
		metavar='name', default='dspam',
		help='--user parameter to pass argument to dspam client (default: %(default)s).'
			' dspam-recognized group names can be passed here as well.'
			' Affects spam classification groups and permissions. Empty - dont pass.')
	parser.add_argument('-t', '--timeout',
		type=float, default=600, metavar='seconds',
		help='Number of seconds the MTA should wait'
			' for a response before considering this milter dead (default: %(default)s).')
	parser.add_argument('--dspam-fail-pass', action='store_true',
		help='Accept mails instead of returning TEMPFAIL'
			' if dspamc returns any kind of errors instead of filtering results.')
	parser.add_argument('--dspam-opts', action='append', metavar='options',
		help='Extra options to pass to dspamc command.'
			' Will be split on spaces, unless option is used multiple times.')
	parser.add_argument('--debug', action='store_true', help='Verbose operation mode.')
	opts = parser.parse_args(sys.argv[1:] if args is None else args)

	logging.basicConfig(
		level=logging.DEBUG if opts.debug else logging.WARNING,
		format='%(levelname)s :: %(message)s')
	log = logging.getLogger('dspam_milter.main')

	# pymilter uses stdout for spam, no logging should go there anyway
	sys.stdout = open(os.devnull, 'w')

	dspamc_opts = opts.dspam_opts or list()
	if len(dspamc_opts) == 1: dspamc_opts = dspamc_opts[0].strip().split()

	Milter.factory = ft.partial( MilterDspam, opts.user,
		fail_pass=opts.dspam_fail_pass, dspamc_opts=dspamc_opts )
	log.debug('Starting libmilter loop...')
	Milter.runmilter('DspamMilter', opts.socket, opts.timeout)
	log.debug('libmilter loop stopped')
开发者ID:mk-fg,项目名称:dspam-milter,代码行数:45,代码来源:dspam-milter.py

示例15: main

# 需要导入模块: import Milter [as 别名]
# 或者: from Milter import runmilter [as 别名]
def main():

    #TODO parse command line

    # read configuration
    cfgfile = "/etc/gnupg-milter.conf"
    conf = gpgmilter.config.Config(cfgfile)
    conf.init_config(cfgfile)

    # Register to have the Milter factory create instances of your class:
    Milter.factory = gpgmilter.GnupgMilter.gpgm_get_factory(conf=conf)
    flags = Milter.CHGBODY + Milter.CHGHDRS + Milter.ADDHDRS
    flags += Milter.ADDRCPT
    flags += Milter.DELRCPT
    Milter.set_flags(flags)
    print("%s gnupg-milter startup" % time.strftime('%Y-%m-%d %H:%M:%S'))
    sys.stdout.flush()
    Milter.runmilter("gnupg-milter", config.socket, config.timeout)
    print("%s gnupg-milter shutdown" % time.strftime('%Y-%m-%d %H:%M:%S'))
开发者ID:burgerdev,项目名称:gnupg-milter,代码行数:21,代码来源:run.py


注:本文中的Milter.runmilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。