"Fossies" - the Fresh Open Source Software Archive

Member "roundup-2.0.0/scripts/add-issue" (26 Aug 2019, 1533 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 "add-issue": 1.6.1_vs_2.0.0.

    1 #! /usr/bin/env python
    2 '''
    3 Usage: %s <tracker home> <priority> <issue title>
    4 
    5 Create a new issue in the given tracker. Input is taken from STDIN to
    6 create the initial issue message (which may be empty). Issues will be
    7 created as the current user (%s) if they exist as a Roundup
    8 user, or "admin" otherwise.
    9 '''
   10 
   11 from __future__ import print_function
   12 import sys, os, pwd
   13 
   14 from roundup import instance, mailgw, date
   15 
   16 # open the instance
   17 username = pwd.getpwuid(os.getuid())[0]
   18 if len(sys.argv) < 3:
   19     print("Error: Not enough arguments")
   20     print(__doc__.strip()%(sys.argv[0], username))
   21     sys.exit(1)
   22 tracker_home = sys.argv[1]
   23 issue_priority = sys.argv[2]
   24 issue_title = ' '.join(sys.argv[3:])
   25 
   26 # get the message, if any
   27 message_text = sys.stdin.read().strip()
   28 
   29 # open the tracker
   30 tracker = instance.open(tracker_home)
   31 db = tracker.open('admin')
   32 db.tx_Source = "cli"
   33 uid = db.user.lookup('admin')
   34 try:
   35     # try to open the tracker as the current user
   36     uid = db.user.lookup(username)
   37     db.close()
   38     db = tracker.open(username)
   39 except KeyError:
   40     pass
   41 
   42 try:
   43 
   44     # handle the message
   45     messages = []
   46     if message_text:
   47         summary, x = mailgw.parseContent(message_text, 0, 0)
   48         msg = db.msg.create(content=message_text, summary=summary, author=uid,
   49             date=date.Date())
   50         messages = [msg]
   51 
   52     # now create the issue
   53     db.issue.create(title=issue_title, priority=issue_priority,
   54         messages=messages)
   55 
   56     db.commit()
   57 finally:
   58     db.close()
   59 
   60 # vim: set filetype=python ts=4 sw=4 et si