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


Python Connection.server_info方法代码示例

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


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

示例1: _open

# 需要导入模块: from pymongo.connection import Connection [as 别名]
# 或者: from pymongo.connection.Connection import server_info [as 别名]
    def _open(self):
        conninfo = self.connection.client
        mongoconn = Connection(host=conninfo.hostname, port=conninfo.port)
        dbname = conninfo.virtual_host
        version = mongoconn.server_info()["version"]
        if tuple(map(int, version.split(".")[:2])) < (1, 3):
            raise NotImplementedError(
                "Kombu requires MongoDB version 1.3+, but connected to %s" % (
                    version, ))
        if not dbname or dbname == "/":
            dbname = "kombu_default"
        database = getattr(mongoconn, dbname)
        if conninfo.userid:
            database.authenticate(conninfo.userid, conninfo.password)

        self.db = database
        col = database.messages
        col.ensure_index([("queue", 1)])

        if "messages.broadcast" not in database.collection_names():
            capsize = conninfo.transport_options.get(
                            "capped_queue_size") or 100000
            database.create_collection("messages.broadcast", size=capsize,
                                                             capped=True)

        self.bcast = getattr(database, "messages.broadcast")
        self.bcast.ensure_index([("queue", 1)])

        self.routing = getattr(database, "messages.routing")
        self.routing.ensure_index([("queue", 1), ("exchange", 1)])
        return database
开发者ID:Kronuz,项目名称:kombu,代码行数:33,代码来源:mongodb.py

示例2: _open

# 需要导入模块: from pymongo.connection import Connection [as 别名]
# 或者: from pymongo.connection.Connection import server_info [as 别名]
    def _open(self):
        """
        See mongodb uri documentation:
        http://www.mongodb.org/display/DOCS/Connections
        """
        client = self.connection.client
        hostname = client.hostname or DEFAULT_HOST
        authdb = dbname = client.virtual_host

        if dbname in ["/", None]:
            dbname = "kombu_default"
            authdb = "admin"

        if not client.userid:
            hostname = hostname.replace('/' + client.virtual_host, '/')
        else:
            hostname = hostname.replace('/' + client.virtual_host,
                                        '/' + authdb)

        mongo_uri = 'mongodb://' + hostname
        # At this point we expect the hostname to be something like
        # (considering replica set form too):
        #
        #   mongodb://[username:[email protected]]host1[:port1][,host2[:port2],
        #   ...[,hostN[:portN]]][/[?options]]
        mongoconn = Connection(host=mongo_uri, ssl=client.ssl)
        database = getattr(mongoconn, dbname)

        version = mongoconn.server_info()['version']
        if tuple(map(int, version.split('.')[:2])) < (1, 3):
            raise NotImplementedError(
                'Kombu requires MongoDB version 1.3+ (server is {0})'.format(
                    version))

        self.db = database
        col = database.messages
        col.ensure_index([('queue', 1), ('_id', 1)], background=True)

        if 'messages.broadcast' not in database.collection_names():
            capsize = (client.transport_options.get('capped_queue_size')
                       or 100000)
            database.create_collection('messages.broadcast',
                                       size=capsize, capped=True)

        self.bcast = getattr(database, 'messages.broadcast')
        self.bcast.ensure_index([('queue', 1)])

        self.routing = getattr(database, 'messages.routing')
        self.routing.ensure_index([('queue', 1), ('exchange', 1)])
        return database
开发者ID:FluidInc,项目名称:8b-kombu,代码行数:52,代码来源:mongodb.py

示例3: main

# 需要导入模块: from pymongo.connection import Connection [as 别名]
# 或者: from pymongo.connection.Connection import server_info [as 别名]
def main():
    connection = Connection()
    runner = BenchmarkRunner(10000, connection.server_info()["gitVersion"])

    runner.run_benchmark(Encode(small, "small"))
    runner.run_benchmark(Encode(medium, "medium"))
    runner.run_benchmark(Encode(large, "large"))

    runner.run_benchmark(Decode(BSON.from_dict(small), "small"))
    runner.run_benchmark(Decode(BSON.from_dict(medium), "medium"))
    runner.run_benchmark(Decode(BSON.from_dict(large), "large"))

    runner.run_benchmark(Insert(connection.benchmark, medium, "medium"))

    runner.run_benchmark(FindOne(connection.benchmark.medium_no_index, {"x": 5000}, "medium"))
开发者ID:drg,项目名称:mongo-python-driver,代码行数:17,代码来源:benchmark.py

示例4: _open

# 需要导入模块: from pymongo.connection import Connection [as 别名]
# 或者: from pymongo.connection.Connection import server_info [as 别名]
 def _open(self):
     conninfo = self.connection.client
     mongoconn = Connection(host=conninfo.hostname, port=conninfo.port)
     dbname = conninfo.virtual_host
     version = mongoconn.server_info()["version"]
     if tuple(map(int, version.split("."))) < (1, 3):
         raise NotImplementedError(
             "Kombu requires MongoDB version 1.3+, but connected to %s" % (
                 version, ))
     if not dbname or dbname == "/":
         dbname = "kombu_default"
     database = getattr(mongoconn, dbname)
     col = database.messages
     col.ensure_index([("queue", 1)])
     return col
开发者ID:danostrowski,项目名称:kombu,代码行数:17,代码来源:mongodb.py

示例5: _open

