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


Python couchdb.Server方法代码示例

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


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

示例1: db

# 需要导入模块: import couchdb [as 别名]
# 或者: from couchdb import Server [as 别名]
def db(request):
    server = couchdb.Server("http://" + worker_defaults['COUCH_DATABASE'].split('/')[2])
    name = worker_defaults['COUCH_DATABASE'].split('/')[3]

    documents = getattr(request, 'param', None)

    def delete():
        del server[name]

    if name in server:
        delete()

    data_base = server.create(name)

    if documents:
        for doc in documents:
            data_base.save(doc)
            
    request.addfinalizer(delete)

    return data_base 
开发者ID:openprocurement,项目名称:openprocurement.auction,代码行数:23,代码来源:conftest.py

示例2: auctions_server

# 需要导入模块: import couchdb [as 别名]
# 或者: from couchdb import Server [as 别名]
def auctions_server(request):
    params = getattr(request, 'param', {})
    server_config = params.get('server_config', {})

    logger = MagicMock(spec_set=frontend.logger)
    logger.name = server_config.get('logger_name', 'some-logger')
    frontend.logger_name = logger.name
    frontend._logger = logger

    for key in ('limit_replications_func', 'limit_replications_progress'):
        frontend.config.pop(key, None)

    for key in ('limit_replications_func', 'limit_replications_progress'):
        if key in server_config:
            frontend.config[key] = server_config[key]

    frontend.couch_server = MagicMock(spec_set=Server)
    frontend.config['TIMEZONE'] = 'some_time_zone'

    if 'couch_tasks' in params:
        frontend.couch_server.tasks.return_value = params['couch_tasks']

    test_app = TestApp(frontend)
    return {'app': frontend, 'test_app': test_app} 
开发者ID:openprocurement,项目名称:openprocurement.auction,代码行数:26,代码来源:conftest.py

示例3: database_caller_creator

# 需要导入模块: import couchdb [as 别名]
# 或者: from couchdb import Server [as 别名]
def database_caller_creator(self, name=None):
        '''creates a couchdb database
        returns the related connection object
        which will be later used to spawn the cursor
        '''

        couch = couchdb.Server()

        if name:
            db = couch.create(name)
        else:
            n = 'couchdb_' + lower_str_generator(self)
            db = couch.create(n)
            logger.warning('couchdb database created with the name: %s', n,
                           extra=d)

        return db 
开发者ID:emirozer,项目名称:fake2db,代码行数:19,代码来源:couchdb_handler.py

示例4: __call__

# 需要导入模块: import couchdb [as 别名]
# 或者: from couchdb import Server [as 别名]
def __call__(self, doc):
        if self.couch is None:
            self.couch = couchdb.Server("http://%s:5984" % SERVER)

        docid = doc['_id']
        db = (self.couch['words'], self.couch['words_slave'])
        doc1 = db[0][docid]
        doc2 = db[1][docid]
        if doc['t'] != doc1['t'] or doc1['t'] != doc2['t']:
            #print >>sys.stderr, "{0}\n{1}\n{2}".format(doc, doc1, doc2)
            return (FAIL, "Err with doc: {0}".format(docid), (doc, doc1, doc2))

        if doc['word'] != doc1['word'] or doc1['word'] != doc2['word']:
            #print >>sys.stderr, "{0}\n{1}\n{2}".format(doc, doc1, doc2)
            return (FAIL, "Err with doc: {0}".format(docid), (doc, doc1, doc2))

        return (OK, OK, OK) 
开发者ID:yandex,项目名称:root-2015-tasks,代码行数:19,代码来源:checker.py

示例5: check_database

# 需要导入模块: import couchdb [as 别名]
# 或者: from couchdb import Server [as 别名]
def check_database(server):
    try:
        etalon_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "etalon.json")
        etalon = json.load(open(etalon_path, "r"))
        couch = couchdb.Server("http://%s:5984" % server)
        db = (couch['words'], couch['words_slave'])

        p = Pool(30)
        result = p.map(CheckDoc(), etalon)
        for r in result:
            if r[0] != OK:
                print r[1]
                print >>sys.stderr, r[2]
                return FAIL

        return OK

    except Exception as e:
        print "Exception: {0}".format(e)
        return FAIL 
开发者ID:yandex,项目名称:root-2015-tasks,代码行数:22,代码来源:checker.py

示例6: __init__

# 需要导入模块: import couchdb [as 别名]
# 或者: from couchdb import Server [as 别名]
def __init__(self):
        self.couch = couchdb.Server(settings.COUCHDB_URL) 
开发者ID:archesproject,项目名称:arches,代码行数:4,代码来源:couch.py

示例7: couchdb_dns_query_settings

