summaryrefslogtreecommitdiff
path: root/job-times
blob: 7cd4b3599d1364f698c03445cf1253b6ccbc71f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/python

import cliapp
import time

class ListJobTimes(cliapp.Application):

    def process_input_line(self, filename, line):
        words = line.split()
        if len(words) < 6 or words[2] != 'INFO':
            pass
        elif words[3] == 'Starting' and words[4] == 'job':
            self.started = self.parse_time(words[0], words[1])
            self.jobid = words[5]
        elif words[3] == 'Finished' and words[4] == 'job':
            ended = self.parse_time(words[0], words[1])
            self.output.write('%.1f %s\n' % (ended - self.started, self.jobid))
            self.started = None
            self.jobid = None

    def parse_time(self, dt, tm):
        t = time.strptime('%s %s' % (dt, tm), '%Y-%m-%d %H:%M:%S')
        return time.mktime(t)

ListJobTimes().run()