+branch/~mbp/+junk/repro-742217

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
#! /usr/bin/python

# Attempted reproduction for <http://pad.lv/742217>

import httplib2
httplib2.debug = 1

from datetime import datetime, timedelta
from launchpadlib.launchpad import Launchpad
import time
import sys
import os

if len(sys.argv) != 2:
    print "usage: %s PERSON_ID" % sys.argv[0]

print 'login'
lp = Launchpad.login_anonymously('reproduce bug 742217',
    service_root='https://api.launchpad.net/')

print 'starting'
person = lp.people[sys.argv[1]]
print 'got %s' % person

LIVE_STATUSES = ["New", "Incomplete", "Expired", "Confirmed", "Triaged",
                 "In Progress", "Fix Committed"]
TERMINAL_STATUSES = ["Fix Released"]

RELEVANT_STATUSES = LIVE_STATUSES + TERMINAL_STATUSES

CLOSED_BUG_RELEVANCE = 30


out = os.fdopen(1, 'w', 0)


def time_get_bugs(what, **params):
    out.write('get bugs %s: ' % what)
    start = time.time()
    coll = person.searchTasks(**params)
    for b in coll:
        out.write('%s ' % b.bug_link.split('/')[-1])
    out.write('\n    %.3fs\n' % (time.time() - start))


time_get_bugs('all assigned', 
    status=RELEVANT_STATUSES,
    assignee=person)


time_get_bugs('live assigned', 
    status=LIVE_STATUSES,
    assignee=person)

cutoff = datetime.now() - timedelta(days=CLOSED_BUG_RELEVANCE)
time_get_bugs('terminal recently-closed assigned', 
    status=TERMINAL_STATUSES,
    assignee=person,
    modified_since=cutoff)