Revision 3d8e3339 log_parser.py

View differences:

log_parser.py
17 17

  
18 18

  
19 19
args = None
20

  
20
resolution = 1
21 21

  
22 22
def print_in_columns(data, width=15, separator=','):
23 23
    print(separator.join([str(d).ljust(width) for d in data]))
......
25 25

  
26 26
def to_unixtime(t):
27 27
    """ note that this does not work if all timestamps are not from the same time zone """
28
    return int((t - datetime.datetime(1970, 1, 1)).total_seconds())
28
    return int((t - datetime.datetime(1970, 1, 1)).total_seconds()*resolution)
29 29

  
30 30

  
31 31
def parse_args():
32
    global args
33
    global resolution
32 34
    parser = argparse.ArgumentParser()
33 35
    parser.add_argument('-f', help='the log file', required=True, nargs='*')
34 36
    parser.add_argument('-v', help='be more verbose', default=False,
......
37 39
                        action='store_true')
38 40
    parser.add_argument('-t', help='compute the number of updates generated',
39 41
                        default=False, action='store_true')
40
    global args
42
    parser.add_argument('-T', help='time resolution (s/decimal/cent/milli)',
43
                        default='SEC',
44
                        choices=['SECS', 'DSEC', 'CSEC', 'MSEC'])
41 45
    args = parser.parse_args()
46
    if args.T == 'DSEC':
47
        resolution = 10
48
    elif args.T == 'CSEC':
49
        resolution = 100
50
    elif args.T == 'MSEC':
51
        resolution = 1000
42 52

  
43 53

  
44 54
def parse_line(line, verb):

Also available in: Unified diff