Premiere version : mise en route du suivi.
[auf_roundup.git] / tools / .svn / text-base / load_tracker.py.svn-base
CommitLineData
c638d827
CR
1#! /usr/bin/env python
2# $Id: load_tracker.py,v 1.6 2005-06-08 02:24:06 anthonybaxter Exp $
3
4'''
5Usage: %s <tracker home> <N>
6
7Load up the indicated tracker with N issues and N/100 users.
8'''
9
10import sys, os, random
11from roundup import instance
12
13# open the instance
14if len(sys.argv) < 2:
15 print "Error: Not enough arguments"
16 print __doc__.strip()%(sys.argv[0])
17 sys.exit(1)
18tracker_home = sys.argv[1]
19N = int(sys.argv[2])
20
21# open the tracker
22tracker = instance.open(tracker_home)
23db = tracker.open('admin')
24
25priorities = db.priority.list()
26statuses = db.status.list()
27resolved_id = db.status.lookup('resolved')
28statuses.remove(resolved_id)
29
30names = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta',
31'theta', 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', 'omicron', 'pi',
32'rho']
33
34titles = '''Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
35Duis nibh purus, bibendum sed, condimentum ut, bibendum ut, risus.
36Fusce pede enim, nonummy sit amet, dapibus a, blandit eget, metus.
37Nulla risus.
38Vivamus tincidunt.
39Donec consequat convallis quam.
40Sed convallis vehicula felis.
41Aliquam laoreet, dui quis pharetra vehicula, magna justo.
42Euismod felis, eu adipiscing eros metus id tortor.
43Suspendisse et turpis.
44Aenean non felis.
45Nam egestas eros.
46Integer tellus quam, mattis ac, vestibulum sed, egestas quis, mauris.
47Nulla tincidunt diam sit amet dui.
48Nam odio mauris, dignissim vitae, eleifend eu, consectetuer id, risus.
49Suspendisse potenti.
50Donec tincidunt.
51Vestibulum gravida.
52Fusce luctus, neque id mattis fringilla, purus pede sodales pede.
53Quis ultricies urna odio sed orci.'''.splitlines()
54
55try:
56 try:
57 db.user.lookup('alpha0')
58 except:
59 # add some users
60 M = N/100
61 for i in range(M):
62 print '\ruser', i, ' ',
63 sys.stdout.flush()
64 if i/17 == 0:
65 db.user.create(username=names[i%17])
66 else:
67 db.user.create(username=names[i%17]+str(i/17))
68
69 # assignable user list
70 users = db.user.list()
71 users.remove(db.user.lookup('anonymous'))
72 print
73
74 # now create the issues
75 for i in range(N):
76 print '\rissue', i, ' ',
77 sys.stdout.flush()
78 # in practise, about 90% of issues are resolved
79 if random.random() > .9:
80 status = random.choice(statuses)
81 else:
82 status = resolved_id
83 db.issue.create(
84 title=random.choice(titles),
85 priority=random.choice(priorities),
86 status=status,
87 assignedto=random.choice(users))
88 if not i%1000:
89 db.commit()
90 print
91
92 db.commit()
93finally:
94 db.close()
95
96# vim: set filetype=python ts=4 sw=4 et si