Exemple #1
0
def ajax_revise_task():
    task_name = request.args.get('task_name', '')  # must
    finish = request.args.get("finish", "10")
    stop_time = request.args.get('stop_time', '')  # timestamp
    user = request.args.get('user', '')

    #now_ts = datetime2ts("2013-09-06")
    _id = user + '-' + task_name
    now_ts = time.time()
    if stop_time and stop_time < now_ts:
        return json.dumps([])

    if task_name and user:
        task_detail = es.get(index=index_manage_sensing_task,
                             doc_type=task_doc_type,
                             id=_id)['_source']
        if stop_time:
            task_detail['stop_time'] = stop_time
        if int(finish) == 0:
            task_detail['finish'] = finish
            task_detail['processing_status'] = "1"  # 重启时将处理状态改为
        if stop_time or int(finish) == 0:
            es.index(index=index_manage_sensing_task,
                     doc_type=task_doc_type,
                     id=_id,
                     body=task_detail)
            return json.dumps(['1'])
    return json.dumps([])
Exemple #2
0
def submit_task(input_data):
    status = 0 # mark it can not submit
    task_name = input_data['task_name']
    try:
        result = es.get(index=index_name, doc_type=index_type, id=task_name)
    except:
        status = 1
    
    if status != 0 and 'uid_file' not in input_data:
        r.lpush('group_task', json.dumps(input_data))
        input_data['status'] = 0 # mark the task not compute
        count = len(input_data['uid_list'])
        input_data['count'] = count
        uid_list_string = json.dumps(input_data['uid_list'])
        es.index(index='group_result', doc_type='group', id=task_name, body=input_data)
    elif status != 0 and 'uid_file' in input_data:
        input_data['status'] = 0 # mark the task not compute
        uid_file = input_data['uid_file']
        uid_list = read_uid_file(uid_file)
        input_data['count'] = len(uid_list)
        input_data['uid_list'] = json.dumps(uid_list)
        r.lpush('group_task', json.dumps(input_data))
        es.index(index='group_result', doc_type='group', id=task_name, body=input_data)
        delete_status = delete_uid_file(uid_file)
        if delete_status == 0:
            print 'fail delete uid file'
        elif delete_status == 1:
            print 'success delete uid file'
    return status
def add_attribute_portrait(uid, attribute_name, attribute_value, submit_user):
    status = False
    submit_user_tag = submit_user + "-tag"
    id_attribute = submit_user + "-" + attribute_name
    add_attribute_value = attribute_name + "-" + attribute_value
    # identify the user exist
    # identify the attribute exist
    # identify the attribute exist in user_portrait
    # add attribute in user_portrait
    try:
        user_result = es.get(index=user_index_name, doc_type=user_index_type, id=uid)['_source']
    except:
        return 'no user'
    try:
        attribute_result = es_tag.get(index=attribute_index_name, doc_type=attribute_index_type, id=id_attribute)['_source']
    except:
        return 'no attribute'
    attribute_value_list = attribute_result['attribute_value'].split('&')
    if attribute_value not in attribute_value_list:
        return 'no attribute value'
    value_set = set()
    for value in attribute_value_list:
        value_set.add(attribute_name + '-' + value) #
    submit_user_attribute = user_result.get(submit_user_tag, '') # 个人是否存在该管理员打上的个人标签
    tmp_attribute_set = set(submit_user_attribute.split('&'))
    attribute_exist = tmp_attribute_set & value_set
    if attribute_exist:
        return 'attribute exist'
    user_result[submit_user_tag] = "&".join([submit_user_attribute, add_attribute_value])
    es.index(index=user_index_name, doc_type=user_index_type, id=uid, body=user_result)
    status = True
    return status
def change_attribute_portrait(uid, attribute_name, attribute_value, submit_user):
    status = False
    submit_user_tag = submit_user + "-tag"
    id_attribute = submit_user + "-" + attribute_name
    #identify the user exist
    #identify the attribute exist
    #identify the attribute value exist
    #identify the submit_user have been admitted----without 
    try:
        user_result = es.get(index=user_index_name, doc_type=user_index_type, id=uid)['_source']
    except:
        return 'no user'
    try:
        attribute_result = es_tag.get(index=attribute_index_name, doc_type=attribute_index_type, id=id_attribute)['_source']
    except:
        return 'no attribute'
    value_list = attribute_result['attribute_value'].split('&')
    if attribute_value not in value_list:
        return 'no attribute value'
    submit_user_attribute = user_result.get(submit_user_tag, '') # 个人是否存在该管理员打上的个人标签
    if attribute_name not in submit_user_attribute:
        return 'personal attribute no exist'
    tmp_attribute_list = submit_user_attribute.split("&")
    attribute_list = []
    for item in tmp_attribute_list:
        if attribute_name in item:
            attribute_list.append(attribute_name + '-' + attribute_value)
        else:
            attribute_list.append(item)
    user_result[submit_user_tag] = "&".join(attribute_list)
    es.index(index=user_index_name, doc_type=user_index_type, id=uid, body=user_result)
    status = True
    return status
