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


Python couchdb.Server类代码示例

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


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

示例1: __init__

 def __init__(self, url):
     print "iniciando a verificação..."
     Server.__init__(self, url)
     act = self
     test_and_create = lambda db: db in act and act[db] or act.create(db)
     for attribute in _DOCBASES:
         setattr(Activ, attribute, test_and_create(attribute))
开发者ID:labase,项目名称:activnce,代码行数:7,代码来源:createdb4benchmark.py

示例2: __init__

 def __init__(self, url):
     print "iniciando a pesquisa..."
     Server.__init__(self, url)
     act = self
     test_and_create = lambda doc: doc in act and act[doc] or act.create(doc)
     for attribute in _DOCBASES:
         setattr(Activ, attribute, test_and_create(attribute))
开发者ID:labase,项目名称:activnce,代码行数:7,代码来源:identificaemailsduplicados.py

示例3: OnAddTag

	def OnAddTag( self, event ):
		bl = Server(self.URL)[BLOG]
		p = Post.load(bl, self.blogpost)
		tags = [ str(x.key) for x in bl.view("all/tags", group = True) if str(x.key) not in map(str,p.tags) ]
		if tags:
			dialog = wx.SingleChoiceDialog(None, "Choose a Tag or press Cancel to type it", "Tags", tags)
			tag = ""
			if dialog.ShowModal() == wx.ID_OK:
				tag = dialog.GetStringSelection()
			else:
				tag = wx.GetTextFromUser( "Type a Tag ", "Tag")
				if tag:
					tag = tag.upper()

			dialog.Destroy()
			if tag:
				bl = Server(self.URL)[BLOG]
				p = Post.load(bl, self.blogpost)
				tagList = p.tags
				tagList.append(tag)
				tagList = list(set(tagList))
				tagList.sort()
				p.tags = tagList
				p.store(bl)
				#event = wx.CommandEvent( wx.wxEVT_COMMAND_LIST_ITEM_SELECTED, self.list.GetId())
				#self.GetEventHandler().ProcessEvent( event )
				self.OnLCtrl(None)
开发者ID:batok,项目名称:couchdb-wxpython,代码行数:27,代码来源:couchdbgui.py

示例4: remove_db

def remove_db(database):
    '''
    Destroy given database.
    '''
    server = Server('http://localhost:5984/')
    server.delete(database)
    logger.info('[DB] Local database %s removed' % database)
开发者ID:poupotte,项目名称:couchdb-fuse,代码行数:7,代码来源:dbutils.py

示例5: database_connection

def database_connection():
    try:
        server = Server('http://localhost:5984/')
        server.version()
        return server
    except Exception:
        print('Cannot connect to the database')
开发者ID:frankrousseau,项目名称:couchdb-fuse,代码行数:7,代码来源:cozy_fuse.py

示例6: handle

    def handle(self, *args, **options):

        verbosity = options['verbosity']
        if verbosity == '0':
            self.logger.setLevel(logging.ERROR)
        elif verbosity == '1':
            self.logger.setLevel(logging.WARNING)
        elif verbosity == '2':
            self.logger.setLevel(logging.INFO)
        elif verbosity == '3':
            self.logger.setLevel(logging.DEBUG)

        self.offset = int(options['offset'])
        self.limit = int(options['limit'])

        self.logger.info("Starting export!")
        server = Server()
        if 'maps-places' not in server:
            self.db = server.create('maps-places')
        else:
            self.db = server['maps-places']

        # places uri startup
        places_uri = "{0}/maps/places".format(settings.OP_API_URI)
        self.logger.debug("GET {0}".format(places_uri))

        # get all places, following the next link
        places_json = self.export_page(places_uri)
        while places_json and places_json['next']:
            places_json = self.export_page(places_json['next'])
开发者ID:openpolis,项目名称:op_api3,代码行数:30,代码来源:maps_export_to_couchdb.py

示例7: loadCouchDB

