-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimeline
More file actions
executable file
·44 lines (36 loc) · 1.31 KB
/
Copy pathtimeline
File metadata and controls
executable file
·44 lines (36 loc) · 1.31 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from datetime import datetime, timedelta
from time import sleep
from xmlrpc.client import ServerProxy, Binary, DateTime
import sys
import trackit
import time
def main():
try:
config = trackit.Config("~/.tracrc")
except:
sys.exit(trackit.noconfig_msg())
p = ServerProxy(config.login)
interval = 10 if len(sys.argv) <= 1 else int(sys.argv[1])
since = None
while True:
now = datetime.now()
if since == None:
since = now - timedelta(minutes=interval)
changes = []
for change in p.ticket.getRecentChanges(DateTime(since + timedelta(seconds=time.timezone))):
try:
(_, _, changed, attribute) = p.ticket.get(change)
(_, author) = p.ticket.changeLog(change)[-1][:2]
changed = datetime.strptime(changed.value, "%Y%m%dT%H:%M:%S") - timedelta(seconds=time.timezone)
changes.append((changed.strftime("%Y-%m-%d %H:%M:%S"), change, author, attribute["summary"]))
except:
pass
changes = sorted(changes, key=lambda x: x[0])
for _ in changes:
print("{} {} \033[0;33m{} \033[0;32m{}\033[0m".format(*_))
since = now
sleep(interval*60)
if __name__ == "__main__":
main()