<s> import couchdb <EOL> import pyes <EOL> import pysolr <EOL> from pymongo import Connection <EOL> from celery . task import task <EOL> from celery . log import get_default_logger <EOL> import redis <EOL> log = get_default_logger ( ) <EOL> @ task <EOL> def insertDocumentMongo ( envelope , config ) : <EOL> try : <EOL> conf = config [ '<STR_LIT>' ] <EOL> con = Connection ( conf [ '<STR_LIT:host>' ] , conf [ '<STR_LIT:port>' ] ) <EOL> db = con [ conf [ '<STR_LIT>' ] ] <EOL> collection = db [ conf [ '<STR_LIT>' ] ] <EOL> del envelope [ '<STR_LIT>' ] <EOL> del envelope [ '<STR_LIT>' ] <EOL> collection . insert ( envelope ) <EOL> except ( Exception ) , exc : <EOL> log . error ( "<STR_LIT>" ) <EOL> processHarvestResult . retry ( exc ) <EOL> @ task <EOL> def insertDocumentCouchdb ( envelope , config ) : <EOL> try : <EOL> conf = config [ '<STR_LIT>' ] <EOL> db = couchdb . Database ( conf [ '<STR_LIT>' ] ) <EOL> del envelope [ '<STR_LIT>' ] <EOL> del envelope [ '<STR_LIT>' ] <EOL> db . save ( envelope ) <EOL> except ( Exception ) , exc : <EOL> log . error ( "<STR_LIT>" ) <EOL> processHarvestResult . retry ( exc ) <EOL> @ task <EOL> def insertDocumentElasticSearch ( envelope , config ) : <EOL> r = config [ '<STR_LIT>' ] <EOL> r = redis . StrictRedis ( host = r [ '<STR_LIT:host>' ] , port = r [ '<STR_LIT:port>' ] , db = r [ '<STR_LIT>' ] ) <EOL> count = r . incr ( '<STR_LIT>' ) <EOL> conf = config [ '<STR_LIT>' ] <EOL> es = pyes . ES ( "<STR_LIT>" . format ( conf [ '<STR_LIT:host>' ] , conf [ '<STR_LIT:port>' ] ) ) <EOL> index = { "<STR_LIT>" : envelope [ '<STR_LIT>' ] , '<STR_LIT>' : envelope [ '<STR_LIT>' ] , '<STR_LIT>' : envelope [ '<STR_LIT>' ] } <EOL> es . index ( index , conf [ '<STR_LIT:index>' ] , conf [ '<STR_LIT>' ] , count ) <EOL> @ task <EOL> def insertDocumentSolr ( envelope , config ) : <EOL> pass </s>