# 需要导入模块: import couchdb [as 别名]
# 或者: from couchdb import Server [as 别名]
def couchdb_dns_query_settings(server_url, database_name):
    parsed_url = urlparse(server_url)
    all_ips = set([str(i[4][0]) for i in socket.getaddrinfo(urlparse(server_url).hostname, 80)])

    while all_ips:
        selected_ip = set(sample(all_ips, 1))
        all_ips -= selected_ip
        couch_url = server_url.replace(parsed_url.hostname, selected_ip.pop())
        try:
            server = Server(couch_url, session=Session(retry_delays=range(10)))
            return server[database_name]
        except socket.error:
            continue
    raise Exception("No route to any couchdb server") 
开发者ID:openprocurement,项目名称:openprocurement.auction,代码行数:16,代码来源:couch.py

示例8: __init__

# 需要导入模块: import couchdb [as 别名]
# 或者: from couchdb import Server [as 别名]
def __init__(self, parent):
        print('Performing check: ' + self.TITLE)
        import couchdb
        from urlparse import urlparse

        # parent connection is authenticated so create a new unauthenticated connection
        url     = urlparse(parent.dbhost)
        self.db = couchdb.Server(url.scheme + '://' + url.hostname + ':' + parent.dbport) 
开发者ID:foospidy,项目名称:DbDat,代码行数:10,代码来源:check_configuration_verify_auth.py

示例9: setUp

# 需要导入模块: import couchdb [as 别名]
# 或者: from couchdb import Server [as 别名]
def setUp(self):
        self.db_name += uuid4().hex
        # self.couchdb_server.create(self.db_name)
        couchdb_server = Mock(spec=CouchdbServer)
        couchdb_server.tasks = MagicMock(return_value=self.return_value)
        self.app.app.registry.couchdb_server = couchdb_server
        self.db_name = self.db.name
        self.app.authorization = ('Basic', ('token', '')) 
开发者ID:openprocurement,项目名称:openprocurement.api,代码行数:10,代码来源:health.py

示例10: __init__

# 需要导入模块: import couchdb [as 别名]
# 或者: from couchdb import Server [as 别名]
def __init__(self, dbName, config='http://localhost:5984'):
        self.server = couchdb.Server(config)
        try:
            self.db = self.server[dbName]
        except Exception:
            self.db = self.server.create(dbName) 
开发者ID:hyperledger,项目名称:fabric-sdk-py,代码行数:8,代码来源:couchdbwalletstore.py

示例11: getResults

# 需要导入模块: import couchdb [as 别名]
# 或者: from couchdb import Server [as 别名]
def getResults(test=False):
    '''Run a Mango query to get the data'''
    ts = datetime.utcnow().isoformat()[:19]
    payload={"selector":{"start_date.timestamp":{"$lt":ts}, "status.status_qualifier":"Success", "activity_type":"Environment_Observation", "subject.name":"Air","subject.attribute.name": "Temperature"}, "fields":["start_date.timestamp", "subject.attribute.value"], "sort":[{"start_date.timestamp":"desc"}], "limit":250}    
    db_name = 'mvp_data'
    if test:
        print payload
    server = Server()
    db = server[db_name]
    return db.find(payload) 
开发者ID:futureag,项目名称:mvp,代码行数:12,代码来源:TempChart.py

示例12: getResults

# 需要导入模块: import couchdb [as 别名]
# 或者: from couchdb import Server [as 别名]
def getResults():
#    header={"Content-Type":"application/json"}
    ts = datetime.utcnow().isoformat()[:19]
    payload={"selector":{"start_date.timestamp":{"$lt":ts},"status.status_qualifier":{"$eq": "Success"}, "activity_type":{"$eq":"Environment_Observation"}, "subject.name":{"$eq": "Air"}, "$or":[{"subject.attribute.name":"Humidity"}, {"subject.attribute.name":"Temperature"}]}, "fields":["start_date.timestamp", "subject.attribute.name", "subject.attribute.value"], "sort":[{"start_date.timestamp":"desc"}], "limit":250}        
    server = Server()
    db_name = 'mvp_data'
    db = server[db_name]
    return db.find(payload) 
开发者ID:futureag,项目名称:mvp,代码行数:10,代码来源:DewpointChart.py

示例13: getResults

# 需要导入模块: import couchdb [as 别名]
# 或者: from couchdb import Server [as 别名]
def getResults(test=False):
    '''Run a Mango query to get the data'''
    ts = datetime.utcnow().isoformat()[:19]
    payload={"selector":{"start_date.timestamp":{"$lt":ts}, "status.status_qualifier":"Success", "activity_type":"Environment_Observation", "subject.name":"Air","subject.attribute.name": "Humidity"}, "fields":["start_date.timestamp", "subject.attribute.value"], "sort":[{"start_date.timestamp":"desc"}], "limit":250}        
    db_name = 'mvp_data'
    if test:
        print payload
    server = Server()
    db = server[db_name]
    return db.find(payload) 
开发者ID:futureag,项目名称:mvp,代码行数:12,代码来源:HumidityChart.py


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