Exemple #5
0
def delete_attribute_portrait(uid, attribute_name, submit_user):
    status = False
    submit_user_tag = submit_user + "-tag"
    id_attribute = submit_user + "-" + attribute_name
    #identify the user exist
    #identify the attribute value exist in es_user_portrait
    #identify the submit_user have been admitted---without
    try:
        user_result = es.get(index=user_index_name,
                             doc_type=user_index_type,
                             id=uid)['_source']
    except:
        return 'no user'
    submit_user_attribute = user_result.get(submit_user_tag, '')
    if attribute_name not in submit_user_attribute:
        return 'user have no attribtue'
    try:
        tmp_attribute = submit_user_attribute.split('&')
        for item in tmp_attribute:
            if attribute_name in item:
                tmp_attribute.remove(item)
        user_result[submit_user_tag] = "&".join(tmp_attribute)
        es.index(index=user_index_name,
                 doc_type=user_index_type,
                 id=uid,
                 body=user_result)
        status = True
    except Exception, e:
        raise e
def add_tag2group(uid_list, attribute_name, attribute_value, submit_user):
    id_attribute = submit_user + "-" + attribute_name
    add_attribute = attribute_name + "-" + attribute_value
    submit_user_tag = submit_user + "-tag"
    status = False
    #identify the attribute exist
    #for uid in uid_list
    #identify the attribute not in this user
    #add tag to this user
    try:
        attribute_exist = es_tag.get(index=attribute_index_name, doc_type=attribute_index_type, id=id_attribute)['_source']
    except:
        return 'no attribute'
    attribute_exist_value_list = attribute_exist['attribute_value'].split('&')
    if attribute_value not in attribute_exist_value_list:
        return 'no attribute value'
    for uid in uid_list:
        try:
            user_exist = es.get(index=user_index_name, doc_type=user_index_type, id=uid)['_source']
        except:
            user_exist = {}
            continue
        submit_user_attribute = user_exist.get(submit_user_tag, '')
        if user_exist and attribute_name not in submit_user_attribute:
            user_exist[submit_user_tag] = "&".join([submit_user_attribute, add_attribute])
            es.index(index=user_index_name, doc_type=user_index_type, id=uid, body=user_exist)
    status = True
    return status
def ajax_create_task():
    # task_name forbid illegal enter
    task_name = request.args.get('task_name','') # must
    create_by = request.args.get('create_by', 'admin') #
    stop_time = request.args.get('stop_time', "default") #timestamp, 1234567890
    social_sensors = request.args.get("social_sensors", "") #uid_list, split with ","
    keywords = request.args.get("keywords", "") # keywords_string, split with ","
    sensitive_words = request.args.get("sensitive_words", "") # sensitive_words, split with ","
    remark = request.args.get("remark", "")
    create_time = request.args.get('create_time', '')

    exist_es = es.exists(index=index_manage_sensing_task, doc_type=task_doc_type, id=task_name)
    if exist_es:
        return json.dumps(["0"]) # 任务名不能重合

    if task_name:
        task_detail = dict()
        task_detail["task_name"] = task_name
        task_detail["create_by"] = create_by
        task_detail["stop_time"] = stop_time
        task_detail["remark"] = remark
        if social_sensors:
            task_detail["social_sensors"] = json.dumps(list(set(social_sensors.split(','))))
        else:
            task_detail["social_sensors"] = json.dumps([])
        if keywords:
            task_detail["keywords"] = json.dumps(keywords.split(","))
        else:
            task_detail["keywords"] = json.dumps([])
        if sensitive_words:
            task_detail["sensitive_words"] = json.dumps(sensitive_words.split(","))
        else:
            task_detail["sensitive_words"] = json.dumps([])
        now_ts = int(time.time())
        task_detail["create_at"] = create_time # now_ts
        task_detail["warning_status"] = '0'
        task_detail["finish"] = "0" # not end the task
        task_detail["history_status"] = json.dumps([]) # ts, keywords, warning_status
        task_detail['burst_reason'] = ''
        task_detail['processing_status'] = "1" #任务正在进行
        if keywords:
            if social_sensors:
                task_detail["task_type"] = "3"
            else:
                task_detail["task_type"] = "2"
        else:
            if social_sensors:
                task_detail["task_type"] = "1"
            else:
                task_detail["task_type"] = "0"

    # store task detail into es
    es.index(index=index_manage_sensing_task, doc_type=task_doc_type, id=task_name, body=task_detail)


    return json.dumps(["1"])
