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

« back to all changes in this revision

Viewing changes to repro-742217.py

  • Committer: Martin Pool
  • Date: 2011-03-25 04:24:15 UTC
  • Revision ID: mbp@canonical.com-20110325042415-84sdz3717u62xern
Try to reproduce bug 742217

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/python
 
2
 
 
3
# Attempted reproduction for <http://pad.lv/742217>
 
4
 
 
5
import httplib2
 
6
httplib2.debug = 1
 
7
 
 
8
from datetime import datetime, timedelta
 
9
from launchpadlib.launchpad import Launchpad
 
10
import time
 
11
import sys
 
12
import os
 
13
 
 
14
if len(sys.argv) != 2:
 
15
    print "usage: %s PERSON_ID" % sys.argv[0]
 
16
 
 
17
print 'login'
 
18
lp = Launchpad.login_anonymously('reproduce bug 742217',
 
19
    service_root='https://api.launchpad.net/')
 
20
 
 
21
print 'starting'
 
22
person = lp.people[sys.argv[1]]
 
23
print 'got %s' % person
 
24
 
 
25
LIVE_STATUSES = ["New", "Incomplete", "Expired", "Confirmed", "Triaged",
 
26
                 "In Progress", "Fix Committed"]
 
27
TERMINAL_STATUSES = ["Fix Released"]
 
28
 
 
29
RELEVANT_STATUSES = LIVE_STATUSES + TERMINAL_STATUSES
 
30
 
 
31
CLOSED_BUG_RELEVANCE = 30
 
32
 
 
33
 
 
34
out = os.fdopen(1, 'w', 0)
 
35
 
 
36
 
 
37
def time_get_bugs(what, **params):
 
38
    out.write('get bugs %s: ' % what)
 
39
    start = time.time()
 
40
    coll = person.searchTasks(**params)
 
41
    for b in coll:
 
42
        out.write('%s ' % b.bug_link.split('/')[-1])
 
43
    out.write('\n    %.3fs\n' % (time.time() - start))
 
44
 
 
45
 
 
46
time_get_bugs('all assigned', 
 
47
    status=RELEVANT_STATUSES,
 
48
    assignee=person)
 
49
 
 
50
 
 
51
time_get_bugs('live assigned', 
 
52
    status=LIVE_STATUSES,
 
53
    assignee=person)
 
54
 
 
55
cutoff = datetime.now() - timedelta(days=CLOSED_BUG_RELEVANCE)
 
56
time_get_bugs('terminal recently-closed assigned', 
 
57
    status=TERMINAL_STATUSES,
 
58
    assignee=person,
 
59
    modified_since=cutoff)
 
60