2 # $Id: add-issue,v 1.2 2003-04-30 01:28:37 richard Exp $
5 Usage: %s <tracker home> <priority> <issue title>
7 Create a new issue in the given tracker. Input is taken from STDIN to
8 create the initial issue message (which may be empty). Issues will be
9 created as the current user (%s) if they exist as a Roundup
10 user, or "admin" otherwise.
15 from roundup import instance, mailgw, date
18 username = pwd.getpwuid(os.getuid())[0]
20 print "Error: Not enough arguments"
21 print __doc__.strip()%(sys.argv[0], username)
23 tracker_home = sys.argv[1]
24 issue_priority = sys.argv[2]
25 issue_title = ' '.join(sys.argv[3:])
27 # get the message, if any
28 message_text = sys.stdin.read().strip()
31 tracker = instance.open(tracker_home)
32 db = tracker.open('admin')
33 uid = db.user.lookup('admin')
35 # try to open the tracker as the current user
36 uid = db.user.lookup(username)
38 db = tracker.open(username)
47 summary, x = mailgw.parseContent(message_text, 0, 0)
48 msg = db.msg.create(content=message_text, summary=summary, author=uid,
52 # now create the issue
53 db.issue.create(title=issue_title, priority=issue_priority,
60 # vim: set filetype=python ts=4 sw=4 et si