コード例 #1
0
ファイル: multi_query.py プロジェクト: saggu/MediaScope
def accept_query(qid, paras):
        global pending_photo, pending_task
        pending_task[qid] = {}
	pending_photo[qid] = {}
	#f = open('timestamp','w')
	#a = time.time()
	(result, meta) = multi_query_lib.select(paras)
	#b = time.time()
	#f.write(str(b-a))
	#f.close()
        print "result = "+str(result)
        print "meta = "+str(meta)
        if (len(result)) == 0:
                return
        f = open('upload_xml','r')
	upload_xml_file = ''
        upload_xml_file += "<xml>\n\t<app>\n"

	for user in result:
                task_id = "PHOTO_UPLOAD_" + multi_query_lib.unique_id()
		print "=="+str(user)+str(result[user])
                upload_xml_file += "<input>\n" + multi_query_lib.generate_task_file(task_id, user, result[user])
		pending_task[qid][user] = [] 
                pending_task[qid][user].append(task_id)
                uids = result[user].split('|')
                #metas = meta[user].split('|')
                for i in range(len(uids)):
			only_uid = uids[i].split(':')
                        pending_task[qid][user].append(only_uid[0])
                        pending_photo[qid][user + '=' + only_uid[0]] = int(only_uid[1])
        upload_xml_file += f.read()
        if multi_query_lib.send_task([((C2DM_M_S + '_kill.xml'), upload_xml_file)]) == -1:
		print "Send upload task failed"	
        print "Pending photos: "+str(pending_photo)
        print "Pending tasks: "+str(pending_task)
コード例 #2
0
def accept_query(qid, paras):
    global pending_photo, pending_task
    pending_task[qid] = {}
    pending_photo[qid] = {}

    (result, meta) = multi_query_lib.select(paras)
    print "query_result = " + str(result)
    #print "meta = "+str(meta)
    if (len(result)) == 0:
        return
    f = open('upload_xml', 'r')
    upload_xml_file = ''

    for user in result:
        task_id = "PHOTO_UPLOAD_" + multi_query_lib.unique_id()
        #print "=="+str(user)+str(result[user])
        upload_xml_file += multi_query_lib.generate_task_file(
            task_id, user, result[user])
        pending_task[qid][user] = []
        pending_task[qid][user].append(task_id)
        uids = result[user].split('|')
        #metas = meta[user].split('|')
        for i in range(len(uids)):
            only_uid = uids[i].split(':')
            pending_task[qid][user].append(only_uid[0])
            pending_photo[qid][user + '=' + only_uid[0]] = int(only_uid[1])
    upload_xml_file += f.read()
    if multi_query_lib.send_task([('c2dm_kill.xml', upload_xml_file)]) == -1:
        print "Send upload task failed"
    print "Pending photos: " + str(pending_photo)
    print "Pending tasks: " + str(pending_task)
コード例 #3
0
ファイル: multi_query.py プロジェクト: saggu/MediaScope
def kill_users(users):
        f = open('kill_xml','r')
        kill_xml_file = ''

        for user, pending_list in users.iteritems():
                task_id = "KILL_STAGE_" + multi_query_lib.unique_id()
                kill_xml_file += multi_query_lib.generate_task_file(task_id, user, "{"+pending_list[0]+"}")
                kill_xml_file += f.read()
                if multi_query_lib.send_task([((C2DM_M_S + '_upload.xml'), kill_xml_file)]) == -1:
			print "Send kill task failed"
        print "kill: "+str(users)
コード例 #4
0
def accept_query(qid, paras):  # function for sending query to Medusa
    global pending_photo, pending_task
    pending_task[qid] = {}
    pending_photo[qid] = {}

    result = multi_query_lib.select_id(
        paras)  # get parameters of the image (like uid, lat, lng, time, etc.)

    print "accept_query: result returned from select =========================="
    print "result = " + str(result)

    if (len(result)) == 0:
        return

    f = open('upload_xml',
             'r')  # generate the query xml that should be sent to Medusa
    upload_xml_file = ''
    upload_xml_file += "<xml>\n\t<app>\n"
    for user in result:
        task_id = "PHOTO_UPLOAD_" + multi_query_lib.unique_id()
        print "==" + str(user) + str(result[user])
        upload_xml_file += "<input>\n" + multi_query_lib.generate_task_file(
            task_id, user, result[user])
        pending_task[qid][user] = []
        pending_task[qid][user].append(task_id)
        uids = result[user].split('|')
        for i in range(len(uids)):
            only_uid = uids[i].split(':')
            pending_task[qid][user].append(only_uid[0])
            pending_photo[qid][user + '=' + only_uid[0]] = int(only_uid[1])
    upload_xml_file += f.read()
    print "accept_query: upload_xml_file to medusa =========================="
    print upload_xml_file

    if multi_query_lib.send_task([((C2DM_M_S + '_kill.xml'), upload_xml_file)
                                  ]) == -1:  # send the xml to Medusa
        print "Send upload task failed"
    print "Pending photos: " + str(pending_photo)
    print "Pending tasks: " + str(pending_task)