-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
102 lines (85 loc) · 2.49 KB
/
app.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
import requests
import json
from schematics.models import Model
from schematics.types import StringType, URLType,IntType,BooleanType
from schematics.types.compound import MultiType, ModelType
from schematics.types.serializable import serializable
class Id(Model):
id = IntType()
class Task(Model):
id = IntType()
backlog = MultiType(ModelType(Id))
blocked = BooleanType()
color = StringType()
creationDate = StringType()
creator = MultiType(ModelType(Id))
description = StringType()
doneDate = StringType()
estimation = IntType()
inProgressDate = StringType()
initial = IntType()
lastUpdated = StringType()
name = StringType()
notes = StringType()
parentStory = MultiType(ModelType(Id))
participants = MultiType(ModelType(Id))
rank = IntType()
responsible = MultiType(ModelType(Id))
state = IntType()
type = StringType()
uid = IntType()
tags = MultiType(ModelType(Id))
comments = MultiType(ModelType(Id))
@serializable
def getState(self):
if self.state == 0:
return "Task"
elif self.state == 1:
return "in Progress"
else:
return "Done"
@serializable
def getUser(self):
if task.responsible != None:
id = task.responsible['id']
if id == 102:
return "user 102"
elif id == 106:
return "user 106"
elif id == 107:
return "user 107"
else:
return None
def restRequest(type):
headers = {'Accept': 'application/json','Content-Type': 'application/json; charset=UTF-8'}
uri = 'http://:server/ws/p/:pkey/'
r = requests.get(uri+type,headers=headers,auth=('user', 'password'))
return json.loads(unicode(r.text.encode('utf-8'), errors='ignore'))
obj = restRequest('task')
Tasks = []
for o in obj:
task = Task(o)
Tasks.append(task)
sSum = 0
n = 0
done_sSum_tim = 0
done_sSum_task = 0
for task in Tasks:
sSum += 1
if task.estimation != None:
n += task.estimation
if task.state == 2 :
done_sSum_tim += task.estimation
done_sSum_task += 1
print "Task : " ,sSum
print "Sum Tim : ", n
print "------------------------------------------------------"
print "Done Task : " ,done_sSum_task
print "Done Sum Tim : ", done_sSum_tim
print "------------------------------------------------------"
for task in Tasks:
if task.initial != None or task.estimation!= None:
if task.getUser != None:
print task.getUser,"-->", task.getState,"-> ", task.name, "-> initial:",task.initial ,"estimation:", task.estimation