Example #1
0
def main(cid):
    worker = CouchDBWorker()
    enq = CouchDBJobEnqueue()
    timeout = 100000
    cdb = get_couchdb()
    worker.run_by_collection(cid, delete_field_and_queue_image_harvest,
                             'object', cdb, enq)
def get_id_on_queue_and_run(queue):
    cdbworker = CouchDBWorker()
    cid = queue.get_nowait()
    while cid:
        print "STARTING COLLECTION: {}".format(cid)
        cdbworker.run_by_collection(cid, report_non_unicode_data)
        print "FINISHED COLLECTION: {}".format(cid)
        cid = queue.get_nowait()
Example #3
0
def main(user_email, cid, field_list):
    worker = CouchDBWorker()
    timeout = 100000
    cdb = get_couchdb()
    worker.run_by_collection(cid,
                     delete_field_list,
                     field_list,
                     cdb
                     )
Example #4
0
def main(user_email, cid, url_couchdb_src, field_list, url_couchdb_dest=None):
    worker = CouchDBWorker()
    timeout = 100000
    cdb_src = get_couchdb(url=url_couchdb_src, username=False, password=False)
    if url_couchdb_dest:
        cdb_dest = get_couchdb(url=url_couchdb_dest)
    else:
        cdb_dest = get_couchdb()
    worker.run_by_collection(cid, copy_fields_for_doc, cdb_src, field_list,
                             cdb_dest)
def main(cid):
    worker = CouchDBWorker()
    enq = CouchDBJobEnqueue()
    timeout = 100000
    cdb = get_couchdb()
    worker.run_by_collection(cid,
                     delete_field_and_queue_image_harvest,
                     'object',
                     cdb,
                     enq
                     )
def get_id_on_queue_and_run(queue):
    cdbworker = CouchDBWorker()
    cid = queue.get_nowait()
    while cid:
        c_reg = Collection(url_api_base+cid)
        h = HarvestController('*****@*****.**', c_reg)
        c_couch = h._add_registry_data({})['collection']
        del(h)
        print "STARTING COLLECTION: {}".format(cid)
        cdbworker.run_by_collection(cid, fix_registry_data, c_couch, cdbworker._couchdb)
        print "FINISHED COLLECTION: {}".format(cid)
        cid = queue.get_nowait()
def get_id_on_queue_and_run(queue):
    cdbworker = CouchDBWorker()
    cid = queue.get_nowait()
    while cid:
        c_reg = Collection(url_api_base + cid)
        h = HarvestController('*****@*****.**', c_reg)
        c_couch = h._add_registry_data({})['collection']
        del (h)
        print "STARTING COLLECTION: {}".format(cid)
        cdbworker.run_by_collection(cid, fix_registry_data, c_couch,
                                    cdbworker._couchdb)
        print "FINISHED COLLECTION: {}".format(cid)
        cid = queue.get_nowait()
Example #8
0
def main(user_email, cid, url_couchdb_src, field_list, url_couchdb_dest=None):
    worker = CouchDBWorker()
    timeout = 100000
    cdb_src = get_couchdb(url=url_couchdb_src, username=False, password=False)
    if url_couchdb_dest:
        cdb_dest= get_couchdb(url=url_couchdb_dest)
    else:
        cdb_dest= get_couchdb()
    worker.run_by_collection(cid,
                     copy_fields_for_doc,
                     cdb_src,
                     field_list,
                     cdb_dest
                     )
