Subversion Repositories Scribus

Compare Revisions

No changes between revisions

Ignore whitespace Rev 12491 → Rev 12493

/tools/mantisctl/mantisctl.py/mantis.py
18,6 → 18,14
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###
# Changelog:
# Version:
# 0.1: Initial release - bug reporting to Mantis is working.
# 0.2:
# - Added a confirmation message and an option to override it.
# - Fixed a bug in the option parsing method that would not correctly
# return options when script is run with no arguments.
###
 
import re, sys
import mechanize
58,6 → 66,18
(self.opts, self.args) = self._getopts()
assert self._checkbts()
 
def _askconfirm(self):
print "\nYou will submit a bug report with the following data:\n"
self._printdata()
yes = ['y', 'Y']
var = raw_input("Press 'y' to submit the report or any other key to abort and hit ENTER: ")
print var
if var in yes:
print "Submitting your bug report..."
else:
print "Exiting without submitting the report..."
sys.exit(0)
 
def _checkbts(self):
""" Checks if the URL for the front page could be opened."""
try:
72,9 → 92,9
sys.exit(1)
 
def _usage(self):
print 50*"#"
print "\n", 78*"#"
print """\n
Usage: mantisctl.py [Options], version = mantisctl.py 0.1
Usage: mantisctl.py [Options], version = mantisctl.py 0.2
 
Options:
--version show program's version number and exit
82,6 → 102,7
-T, --test Test the script
-L, --list List the Mantis options
-r, --report Report a new bug
-n, --noconfirm Do not ask for confirmation before submitting a report
-u USERNAME, --username=USERNAME
User name [optional if you set it in the script
itself]. [default: None]
107,8 → 128,8
 
def _getopts(self):
from optparse import OptionParser
"""This procedure parses options and arguments passed to the program and
stores them in a dictionary (opts) and a list (args)"""
"""This procedure parses options and arguments passed to the program
and stores them in a dictionary (opts) and a list (args)"""
try:
self.title = title
except:
125,11 → 146,12
self.password = password
except:
self.password = "None"
usage = "%prog [Options], version = %prog 0.1"
op = OptionParser(usage=usage, version='%prog 0.1')
usage = "%prog [Options], version = %prog 0.2"
op = OptionParser(usage=usage, version='%prog 0.2')
op.add_option("-T", "--test", action="store_true", dest="test", default=False, help="Test the script")
op.add_option("-L", "--list", action="store_true", dest="list", default=False, help="List the Mantis options")
op.add_option("-r", "--report", action="store_true", dest="report", default=False, help="Report a new bug")
op.add_option("-n", "--noconfirm", action="store_true", dest="noconfirm", default=False, help="Do not ask for confirmation before submitting a report")
op.add_option("-u", "--username", dest="username", default=self.username, help="User name [optional if you set it in the script itself]. [default: %default]")
op.add_option("-w", "--password", dest="password", default=self.password, help="User password [optional if you set it in the script itself]. [default: %default]")
op.add_option("-a", "--assignto", dest="assignto", help="Assign to [optional]")
139,11 → 161,7
op.add_option("-d", "--desc", dest="description", help="Bug description [optional]")
op.add_option("-p", "--product", dest="pversion", help="Product version <mandatory>")
op.add_option("-t", "--target", dest="tversion", help="Target version [optional]")
try:
(opts, args) = op.parse_args()
except:
self._usage()
return (opts, args)
return op.parse_args()
 
def _printcookies(self):
for i in self.cj:
282,8 → 300,19
self.br.select_form(name="report_bug_form")
self._setupreportform()
 
def _printdata(self):
print "\tCategory: \t\t%s" % self.opts.category
print "\tSeverity: \t\t%s" % self.opts.severity
print "\tAssigned To: \t\t%s" % self.opts.assignto
print "\tProduct Version: \t%s" % self.opts.pversion
print "\tTarget Version: \t%s" % self.opts.tversion
print "\tSummary: \t\t%s" % self.opts.summary
print "\tDescription: \t\t%s" % self.opts.description
 
def doreportbug(self):
self.reportbug()
if not self.opts.noconfirm:
self._askconfirm()
try:
self.br.submit()
except:
290,13 → 319,7
pass
self.br.close()
print "\nBug report submission appears to be successful! The following data have been submitted:\n"
print "\tCategory: \t\t%s" % self.opts.category
print "\tSeverity: \t\t%s" % self.opts.severity
print "\tAssigned To: \t\t%s" % self.opts.assignto
print "\tProduct Version: \t%s" % self.opts.pversion
print "\tTarget Version: \t%s" % self.opts.tversion
print "\tSummary: \t\t%s" % self.opts.summary
print "\tDescription: \t\t%s" % self.opts.description
self._printdata()
sys.exit(0)
 
def _checkcredentials(self):
325,6 → 348,7
if __name__=='__main__':
if len(sys.argv) == 1:
sys.argv.append("--help")
browser = Mantisctl()
else:
browser = Mantisctl()
browser.dorun()
Property changes:
Added: svn:mergeinfo