def ajax_stop_task():
    task_name = request.args.get('task_name','') # must
    if task_name:
        task_detail = es.get(index=index_manage_sensing_task, doc_type=task_doc_type, id=task_name)['_source']
        #task_detail["finish"] = finish_signal
        task_detail['processing_status'] = '0'
        es.index(index=index_manage_sensing_task, doc_type=task_doc_type, id=task_name, body=task_detail)
        return json.dumps(['1'])
    else:
        return json.dumps([])
def ajax_stop_task():
    task_name = request.args.get('task_name','') # must
    user = request.args.get('user', '')
    if task_name and user:
        _id = user + "-" + task_name
        task_detail = es.get(index=index_manage_sensing_task, doc_type=task_doc_type, id=_id)['_source']
        #task_detail["finish"] = finish_signal
        task_detail['processing_status'] = '0'
        es.index(index=index_manage_sensing_task, doc_type=task_doc_type, id=_id, body=task_detail)
        return json.dumps(['1'])
    else:
        return json.dumps([])
def ajax_create_task():
    # task_name forbid illegal enter
    task_number = request.args.get('task_number', 1)
    task_name = request.args.get('task_name','') # must
    create_by = request.args.get('create_by', 'admin') # 用户
    stop_time = request.args.get('stop_time', "default") #timestamp, 1234567890
    social_sensors = request.args.get("social_sensors", "") #uid_list, split with ","
    remark = request.args.get("remark", "")
    _id = create_by + "-" + str(task_name)
    exist_es = es.exists(index=index_manage_sensing_task, doc_type=task_doc_type, id=_id)
    if exist_es:
        return json.dumps(["0"]) # 任务名不能重合
    query_body = {
        "query":{
            "filtered":{
                "filter":{
                    "bool":{
                        "must":[
                            {"term":{"processing_status": "1"}},
                            {"term":{"finish":"0"}}
                        ]
                    }
                }
            }
        }
    }
    
    unfinish_number =  es.count(index=index_manage_sensing_task, doc_type=task_doc_type, body=query_body)['count']
    if unfinish_number > (int(task_number)-1):
        return "more than limit"
    if task_name:
        task_detail = dict()
        task_detail["task_name"] = task_name
        task_detail["create_by"] = create_by # 创建任务, user
        task_detail["stop_time"] = stop_time
        task_detail["remark"] = remark
        if social_sensors:
            task_detail["social_sensors"] = json.dumps(list(set(social_sensors.split(','))))
        else:
            return json.dumps(['-1'])
        now_ts = int(time.time())
        task_detail["create_at"] = now_ts # now_ts
        task_detail["warning_status"] = '0'
        task_detail["finish"] = "0" # not end the task
        task_detail["history_status"] = json.dumps([]) # ts, keywords, warning_status
        task_detail['burst_reason'] = ''
        task_detail['processing_status'] = "1" #任务正在进行

    # store task detail into es
    es.index(index=index_manage_sensing_task, doc_type=task_doc_type, id=_id, body=task_detail)


    return json.dumps(["1"])
Exemple #11
0
def submit_task(input_data):
    status = 0 # mark it can not submit
    task_name = input_data['task_name']
    try:
        result = es.get(index=index_name, doc_type=index_type, id=task_name)
    except:
        status = 1
    if status != 0:
        r.lpush('group_task', json.dumps(input_data))
        input_data['status'] = 0 # mark the task not compute
        count = len(input_data['uid_list'])
        input_data['count'] = count
        uid_list_string = json.dumps(input_data['uid_list'])
        es.index(index='group_result', doc_type='group', id=task_name, body=input_data)
    return status
