def handle(self, **options):
        for design in get_preindex_designs():
            print("Touching", design)
            index_design_doc(design, wait=False)

        for design in get_preindex_designs():
            print("Waiting for", design)
            index_design_doc(design, wait=True)
    def handle(self, **options):
        for design in get_preindex_designs():
            print("Touching", design)
            index_design_doc(design, wait=False)

        for design in get_preindex_designs():
            print("Waiting for", design)
            index_design_doc(design, wait=True)
    def handle_sync(self):
        # pooling is only important when there's a serious reindex
        # (but when there is, boy is it important!)
        pool = Pool(self.num_pool)
        for design in get_preindex_designs():
            pool.spawn(sync_design_doc, design, temp='tmp')

        print "All apps loaded into jobs, waiting..."
        pool.join()
        # reraise any error
        for greenlet in pool.greenlets:
            try:
                greenlet.get()
            except Exception:
                print "Error in greenlet", greenlet
                print_stack()
        print "All apps reported complete."
    def handle_sync(self):
        # pooling is only important when there's a serious reindex
        # (but when there is, boy is it important!)
        pool = Pool(self.num_pool)
        for design in get_preindex_designs():
            pool.spawn(sync_design_doc, design, temp='tmp')

        print "All apps loaded into jobs, waiting..."
        pool.join()
        # reraise any error
        for greenlet in pool.greenlets:
            try:
                greenlet.get()
            except Exception:
                print "Error in greenlet", greenlet
                print_stack()
        print "All apps reported complete."
示例#5
0
    def handle(self, **options):
        # build a data structure indexing databases to relevant design docs
        db_label_map = defaultdict(lambda: set())

        # pull design docs from preindex plugins
        for design in get_preindex_designs():
            if design.design_path:
                db_label_map[design.db.uri].add(design.app_label)

        designs_to_delete = {}
        for db_uri in db_label_map:
            db = Database(db_uri)
            expected_designs = db_label_map[db_uri]
            design_docs = get_design_docs(db)
            found_designs = set(dd.name for dd in design_docs)
            to_delete = found_designs - expected_designs
            if to_delete:
                designs_to_delete[db] = [
                    ddoc._doc for ddoc in design_docs if ddoc.name in to_delete
                ]
                print('\ndeleting from {}:\n---------------------'.format(
                    db.dbname))
                print('\n'.join(sorted(to_delete)))

        if designs_to_delete:
            if options['noinput'] or input('\n'.join([
                    '\n\nReally delete all the above design docs?',
                    'If any of these views are actually live, bad things will happen. '
                    '(Type "delete designs" to continue):',
                    '',
            ])).lower() == 'delete designs':
                for db, design_docs in designs_to_delete.items():
                    for design_doc in design_docs:
                        # If we don't delete conflicts, then they take the place of the
                        # document when it's deleted. (That's how couch works.)
                        # This results in a huge reindex for an old conflicted version
                        # of a design doc we don't even want anymore.
                        delete_conflicts(db, design_doc['_id'])
                    db.delete_docs(design_docs)
            else:
                print('aborted!')
        else:
            print('database already completely pruned!')
示例#6
0
    def handle(self, **options):
        # build a data structure indexing databases to relevant design docs
        db_label_map = defaultdict(lambda: set())

        # pull design docs from preindex plugins
        for design in get_preindex_designs():
            if design.design_path:
                db_label_map[design.db.uri].add(design.app_label)

        designs_to_delete = {}
        for db_uri in db_label_map:
            db = Database(db_uri)
            expected_designs = db_label_map[db_uri]
            design_docs = get_design_docs(db)
            found_designs = set(dd.name for dd in design_docs)
            to_delete = found_designs - expected_designs
            if to_delete:
                designs_to_delete[db] = [ddoc._doc for ddoc in design_docs if ddoc.name in to_delete]
                print('\ndeleting from {}:\n---------------------'.format(db.dbname))
                print('\n'.join(sorted(to_delete)))

        if designs_to_delete:
            if options['noinput'] or input('\n'.join([
                    '\n\nReally delete all the above design docs?',
                    'If any of these views are actually live, bad things will happen. '
                    '(Type "delete designs" to continue):',
                    '',
            ])).lower() == 'delete designs':
                for db, design_docs in designs_to_delete.items():
                    for design_doc in design_docs:
                        # If we don't delete conflicts, then they take the place of the
                        # document when it's deleted. (That's how couch works.)
                        # This results in a huge reindex for an old conflicted version
                        # of a design doc we don't even want anymore.
                        delete_conflicts(db, design_doc['_id'])
                    db.delete_docs(design_docs)
            else:
                print('aborted!')
        else:
            print('database already completely pruned!')
示例#7
0
def preindex_couch_views():
    for design in get_preindex_designs():
        index_design_doc(design)
示例#8
0
def preindex_couch_views():
    for design in get_preindex_designs():
        index_design_doc(design)