當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。