X-Git-Url: https://code.delx.au/pymsnt/blobdiff_plain/1f844844773f69597293040f8ad95b9521a21293..4613e8e993d2731781072c371c3c59078f507d7f:/src/main.py diff --git a/src/main.py b/src/main.py index e34f95a..a85a4ee 100644 --- a/src/main.py +++ b/src/main.py @@ -9,26 +9,19 @@ sys.stdout = codecs.lookup('utf-8')[-1](sys.stdout) # Find the best reactor selectWarning = "Unable to install any good reactors (kqueue, epoll, poll).\nWe fell back to using select. You may have scalability problems.\nThis reactor will not support more than 1024 connections at a time." -try: - from twisted.internet import epollreactor as bestreactor -except: - #try: - #from twisted.internet import kqreactor as bestreactor - #except: +reactors = [("epollreactor", True), ("pollreactor", True), ("selectreactor", False), ("default", False)] +for tryReactor, good in reactors: try: - from twisted.internet import pollreactor as bestreactor - except: - try: - from twisted.internet import selectreactor as bestreactor - print selectWarning - except: - try: - from twisted.internet import default as bestreactor - print selectWarning - except: - print "Unable to find a reactor. Please make sure you have Twisted properly installed.\nExiting..." - sys.exit(1) -bestreactor.install() + bestReactor = __import__("twisted.internet." + tryReactor) + if not good: + print >> sys.stderr, selectWarning + break + except ImportError: + pass +else: + print >> sys.stderr, "Unable to find a reactor. Please make sure you have Twisted properly installed.\nExiting..." + sys.exit(1) + import twistfix twistfix.main() @@ -90,7 +83,7 @@ if config.reactor: from twisted.internet import kqreactor kqreactor.install() elif len(config.reactor) > 0: - print "Unknown reactor: ", config.reactor, ". Using select(), reactor." + print >> sys.stderr, "Unknown reactor: ", config.reactor, ". Using best available reactor." from twisted.internet import reactor, task @@ -134,6 +127,7 @@ class PyTransport(component.Service): self.discovery.addFeature(disco.XCONFERENCE, None, config.jid) # So that clients know you can create groupchat rooms on the server self.discovery.addFeature("jabber:iq:conference", None, config.jid) # We don't actually support this, but Psi has a bug where it looks for this instead of the above self.discovery.addIdentity("client", "pc", "MSN Messenger", "USER") + self.discovery.addIdentity("conference", "text", "MSN Groupchat", "ROOM") self.xdb = xdb.XDB(config.jid, legacy.mangle) self.avatarCache = avatar.AvatarCache() @@ -390,7 +384,7 @@ if os.name == "posix": # Set SIGHUP to reload the config file & close & open debug file signal.signal(signal.SIGHUP, SIGHUPstuff) # Load some scripts for PID and daemonising - from twisted.scripts import twistd + from twisted.scripts import _twistd_unix as twistd def main():