示例#1
0
def get_tyrant_or_None():
    try:
        tb = TyrantBackend()
        try:
            tb.open()
        except socket.error, exc:
            if exc.errno == errno.ECONNREFUSED:
                if not _no_tyrant_msg_emitted:
                    sys.stderr.write("\n" + _no_tyrant_msg + "\n")
                return None
            else:
                raise
        return tb
示例#2
0
def get_tyrant_or_None():
    def emit_no_tyrant_msg():
        global _no_tyrant_msg_emitted
        if not _no_tyrant_msg_emitted:
            sys.stderr.write("\n" + _no_tyrant_msg + "\n")
            _no_tyrant_msg_emitted = True

    if tyrant.pytyrant is None:
        emit_no_tyrant_msg()
        return None
    try:
        tb = TyrantBackend()
        try:
            tb.open()
        except socket.error, exc:
            if exc.errno == errno.ECONNREFUSED:
                emit_no_tyrant_msg()
                return None
            else:
                raise
        return tb