# 需要导入模块: from pymongo.connection import Connection [as 别名]
# 或者: from pymongo.connection.Connection import server_info [as 别名]
    def _open(self):
        conninfo = self.connection.client
        mongoconn = Connection(host=conninfo.hostname, port=conninfo.port)
        dbname = conninfo.virtual_host
        version = mongoconn.server_info()["version"]
        if tuple(map(int, version.split(".")[:2])) < (1, 3):
            raise NotImplementedError(
                "Kombu requires MongoDB version 1.3+, but connected to %s" % (
                    version, ))
        if not dbname or dbname == "/":
            dbname = "kombu_default"
        database = getattr(mongoconn, dbname)
        if conninfo.userid:
            database.authenticate(conninfo.userid, conninfo.password)
        col = database.messages
        #note, for existing installation one should drop the index on only queue
        col.ensure_index([("queue", pymongo.ASCENDING), ("priority", pymongo.ASCENDING), ("_id", pymongo.ASCENDING)])

        return col
开发者ID:peterlundberg,项目名称:kombu,代码行数:21,代码来源:mongodb.py

示例6: _open

# 需要导入模块: from pymongo.connection import Connection [as 别名]
# 或者: from pymongo.connection.Connection import server_info [as 别名]
    def _open(self):
        """
        See mongodb uri documentation:
        http://www.mongodb.org/display/DOCS/Connections
        """
        conninfo = self.connection.client

        dbname = None
        hostname = None

        if not conninfo.hostname:
            conninfo.hostname = DEFAULT_HOST

        for part in conninfo.hostname.split('/'):
            if not hostname:
                hostname = 'mongodb://' + part
                continue

            dbname = part
            if '?' in part:
                # In case someone is passing options
                # to the mongodb connection. Right now
                # it is not permitted by kombu
                dbname, options = part.split('?')
                hostname += '/?' + options

        hostname = "%s/%s" % (
            hostname, dbname in [None, "/"] and "admin" or dbname,
        )
        if not dbname or dbname == "/":
            dbname = "kombu_default"

        # At this point we expect the hostname to be something like
        # (considering replica set form too):
        #
        #   mongodb://[username:[email protected]]host1[:port1][,host2[:port2],
        #   ...[,hostN[:portN]]][/[?options]]
        mongoconn = Connection(host=hostname, ssl=conninfo.ssl)
        version = mongoconn.server_info()['version']
        if tuple(map(int, version.split('.')[:2])) < (1, 3):
            raise NotImplementedError(
                'Kombu requires MongoDB version 1.3+, but connected to %s' % (
                    version, ))

        database = getattr(mongoconn, dbname)

        # This is done by the connection uri
        # if conninfo.userid:
        #     database.authenticate(conninfo.userid, conninfo.password)
        self.db = database
        col = database.messages
        col.ensure_index([('queue', 1), ('_id', 1)], background=True)

        if 'messages.broadcast' not in database.collection_names():
            capsize = conninfo.transport_options.get(
                'capped_queue_size') or 100000
            database.create_collection('messages.broadcast',
                                       size=capsize, capped=True)

        self.bcast = getattr(database, 'messages.broadcast')
        self.bcast.ensure_index([('queue', 1)])

        self.routing = getattr(database, 'messages.routing')
        self.routing.ensure_index([('queue', 1), ('exchange', 1)])
        return database
开发者ID:OpenPOWER-BigData,项目名称:HDP-hue,代码行数:67,代码来源:mongodb.py

示例7: _open

# 需要导入模块: from pymongo.connection import Connection [as 别名]
# 或者: from pymongo.connection.Connection import server_info [as 别名]
    def _open(self):
        """
        See mongodb uri documentation:
        http://www.mongodb.org/display/DOCS/Connections
        """
        conninfo = self.connection.client

        dbname = None
        hostname = None

        if not conninfo.hostname:
            conninfo.hostname = DEFAULT_HOST

        for part in conninfo.hostname.split("/"):
            if not hostname:
                hostname = "mongodb://" + part
                continue

            dbname = part
            if "?" in part:
                # In case someone is passing options
                # to the mongodb connection. Right now
                # it is not permitted by kombu
                dbname, options = part.split("?")
                hostname += "/?" + options

        # At this point we expect the hostname to be something like
        # (considering replica set form too):
        #
        #   mongodb://[username:[email protected]]host1[:port1][,host2[:port2],
        #   ...[,hostN[:portN]]][/[?options]]
        mongoconn = Connection(host=hostname)
        version = mongoconn.server_info()["version"]
        if tuple(map(int, version.split(".")[:2])) < (1, 3):
            raise NotImplementedError(
                "Kombu requires MongoDB version 1.3+, but connected to %s" % (
                    version, ))

        if not dbname or dbname == "/":
            dbname = "kombu_default"

        database = getattr(mongoconn, dbname)

        # This is done by the connection uri
        # if conninfo.userid:
        #     database.authenticate(conninfo.userid, conninfo.password)

        self.db = database
        col = database.messages
        col.ensure_index([("queue", 1)])

        if "messages.broadcast" not in database.collection_names():
            capsize = conninfo.transport_options.get(
                            "capped_queue_size") or 100000
            database.create_collection("messages.broadcast", size=capsize,
                                                             capped=True)

        self.bcast = getattr(database, "messages.broadcast")
        self.bcast.ensure_index([("queue", 1)])

        self.routing = getattr(database, "messages.routing")
        self.routing.ensure_index([("queue", 1), ("exchange", 1)])
        return database
开发者ID:AshishNamdev,项目名称:mozillians,代码行数:65,代码来源:mongodb.py


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