#!/usr/bin/env python import sblog from optparse import OptionParser import signal import sys, os from tfplib import osutils as _osutils osutils = _osutils.impl # TODO: Support Multiple Blogs # Define the signal handler def termhandler(signum, frame): sys.exit() version = "%prog $Revision$" BlogFile = "data/entries.xml" SocketFile = "xmlrpcServer" def buildOptParser(): usage = "usage: %prog [options]" parser = OptionParser(usage=usage, version=version) parser.add_option("-f", "--file", help="Blog File to Use", dest="filename", default=BlogFile) parser.add_option("-s", "--socket", help="Unix Socket File to use", dest="socket", default=SocketFile) return parser def main(): if osutils.supported: osutils.process_name = "BlogServer" parser = buildOptParser() (options, args) = parser.parse_args() BServer = sblog.BlogServer(address=options.socket) BServer.AddBlog(options.filename) signal.signal(signal.SIGTERM, termhandler) BServer.Mainloop() # Cleanup when done (TODO: Make this stuff run at exit and when we get various signals) # Done in GetBlogXMLRPCServer with atexit if __name__ == "__main__": main() # vim: set noexpandtab: