def identify_task_exist(task_id): status = True try: task_exist_result = es_group_result.get(index=group_index_name, doc_type=group_index_type, id=task_id)['_source'] except: task_exist_result = {} if task_exist_result != {}: status = True return status
def exist(task_id): try: task_exist = es.get(index=index_name, doc_type=index_type, id=task_id)['_source'] except: task_exist = {} if not task_exist: return False else: if task_exist['status'] == 1: return False return True
def change_process_proportion(task_id, proportion): mark = False try: task_exist_result = es_group_result.get(index=group_index_name, doc_type=group_index_type, id=task_id)['_source'] except: task_exist_result = {} return 'task is not exist' if task_exist_result != {}: task_exist_result['detect_process'] = proportion es_group_result.index(index=group_index_name, doc_type=group_index_type, id=task_id, body=task_exist_result) mark = True return mark
def save_detect_results(detect_results, task_id): mark = False try: task_exist_result = es_group_result.get(index=group_index_name, doc_type=group_index_type, id=task_id)['_source'] except: task_exist_result = {} if task_exist_result != {}: task_exist_result['uid_list'] = json.dumps(detect_results) task_exist_result['detect_process'] = 100 es_group_result.index(index=group_index_name, doc_type=group_index_type, id=task_id, body=task_exist_result) mark = True return mark
def save_group_results(results): status = False # step1: identify the task is exist try: task_exist_result = es.get(index=index_name, doc_type=index_type, id=results["task_name"])["_source"] except: task_exist_result = {} # step2: save result if task_exist_result != {}: es.index(index=index_name, doc_type=index_type, body=results, id=results["task_name"]) status = True return status
def save_group_results(results): status = False submit_user = results['submit_user'] task_name = results['task_name'] task_id = results['task_id'] #step1: identify the task is exist try: task_exist_result = es.get(index=index_name, doc_type=index_type, id=task_id)['_source'] except: task_exist_result = {} #step2: save result #if task_exist_result != {}: es.index(index=index_name, doc_type=index_type, body=results, id=task_id) status = True print 'save group results:', status return status
def save_group_results(results): status = False #step1: identify the task is exist try: task_exist_result = es.get(index=index_name, doc_type=index_type, id=results['task_name'])['_source'] except: task_exist_result = {} #step2: save result if task_exist_result != {}: es.index(index=index_name, doc_type=index_type, body=results, id=results['task_name']) status = True return status