Exemple #12
0
def delete_attribute_portrait(uid, attribute_name, submit_user):
    status = False
    #identify the user exist
    #identify the attribute value exist in es_user_portrait
    #identify the submit_user have been admitted---without
    try:
        user_exist = es.get(index=user_index_name, doc_type=user_index_type, id=uid)['_source']
    except:
        return 'no user'
    if attribute_name not in user_exist:
        return 'user have no attribtue'
    try:
        del_attribute_value = user_exist.pop(attribute)
        es.index(index=user_index_name, doc_type=user_index_type, body=user_exist)
        status = True
    except Exception, e:
        raise e
Exemple #13
0
def ajax_create_task():
    # task_name forbid illegal enter
    task_name = request.args.get('task_name', '')  # must
    create_by = request.args.get('create_by', 'admin')  # 用户
    stop_time = request.args.get('stop_time',
                                 "default")  #timestamp, 1234567890
    social_sensors = request.args.get("social_sensors",
                                      "")  #uid_list, split with ","
    #keywords = request.args.get("keywords", "") # keywords_string, split with ","
    #sensitive_words = request.args.get("sensitive_words", "") # sensitive_words, split with ","
    remark = request.args.get("remark", "")
    _id = create_by + "-" + str(task_name)
    exist_es = es.exists(index=index_manage_sensing_task,
                         doc_type=task_doc_type,
                         id=_id)
    if exist_es:
        return json.dumps(["0"])  # 任务名不能重合

    if task_name:
        task_detail = dict()
        task_detail["task_name"] = task_name
        task_detail["create_by"] = create_by  # 创建任务, user
        task_detail["stop_time"] = stop_time
        task_detail["remark"] = remark
        if social_sensors:
            task_detail["social_sensors"] = json.dumps(
                list(set(social_sensors.split(','))))
        else:
            return json.dumps(['-1'])
        now_ts = int(time.time())
        task_detail["create_at"] = now_ts  # now_ts
        task_detail["warning_status"] = '0'
        task_detail["finish"] = "0"  # not end the task
        task_detail["history_status"] = json.dumps(
            [])  # ts, keywords, warning_status
        task_detail['burst_reason'] = ''
        task_detail['processing_status'] = "1"  #任务正在进行

    # store task detail into es
    es.index(index=index_manage_sensing_task,
             doc_type=task_doc_type,
             id=_id,
             body=task_detail)

    return json.dumps(["1"])
Exemple #14
0
def change_attribute(attribute_name, value, user, state):
    status = False
    # identify the attribute_name is in ES - custom attribute
    try:
        result =  es.get(index=attribute_index_name, doc_type=attribute_index_type, id=attribute_name)['_source']
    except:
        result = None
        return status
    value_list = value.split('&')
    result['value'] = json.dumps(value_list)
    result['user'] = user
    result['state'] = state
    now_ts = time.time()
    now_date = ts2datetime(now_ts)
    result['date'] = now_date
    es.index(index=attribute_index_name, doc_type=attribute_index_type, body=result)
    status = True
    return status
Exemple #15
0
def submit_attribute(attribute_name, attribute_value, submit_user, state):
    status = False
    #maybe there have to identify the user admitted to submit attribute
    attribute_exist = es.get(index=attribute_index_name, doc_type=attribute_index_type, id=attribute_name)['docs']
    try:
        source = attribute_exist['_source']
    except:
        input_data = dict()
        now_ts = time.time()
        date = ts2datetime(now_ts)
        input_data['name'] = attribute_name
        input_data['value'] = json.dumps(attribute_value.split('&'))
        input_data['user'] = submit_user
        input_data['state'] = state
        input_data['date'] = date
        es.index(index=attribute_index_name, doc_type=attribute_index_type, id=attribute_name, body=input_data)
        status = True
    return status
Exemple #16
0
def add_attribute_portrait(uid, attribute_name, attribute_value, submit_user):
    status = False
    submit_user_tag = submit_user + "-tag"
    id_attribute = submit_user + "-" + attribute_name
    add_attribute_value = attribute_name + "-" + attribute_value
    # identify the user exist
    # identify the attribute exist
    # identify the attribute exist in user_portrait
    # add attribute in user_portrait
    try:
        user_result = es.get(index=user_index_name,
                             doc_type=user_index_type,
                             id=uid)['_source']
    except:
        return 'no user'
    try:
        attribute_result = es_tag.get(index=attribute_index_name,
                                      doc_type=attribute_index_type,
                                      id=id_attribute)['_source']
    except:
        return 'no attribute'
    attribute_value_list = attribute_result['attribute_value'].split('&')
    if attribute_value not in attribute_value_list:
        return 'no attribute value'
    value_set = set()
    for value in attribute_value_list:
        value_set.add(attribute_name + '-' + value)  #
    submit_user_attribute = user_result.get(submit_user_tag,
                                            '')  # 个人是否存在该管理员打上的个人标签
    tmp_attribute_set = set(submit_user_attribute.split('&'))
    attribute_exist = tmp_attribute_set & value_set
    if attribute_exist:
        return 'attribute exist'
    if submit_user_attribute:
        user_result[submit_user_tag] = "&".join(
            [submit_user_attribute, add_attribute_value])
    else:
        user_result[submit_user_tag] = add_attribute_value
    es.index(index=user_index_name,
             doc_type=user_index_type,
             id=uid,
             body=user_result)
    status = True
    return status
