Exemple #1
0
    query_body = {"query": {"match_all": {}}}

    search_results = es.search(index=index_manage_sensing,
                               doc_type=type_manage_sensing,
                               body=query_body)['hits']['hits']

    count = 0
    if search_results:
        for iter_item in search_results:
            _id = iter_item['_id']
            item = iter_item['_source']

            task = []
            task.append(item['task_name'])  # task_name
            try:
                task.append(json.loads(
                    item['social_sensors']))  # social sensors
            except:
                task.append(item['social_sensors'])  # social sensors
            task.append(now_ts)

            r.lpush("task_name", json.dumps(task))
            count += 1

    print 'task_count_sum:', count


if __name__ == "__main__":
    create_task_list()
    social_sensing_task()
            task.append(ts)
            r.lpush('task_name', json.dumps(task))
            count += 1

    print count
    now_ts = str(int(time.time()))
    print_log = "&".join([file_path, "end", now_ts])
    print print_log


if __name__ == "__main__":

    ts2 = datetime2ts("2013-09-08")
    #ts1 = datetime2ts("2013-09-01")
    ts1 = 1377984600
    ts = ts1 + time_interval
    while 1:
        if ts <= ts2:
            print ts
            create_task_list(ts)
            social_sensing_task(ts)
            ts += time_interval
        else:
            break
    """

    ts = time.time()
    create_task_list(ts)
    social_sensing_task(ts)
    """
                }
            }
        }
    }

    search_results = es.search(index=index_name, doc_type=task_doc_type, body=query_body)['hits']['hits']

    count = 0
    if search_results:
        for iter_item in search_results:
            _id = iter_item['_id']
            item = iter_item['_source']
            task = []
            task.append(item['task_name']) # task_name
            task.append(item['keywords']) # keywords
            task.append(item['stop_time']) # stop time
            task.append(item['create_by'])
            task.append(now_ts)
            r.lpush('task_name', json.dumps(task))
            count += 1

    print count
    print_log = "&".join([file_path, "end", ts2date(time.time())])
    print print_log


if __name__ == "__main__":
    create_task_list()
    social_sensing_task()

            r.lpush('task_name', json.dumps(task))
            count += 1

    print count
    now_ts = str(int(time.time()))
    print_log = "&".join([file_path, "end", now_ts])
    print print_log


if __name__ == "__main__":

    ts2 = datetime2ts("2013-09-08")
    ts1 = datetime2ts("2013-09-01")
    #ts1 = 1377984600
    ts = ts1 + time_interval
    while 1:
        if ts <= ts2:
            print ts
            create_task_list(ts)
            social_sensing_task(ts)
            ts += time_interval
        else:
            break

    """

    ts = time.time()
    create_task_list(ts)
    social_sensing_task(ts)
    """