コード例 #1
0
ファイル: type.py プロジェクト: fnmdx111/LogParserPrototype
    def jsonify(self):
        from_log = from_(self.time_slices)

        d = map(lambda (k, v): (k.split('!'), v),
                {r_flag: from_log(get_request_count_per_t_slice_of(r_flag))
                 for r_flag in req_flag[1:]}.iteritems())
        d_prime = defaultdict(dict)
        for (main, sub), v in d:
            d_prime[main][sub] = v
        for main in d_prime:
            stub = {sub: sum(d_prime[main][sub])
                    for sub in d_prime[main]}
            d_prime[main]['overview'] = [stub.keys(), map(lambda i: [i], stub.values())]

        d_prime.update({
            'time_slice_names': from_log(get_name),
            'client': from_log(get_request_count_per_t_slice_of('client'))
        })

        req_names = ['line', 'news', 'param', 'stop', 'stop2stop']
        d_prime.update({
            'total': {
                'perhour': from_log(get_count),
                'overview': [['client'] + req_names,
                             map(lambda i: [i],
                                 [sum(d_prime['client'])] +
                                  map(lambda name: sum(map(lambda (i,): i,
                                                           d_prime[name]['overview'][1])),
                                      req_names))]
            }
        })

        print d_prime

        return jsonify(d_prime)
コード例 #2
0
def get_weekly_data():
    logs = log_adapter.get_multiple_logs()
    from_logs = from_(logs)

    d_prime = defaultdict(dict)

    for (main, sub), req_flag in map(lambda req_flag: (req_flag.split('!'), req_flag),
                                     t.req_flag[1:]):
        d_prime[main][sub] = from_logs(get_request_count_of(req_flag))

    for main in t.req_main_flag:
        d_prime[main]['overview'] = get_overview(d_prime[main])

    d_prime.update({
        'total_requests_per_day': from_logs(get_count),
        'ticks': from_logs(get_date),
        'client': from_logs(get_request_count_of('client'))
    })

    print d_prime

    return jsonify(d_prime)