Exemple #17
0
def change_attribute_portrait(uid, attribute_name, attribute_value,
                              submit_user):
    status = False
    submit_user_tag = submit_user + "-tag"
    id_attribute = submit_user + "-" + attribute_name
    #identify the user exist
    #identify the attribute exist
    #identify the attribute value exist
    #identify the submit_user have been admitted----without
    try:
        user_result = es.get(index=user_index_name,
                             doc_type=user_index_type,
                             id=uid)['_source']
    except:
        return 'no user'
    try:
        attribute_result = es_tag.get(index=attribute_index_name,
                                      doc_type=attribute_index_type,
                                      id=id_attribute)['_source']
    except:
        return 'no attribute'
    value_list = attribute_result['attribute_value'].split('&')
    if attribute_value not in value_list:
        return 'no attribute value'
    submit_user_attribute = user_result.get(submit_user_tag,
                                            '')  # 个人是否存在该管理员打上的个人标签
    if attribute_name not in submit_user_attribute:
        return 'personal attribute no exist'
    tmp_attribute_list = submit_user_attribute.split("&")
    attribute_list = []
    for item in tmp_attribute_list:
        if attribute_name in item:
            attribute_list.append(attribute_name + '-' + attribute_value)
        else:
            attribute_list.append(item)
    user_result[submit_user_tag] = "&".join(attribute_list)
    es.index(index=user_index_name,
             doc_type=user_index_type,
             id=uid,
             body=user_result)
    status = True
    return status
def ajax_revise_task():
    task_name = request.args.get('task_name','') # must
    finish = request.args.get("finish", "10")
    stop_time = request.args.get('stop_time', '') # timestamp

    now_ts = datetime2ts("2013-09-06")
    #now_ts = time.time()
    if stop_time and stop_time < now_ts:
        return json.dumps([])

    if task_name:
        task_detail = es.get(index=index_manage_sensing_task, doc_type=task_doc_type, id=task_name)['_source']
        if stop_time:
            task_detail['stop_time'] = stop_time
        if int(finish) == 0:
            task_detail['finish'] = finish
            task_detail['processing_status'] = "1" # 重启时将处理状态改为
        if stop_time or int(finish) == 0:
            es.index(index=index_manage_sensing_task, doc_type=task_doc_type, id=task_name, body=task_detail)
            return json.dumps(['1'])
    return json.dumps([])
Exemple #19
0
def delete_attribute_portrait(uid, attribute_name, submit_user):
    status = False
    #identify the user exist
    #identify the attribute value exist in es_user_portrait
    #identify the submit_user have been admitted---without
    try:
        user_exist = es.get(index=user_index_name,
                            doc_type=user_index_type,
                            id=uid)['_source']
    except:
        return 'no user'
    if attribute_name not in user_exist:
        return 'user have no attribtue'
    try:
        del_attribute_value = user_exist.pop(attribute_name)
        es.index(index=user_index_name,
                 doc_type=user_index_type,
                 id=uid,
                 body=user_exist)
        status = True
    except Exception, e:
        raise e