Example #9
0
class CouchDBWorkerTestCase(TestCase):
    '''Test the running of functions against sets of couchdb documents.
    '''
    @httpretty.activate
    def setUp(self):
        self.conf = config()
        self.url_couch_base = self.conf['couchdb_url']
        self.cdb = self.conf['couchdb_dbname']
        url_head = os.path.join(self.url_couch_base, self.cdb)
        httpretty.register_uri(httpretty.HEAD,
                               url_head,
                               body='',
                               content_length='0',
                               content_type='text/plain; charset=utf-8',
                               connection='close',
                               server='CouchDB/1.5.0 (Erlang OTP/R16B03)',
                               cache_control='must-revalidate',
                               date='Mon, 24 Nov 2014 21:30:38 GMT')
        self._cdbworker = CouchDBWorker()

        def func_for_test(doc, *args, **kwargs):
            return doc, args, kwargs

        self.function = func_for_test

    @httpretty.activate
    def testCollectionSlice(self):
        '''Test that results are correct for a known couchdb result'''
        url_to_pretty = os.path.join(self.url_couch_base, self.cdb, '_design',
                                     COUCHDB_VIEW.split('/')[0], '_view',
                                     COUCHDB_VIEW.split('/')[1])
        httpretty.register_uri(
            httpretty.GET,
            re.compile(url_to_pretty + ".*$"),
            body=open(DIR_FIXTURES +
                      '/couchdb_by_provider_name-5112.json').read(),
            etag="2U5BW2TDDX9EHZJOO0DNE29D1",
            content_type='application/json',
        )

        results = self._cdbworker.run_by_collection('5112',
                                                    self.function,
                                                    'arg1',
                                                    'arg2',
                                                    kwarg1='1',
                                                    kwarg2=2)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[1][0],
                         '5112--http://ark.cdlib.org/ark:/13030/kt7779r8zj')
        self.assertEqual(results[1][1][1], ('arg1', 'arg2'))
        self.assertEqual(results[1][1][2], {'kwarg1': '1', 'kwarg2': 2})
        doc = results[0][1][0]
        self.assertEqual(doc['isShownAt'],
                         'http://www.coronado.ca.us/library/')
Example #10
0
class CouchDBWorkerTestCase(TestCase):
    '''Test the running of functions against sets of couchdb documents.
    '''
    @httpretty.activate
    def setUp(self):
        self.conf = config()
        self.url_couch_base = self.conf['couchdb_url']
        self.cdb = self.conf['couchdb_dbname']
        url_head = os.path.join(self.url_couch_base, self.cdb)
        httpretty.register_uri(httpretty.HEAD,
                url_head,
                body='',
                content_length='0',
                content_type='text/plain; charset=utf-8',
                connection='close',
                server='CouchDB/1.5.0 (Erlang OTP/R16B03)',
                cache_control='must-revalidate',
                date='Mon, 24 Nov 2014 21:30:38 GMT'
                )
        self._cdbworker = CouchDBWorker()
        def func_for_test(doc, *args, **kwargs):
            return doc, args, kwargs
        self.function = func_for_test


    @httpretty.activate
    def testCollectionSlice(self):
        '''Test that results are correct for a known couchdb result'''
        url_to_pretty = os.path.join(self.url_couch_base, self.cdb,
                '_design', COUCHDB_VIEW.split('/')[0],
                '_view', COUCHDB_VIEW.split('/')[1])
        httpretty.register_uri(httpretty.GET,
                re.compile(url_to_pretty+".*$"),
                body=open(DIR_FIXTURES+'/couchdb_by_provider_name-5112.json').read(),
                etag="2U5BW2TDDX9EHZJOO0DNE29D1",
                content_type='application/json',
                )

        results = self._cdbworker.run_by_collection('5112', self.function,
                'arg1', 'arg2', kwarg1='1', kwarg2=2)
        self.assertEqual(len(results), 3)
        self.assertEqual(results[1][0], '5112--http://ark.cdlib.org/ark:/13030/kt7779r8zj')
        self.assertEqual(results[1][1][1], ('arg1', 'arg2'))
        self.assertEqual(results[1][1][2], {'kwarg1':'1', 'kwarg2':2})
        doc = results[0][1][0]
        self.assertEqual(doc['isShownAt'], 'http://www.coronado.ca.us/library/')