def loadCouchDB(db_name, view_name, excel_name):
    tweet_dict = {}
    couch_server = Server("http://115.146.94.12:5984")
    couch_server.resource.credentials = ('admin', 'admin')
    couch_server.config()
    db = couch_server[db_name]

    wb = Workbook()
    ws = wb.active

    ws.title = "range names"
    rowid = 1
    for row in db.view(view_name):
        coordinate = re.sub(r"\[|\]", "", str(row.key))

        # write coordinate
        col = get_column_letter(1)
        ws.cell('%s%s'%(col, rowid)).value = coordinate

        #write polarity
        col = get_column_letter(2)
        ws.cell('%s%s'%(col, rowid)).value = getPolarity(row.value)

        #write text
        col = get_column_letter(3)
        ws.cell('%s%s'%(col, rowid)).value = row.value

        rowid += 1

    ws = wb.create_sheet()

    ws.title = 'coordinate'
    wb.save(filename = excel_name)

    return tweet_dict
开发者ID:COMP90024-cloud-computing,项目名称:sentiment,代码行数:35,代码来源:writeExcel.py

示例8: main

def main(global_config, **settings):
    config = Configurator(settings=settings)
    config.set_authentication_policy(AuthenticationPolicy(None))
    config.set_authorization_policy(AuthorizationPolicy())
    config.add_renderer('prettyjson', JSON(indent=4))
    config.add_renderer('jsonp', JSONP(param_name='opt_jsonp'))
    config.add_renderer('prettyjsonp', JSONP(indent=4, param_name='opt_jsonp'))
    config.add_subscriber(set_renderer, NewRequest)
    config.include("cornice")
    config.route_prefix = '/api/{}'.format(VERSION)
    config.scan("openprocurement.api.views")

    # CouchDB connection
    server = Server(settings.get('couchdb.url'))
    config.registry.couchdb_server = server
    db_name = os.environ.get('DB_NAME', settings['couchdb.db_name'])
    if db_name not in server:
        server.create(db_name)
    config.registry.db = server[db_name]

    # sync couchdb views
    sync_design(config.registry.db)

    # migrate data
    migrate_data(config.registry.db)

    # S3 connection
    if 'aws.access_key' in settings and 'aws.secret_key' in settings and 'aws.bucket' in settings:
        connection = S3Connection(settings['aws.access_key'], settings['aws.secret_key'])
        config.registry.s3_connection = connection
        bucket_name = settings['aws.bucket']
        if bucket_name not in [b.name for b in connection.get_all_buckets()]:
            connection.create_bucket(bucket_name, location=Location.EU)
        config.registry.bucket_name = bucket_name
    return config.make_wsgi_app()
开发者ID:gitter-badger,项目名称:openprocurement.api,代码行数:35,代码来源:__init__.py

示例9: init_db

def init_db():
    server = CouchDBServer(db_addr)
    try:
        server.create(db_name)
    except PreconditionFailed:
        del server[db_name]
        server.create(db_name)
开发者ID:Tefx,项目名称:MoWSC,代码行数:7,代码来源:exp.py

示例10: create_test_users_db

def create_test_users_db(name=TEST_USERS_DB, server=TEST_SERVER):
    try:
        couchdb = Server(server)
        return couchdb.create(name)
    except PreconditionFailed:        
        del couchdb[name]
        return couchdb.create(name)
开发者ID:jab,项目名称:radarpost,代码行数:7,代码来源:helpers.py

示例11: initialize

 def initialize(self):
     couch = Server()
     if "stories" not in couch:
         couch.create("stories")
     self.db_stories = couch['stories']
     if "posts" not in couch:
         couch.create("posts")
     self.db_posts = couch['posts']
开发者ID:OpenFilter,项目名称:MediaManagerService,代码行数:8,代码来源:StoryFeedHandler.py

示例12: __init__

 def __init__(self):
     couchdb_host = getattr(settings, 'COUCHDB_HOST')
     server       = Server(couchdb_host)
     try:
         self.db  = server['wiki']
     except ResourceNotFound:
         self.db  = server.create('wiki')
         Page.get_pages.sync(self.db)
     self.wiki_form = curry(PageForm, db = self.db)
开发者ID:theju,项目名称:django-couch-wiki,代码行数:9,代码来源:views.py

示例13: main

