Dependency https github com JetBrains youtrack-rest-python -library us

 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
# Dependency: https://github.com/JetBrains/youtrack-rest-python-library
# usage:
# C:\youtrack-rest-python-library-master\python> c:\Python27\python .\my-time.py pkudinov "PASSWORD"
from youtrack.connection import Connection
from datetime import datetime
from datetime import timedelta
import itertools
import sys
me = sys.argv[1]
passw = sys.argv[2]
def getDate(wi):
return datetime.fromtimestamp(int(wi.date)/1000)
def isToday(d):
return d.strftime("%y-%m-%d") == datetime.today().strftime("%y-%m-%d")
connection = Connection(
'http://youtrack.crossmarket.across.lan',
'acrosssys\\{me}'.format(me=me),
passw)
iss = connection.getIssues('MKT', 'for #me updated: Today', 0, 99999)
issues = [{'date': getDate(wi), 'user': wi.authorLogin, 'duration': wi.duration}
for wi in itertools.chain(*[connection.getWorkItems(i.id) for i in iss])]
by_me_today = [i for i in issues if isToday(i['date']) and i['user'] == me]
total_minutes = sum([int(i['duration']) for i in by_me_today])
d = timedelta(minutes=total_minutes)
print(d)