changeset 2669:7179217f745e

s/main.py/bot.py/
author Karol Nowak <grzywacz@sul.uni.lodz.pl>
date Mon, 13 Aug 2007 13:47:26 +0200
parents 165c3f2950dc
children 8afeb0c659b1
files jabberbot/bot.py jabberbot/main.py
diffstat 2 files changed, 78 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jabberbot/bot.py	Mon Aug 13 13:47:26 2007 +0200
@@ -0,0 +1,78 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - jabber bot main file
+
+    @copyright: 2007 by Karol Nowak <grywacz@gmail.com>
+    @license: GNU GPL, see COPYING for details.
+"""
+
+import logging, os, sys, time
+from Queue import Queue
+
+from jabberbot.config import BotConfig
+from jabberbot.i18n import init_i18n
+from jabberbot.xmppbot import XMPPBot
+from jabberbot.xmlrpcbot import XMLRPCServer, XMLRPCClient
+
+
+def main():
+    args = sys.argv
+
+    if "--help" in args:
+        print """MoinMoin notification bot
+
+        Usage: %(myname)s [--server server] [--xmpp_port port] [--user user] [--resource resource] [--password pass] [--xmlrpc_host host] [--xmlrpc_port port]
+        """ % {"myname": os.path.basename(args[0])}
+
+        raise SystemExit
+
+    log = logging.getLogger("log")
+    log.setLevel(logging.DEBUG)
+    log.addHandler(logging.StreamHandler())
+
+    init_i18n(BotConfig)
+
+    # TODO: actually accept options from the help string
+    commands_from_xmpp = Queue()
+    commands_to_xmpp = Queue()
+
+    xmpp_bot = None
+    xmlrpc_client = None
+    xmlrpc_server = None
+
+    while True:
+        try:
+            if not xmpp_bot or not xmpp_bot.isAlive():
+                log.info("(Re)starting XMPP thread...")
+                xmpp_bot = XMPPBot(BotConfig, commands_from_xmpp, commands_to_xmpp)
+                xmpp_bot.setDaemon(True)
+                xmpp_bot.start()
+
+            if not xmlrpc_client or not xmlrpc_client.isAlive():
+                log.info("(Re)starting XMLRPC client thread...")
+                xmlrpc_client = XMLRPCClient(BotConfig, commands_from_xmpp, commands_to_xmpp)
+                xmlrpc_client.setDaemon(True)
+                xmlrpc_client.start()
+
+            if not xmlrpc_server or not xmlrpc_server.isAlive():
+                log.info("(Re)starting XMLRPC server thread...")
+                xmlrpc_server = XMLRPCServer(BotConfig, commands_to_xmpp)
+                xmlrpc_server.setDaemon(True)
+                xmlrpc_server.start()
+
+            time.sleep(5)
+
+        except KeyboardInterrupt, i:
+            xmpp_bot.stop()
+            xmlrpc_client.stop()
+
+            log.info("Stopping XMPP bot thread, please wait...")
+            xmpp_bot.join(5)
+            log.info("Stopping XMLRPC client thread, please wait...")
+            xmlrpc_client.join(5)
+
+            sys.exit(0)
+
+
+if __name__ == "__main__":
+    main()
--- a/jabberbot/main.py	Mon Aug 13 13:14:50 2007 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - jabber bot main file
-
-    @copyright: 2007 by Karol Nowak <grywacz@gmail.com>
-    @license: GNU GPL, see COPYING for details.
-"""
-
-import logging, os, sys, time
-from Queue import Queue
-
-from jabberbot.config import BotConfig
-from jabberbot.i18n import init_i18n
-from jabberbot.xmppbot import XMPPBot
-from jabberbot.xmlrpcbot import XMLRPCServer, XMLRPCClient
-
-
-def main():
-    args = sys.argv
-
-    if "--help" in args:
-        print """MoinMoin notification bot
-
-        Usage: %(myname)s [--server server] [--xmpp_port port] [--user user] [--resource resource] [--password pass] [--xmlrpc_host host] [--xmlrpc_port port]
-        """ % {"myname": os.path.basename(args[0])}
-
-        raise SystemExit
-
-    log = logging.getLogger("log")
-    log.setLevel(logging.DEBUG)
-    log.addHandler(logging.StreamHandler())
-
-    init_i18n(BotConfig)
-
-    # TODO: actually accept options from the help string
-    commands_from_xmpp = Queue()
-    commands_to_xmpp = Queue()
-
-    xmpp_bot = None
-    xmlrpc_client = None
-    xmlrpc_server = None
-
-    while True:
-        try:
-            if not xmpp_bot or not xmpp_bot.isAlive():
-                log.info("(Re)starting XMPP thread...")
-                xmpp_bot = XMPPBot(BotConfig, commands_from_xmpp, commands_to_xmpp)
-                xmpp_bot.setDaemon(True)
-                xmpp_bot.start()
-
-            if not xmlrpc_client or not xmlrpc_client.isAlive():
-                log.info("(Re)starting XMLRPC client thread...")
-                xmlrpc_client = XMLRPCClient(BotConfig, commands_from_xmpp, commands_to_xmpp)
-                xmlrpc_client.setDaemon(True)
-                xmlrpc_client.start()
-
-            if not xmlrpc_server or not xmlrpc_server.isAlive():
-                log.info("(Re)starting XMLRPC server thread...")
-                xmlrpc_server = XMLRPCServer(BotConfig, commands_to_xmpp)
-                xmlrpc_server.setDaemon(True)
-                xmlrpc_server.start()
-
-            time.sleep(5)
-
-        except KeyboardInterrupt, i:
-            xmpp_bot.stop()
-            xmlrpc_client.stop()
-
-            log.info("Stopping XMPP bot thread, please wait...")
-            xmpp_bot.join(5)
-            log.info("Stopping XMLRPC client thread, please wait...")
-            xmlrpc_client.join(5)
-
-            sys.exit(0)
-
-
-if __name__ == "__main__":
-    main()