def main(bulk_size, up_to, num_threads):
    global timer
    s = Server('http://localhost:5984')
    if 'test' in s:
        del s['test']
    db = s.create('test')

    stats_file = 'bulk-perf-%s-%s-%s.dat' % (bulk_size, up_to, num_threads)
    title_file = stats_file + '.meta'
    f = open(title_file, 'w')
    f.write('Bulk size: %s, num threads: %s' % (bulk_size, num_threads))
    f.close()

    stats_file = open(stats_file, 'w')

    stats_lock = Lock()
    exit_event = Event()

    chunks = Queue.Queue()

    def process_chunks():
        global count, timer, internal_counter

        s = Server('http://localhost:5984')
        db = s['test']

        while not exit_event.isSet():
            try:
                chunk = list(chunks.get(timeout=5))
                chunks.task_done()

                db.update(chunk)

                stats_lock.acquire()
                try:
                    count += bulk_size
                    internal_counter += bulk_size

                    if internal_counter >= max(num_threads*bulk_size, up_to/1000):
                        end = time()

                        stats_file.write('%s %s\n' % (count, internal_counter/float(end-timer)))
                        stats_file.flush()

                        timer = end
                        internal_counter = 0
                        print '%.1f%%' % (float(count) / up_to * 100)
                finally:
                    stats_lock.release()

            except Queue.Empty:
                pass

            except Exception, e:
                print 'Exception: %r' % (e,)
                chunks.put(chunk)
                sleep(1)
开发者ID:svetlyak40wt,项目名称:couchdb-performance-tests,代码行数:57,代码来源:couchdb_bulk_perf.py

示例14: couchdb_connection

def couchdb_connection(config):

    LOGGER = getLogger("BILLING")
    LOGGER.info("Start database initialization")

    # CouchDB connection
    db_name = config.get('db').get('name')
    db_host = config.get('db').get('host')
    db_port = config.get('db').get('port')
    admin_name = config.get('admin').get('username')
    admin_pass = config.get('admin').get('password')
    aserver = Server(
        create_db_url(db_host, db_port, admin_name, admin_pass),
        session=Session(retry_delays=range(10)))
    users_db = aserver['_users']

    username = config.get('user').get('username')
    password = config.get('user').get('password')

    user_doc = users_db.get(
        'org.couchdb.user:{}'.format(username),
        {'_id': 'org.couchdb.user:{}'.format(username)}
    )

    if not user_doc.get('derived_key', '') or PBKDF2(password, user_doc.get('salt', ''), user_doc.get('iterations', 10)).hexread(int(len(user_doc.get('derived_key', '')) / 2)) != user_doc.get('derived_key', ''):
        user_doc.update({
            "name": username,
            "roles": [],
            "type": "user",
            "password": password
        })
        LOGGER.info(
            "Updating api db main user",
            extra={'MESSAGE_ID': 'update_api_main_user'}
        )
        users_db.save(user_doc)
    if db_name not in aserver:
        aserver.create(db_name)
    db = aserver[db_name]

    SECURITY[u'members'][u'names'] = [username, ]
    if SECURITY != db.security:
        LOGGER.info(
            "Updating api db security",
            extra={'MESSAGE_ID': 'update_api_security'}
        )
        db.security = SECURITY

    auth_doc = db.get(VALIDATE_DOC_ID, {'_id': VALIDATE_DOC_ID})
    if auth_doc.get('validate_doc_update') != VALIDATE_DOC_UPDATE % username:
        auth_doc['validate_doc_update'] = VALIDATE_DOC_UPDATE % username
        LOGGER.info(
            "Updating api db validate doc",
            extra={'MESSAGE_ID': 'update_api_validate_doc'}
        )
        db.save(auth_doc)
开发者ID:openprocurement,项目名称:reports,代码行数:56,代码来源:init.py

示例15: __init__

 def __init__(self, url):
     print "conectando com o banco..."
     Server.__init__(self, url)
     
     #self.erase_tables(_DOCBASES_TO_REMOVE) 
     
     act = self
     test_and_create = lambda doc: doc in act and act[doc] or act.create(doc)
     for attribute in _DOCBASES:
         setattr(Activ, attribute, test_and_create(attribute))
开发者ID:labase,项目名称:activnce,代码行数:10,代码来源:X_XX_XXXXremove_fromtags.py


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