"Fossies" - the Fresh Open Source Software Archive

Member "roundup-2.0.0/tools/load_tracker.py" (26 Aug 2019, 2735 Bytes) of package /linux/www/roundup-2.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "load_tracker.py": 1.6.1_vs_2.0.0.

    1 #! /usr/bin/env python
    2 '''
    3 Usage: %s <tracker home> <N>
    4 
    5 Load up the indicated tracker with N issues and N/100 users.
    6 '''
    7 
    8 from __future__ import print_function
    9 import sys, os, random
   10 from roundup import instance
   11 
   12 # open the instance
   13 if len(sys.argv) < 2:
   14     print("Error: Not enough arguments")
   15     print(__doc__.strip()%(sys.argv[0]))
   16     sys.exit(1)
   17 tracker_home = sys.argv[1]
   18 N = int(sys.argv[2])
   19 
   20 # open the tracker
   21 tracker = instance.open(tracker_home)
   22 db = tracker.open('admin')
   23 db.tx_Source = "cli"
   24 
   25 priorities = db.priority.list()
   26 statuses = db.status.list()
   27 resolved_id = db.status.lookup('resolved')
   28 statuses.remove(resolved_id)
   29 
   30 names = ['alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 
   31 'theta', 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', 'omicron', 'pi',
   32 'rho']
   33 
   34 titles = '''Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
   35 Duis nibh purus, bibendum sed, condimentum ut, bibendum ut, risus.
   36 Fusce pede enim, nonummy sit amet, dapibus a, blandit eget, metus.
   37 Nulla risus.
   38 Vivamus tincidunt.
   39 Donec consequat convallis quam.
   40 Sed convallis vehicula felis.
   41 Aliquam laoreet, dui quis pharetra vehicula, magna justo.
   42 Euismod felis, eu adipiscing eros metus id tortor.
   43 Suspendisse et turpis.
   44 Aenean non felis.
   45 Nam egestas eros.
   46 Integer tellus quam, mattis ac, vestibulum sed, egestas quis, mauris.
   47 Nulla tincidunt diam sit amet dui.
   48 Nam odio mauris, dignissim vitae, eleifend eu, consectetuer id, risus.
   49 Suspendisse potenti.
   50 Donec tincidunt.
   51 Vestibulum gravida.
   52 Fusce luctus, neque id mattis fringilla, purus pede sodales pede.
   53 Quis ultricies urna odio sed orci.'''.splitlines()
   54 
   55 try:
   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, '       ', end=' ')
   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, '       ', end=' ')
   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()
   93 finally:
   94     db.close()
   95 
   96 # vim: set filetype=python ts=4 sw=4 et si