import solr import pickle from collections import defaultdict import zlib, base64, re, time, random, string, math import pytyrant import datetime now = datetime.datetime.utcnow() IMPORTDATE = now.strftime("%Y-%m-%dT%H:%M:%SZ") try: import json except ImportError: import simplejson as json _fp_solr = solr.SolrConnectionPool("http://localhost:8502/solr/fp") _hexpoch = int(time.time() * 1000) logger = logging.getLogger(__name__) _tyrant_address = ['localhost', 1978] _tyrant = None class Response(object): # Response codes NOT_ENOUGH_CODE, CANNOT_DECODE, SINGLE_BAD_MATCH, SINGLE_GOOD_MATCH, NO_RESULTS, MULTIPLE_GOOD_MATCH_HISTOGRAM_INCREASED, \ MULTIPLE_GOOD_MATCH_HISTOGRAM_DECREASED, MULTIPLE_BAD_HISTOGRAM_MATCH, MULTIPLE_GOOD_MATCH = range(9) def __init__(self, code, TRID=None, score=0, qtime=0, tic=0, metadata={}): self.code = code self.qtime = qtime self.TRID = TRID self.score = score
IMPORTDATE = now.strftime("%Y-%m-%dT%H:%M:%SZ") try: import json except ImportError: import simplejson as json import yaml with open('../config.yml', 'r') as f: config = yaml.load(f) solr_server = config['solr']['url'] tyrant_server = config['tyrant']['ip'] tyrant_port = config['tyrant']['port'] _fp_solr = solr.SolrConnectionPool(solr_server) _hexpoch = int(time.time() * 1000) logger = logging.getLogger(__name__) _tyrant_address = [tyrant_server, tyrant_port] _tyrant = None _tyrant_lock = None class Response(object): # Response codes NOT_ENOUGH_CODE, CANNOT_DECODE, SINGLE_BAD_MATCH, SINGLE_GOOD_MATCH, NO_RESULTS, MULTIPLE_GOOD_MATCH_HISTOGRAM_INCREASED, \ MULTIPLE_GOOD_MATCH_HISTOGRAM_DECREASED, MULTIPLE_BAD_HISTOGRAM_MATCH, MULTIPLE_GOOD_MATCH = range(9) def __init__(self, code, TRID=None, score=0, qtime=0, tic=0, metadata={}): self.code = code self.qtime = qtime