Exemple #20
0
def add_tag2group(uid_list, attribute_name, attribute_value, submit_user):
    id_attribute = submit_user + "-" + attribute_name
    add_attribute = attribute_name + "-" + attribute_value
    submit_user_tag = submit_user + "-tag"
    status = False
    #identify the attribute exist
    #for uid in uid_list
    #identify the attribute not in this user
    #add tag to this user
    try:
        attribute_exist = es_tag.get(index=attribute_index_name,
                                     doc_type=attribute_index_type,
                                     id=id_attribute)['_source']
    except:
        return 'no attribute'
    attribute_exist_value_list = attribute_exist['attribute_value'].split('&')
    if attribute_value not in attribute_exist_value_list:
        return 'no attribute value'
    for uid in uid_list:
        try:
            user_exist = es.get(index=user_index_name,
                                doc_type=user_index_type,
                                id=uid)['_source']
        except:
            user_exist = {}
            continue
        submit_user_attribute = user_exist.get(submit_user_tag, '')
        if user_exist and attribute_name not in submit_user_attribute:
            if submit_user_attribute:
                user_exist[submit_user_tag] = "&".join(
                    [submit_user_attribute, add_attribute])
            else:
                user_exist[submit_user_tag] = add_attribute
            es.index(index=user_index_name,
                     doc_type=user_index_type,
                     id=uid,
                     body=user_exist)
    status = True
    return status
def delete_attribute_portrait(uid, attribute_name, submit_user):
    status = False
    submit_user_tag = submit_user + "-tag"
    id_attribute = submit_user + "-" + attribute_name
    #identify the user exist
    #identify the attribute value exist in es_user_portrait
    #identify the submit_user have been admitted---without
    try:
        user_result = es.get(index=user_index_name, doc_type=user_index_type, id=uid)['_source']
    except:
        return 'no user'
    submit_user_attribute = user_result.get(submit_user_tag, '')
    if attribute_name not in submit_user_attribute:
        return 'user have no attribtue'
    try:
        tmp_attribute = submit_user_attribute.split('&')
        for item in tmp_attribute:
            if attribute_name in item:
                tmp_attribute.remove(item)
        user_result[submit_user_attribute] = "&".join(tmp_attribute)
        es.index(index=user_index_name, doc_type=user_index_type, id=uid, body=user_result)
        status = True
    except Exception, e:
        raise e
Exemple #22
0
def ajax_create_task():
    # task_name forbid illegal enter
    task_name = request.args.get('task_name', '')  # must
    create_by = request.args.get('create_by', 'admin')  #
    stop_time = request.args.get('stop_time',
                                 "default")  #timestamp, 1234567890
    social_sensors = request.args.get("social_sensors",
                                      "")  #uid_list, split with ","
    keywords = request.args.get("keywords",
                                "")  # keywords_string, split with ","
    sensitive_words = request.args.get("sensitive_words",
                                       "")  # sensitive_words, split with ","
    remark = request.args.get("remark", "")
    create_time = request.args.get('create_time', '')

    exist_es = es.exists(index=index_manage_sensing_task,
                         doc_type=task_doc_type,
                         id=task_name)
    if exist_es:
        return json.dumps(["0"])  # 任务名不能重合

    if task_name:
        task_detail = dict()
        task_detail["task_name"] = task_name
        task_detail["create_by"] = create_by
        task_detail["stop_time"] = stop_time
        task_detail["remark"] = remark
        if social_sensors:
            task_detail["social_sensors"] = json.dumps(
                list(set(social_sensors.split(','))))
        else:
            task_detail["social_sensors"] = json.dumps([])
        if keywords:
            tmp_list = keywords.split(",")
            keywords_list = []
            for item in tmp_list:
                if item:
                    keywords_list.append(item.replace(' ', ''))
            task_detail["keywords"] = json.dumps(keywords_list)
        else:
            task_detail["keywords"] = json.dumps([])
        if sensitive_words:
            tmp_list = sensitive_words.split(",")
            sensitive_words_list = []
            for item in tmp_list:
                if item:
                    sensitive_words_list.append(item.replace(' ', ''))
            task_detail["sensitive_words"] = json.dumps(sensitive_words_list)
        else:
            task_detail["sensitive_words"] = json.dumps([])
        if not sensitive_words_list and keywords_list:
            return json.dumps(['-1'])
        now_ts = int(time.time())
        task_detail["create_at"] = create_time  # now_ts
        task_detail["warning_status"] = '0'
        task_detail["finish"] = "0"  # not end the task
        task_detail["history_status"] = json.dumps(
            [])  # ts, keywords, warning_status
        task_detail['burst_reason'] = ''
        task_detail['processing_status'] = "1"  #任务正在进行
        if keywords:
            if social_sensors:
                task_detail["task_type"] = "3"
            else:
                task_detail["task_type"] = "2"
        else:
            if social_sensors:
                task_detail["task_type"] = "1"
            else:
                task_detail["task_type"] = "0"

    # store task detail into es
    es.index(index=index_manage_sensing_task,
             doc_type=task_doc_type,
             id=task_name,
             body=task_detail)

    return json.dumps(["1"])