Ejemplo n.º 1
0
def render(msg):
    msg = cStringIO.StringIO(msg)
    query_msg = decode_netstring_fd(msg)
    score_msg = decode_netstring_fd(msg)
    rank_msg = decode_netstring_fd(msg)

    site_check = True
    show_score = False

    try:
        query = make_query.parse_qs(query_msg['query'])
        if 'offs' in query:
            offs = int(query['offs'])
        else:
            offs = 0
        query_q = query['q']

        if query_msg['mods']:
            if query_msg['mods'].startswith("site"):
                site_check = False
            elif query_msg['mods'].startswith("score"):
                show_score = True

    except Exception, x:
        erlay.report("Invalid or missing query string: %s" %
                     query_msg['query'])
        traceback.print_exc()
        offs = 0
        query_q = ""
Ejemplo n.º 2
0
def render(msg):
        msg = cStringIO.StringIO(msg)
        query_msg = decode_netstring_fd(msg)
        score_msg = decode_netstring_fd(msg)
        rank_msg = decode_netstring_fd(msg)
		
	site_check = True
	show_score = False
        
        try:
                query = make_query.parse_qs(query_msg['query'])
                if 'offs' in query:
                        offs = int(query['offs'])
                else:
                        offs = 0
                query_q = query['q']
		
		if query_msg['mods']:
			if query_msg['mods'].startswith("site"):
				site_check = False
			elif query_msg['mods'].startswith("score"):
				show_score = True

        except Exception, x:
                erlay.report("Invalid or missing query string: %s" %
                        query_msg['query'])
                traceback.print_exc()
                offs = 0
                query_q = ""
Ejemplo n.º 3
0
def parse_query(msg):
	if normtables_need_update and\
		time.time() - last_normtable_update > NORMTABLE_UPDATE:
		update_normtable()

        query = None
        try:
                query = make_query.parse_qs(msg)
                keys, cues, mods = make_query.make_query(query['q'])
                keys = " ".join(map(str, keys))
                cues = " ".join(map(str, cues))
        	mods = " ".join(mods)
	except Exception, x:
                erlay.report("Query parsing failed: %s" % x)
                if query:
                        erlay.report("Failed query: %s" % query)
                keys = ""
                cues = ""
		mods = ""
                query = ""