File Bugs via a Script

Every once in a while it is necessary to file a series of bugs against several packages, preferably from the command line. To do so, there are two approaches for now: one via curl and another one via python which calls into the official Mantis SOAP API. While both approaches are a bit rough around the edges, the latter one looks like a promising candidate for building OpenCSW tools and services.

Filing a bug via curl

The following steps exemplify how curl can be used to file a bug against a package from the command line.

Authenticate to Mantis (stores a session cookie)

curl -s -c mantis.cookies -d 'username=<username>;&password=<password>;'  http://www.opencsw.org/bugtrack/login.php > /dev/null

Select the relevant project/package (project ID can be retrieved from http://opencsw.org/packages/yourpackage)

curl -s -b mantis.cookies -c mantis.cookies -d "project_id=<project_id>" http://www.opencsw.org/bugtrack/set_project.php > /dev/null

File a bug The resulting bug looks like this one.

curl -s -b mantis.cookies -c mantis.cookies \
    -F "m_id=0" \
    -F "project_id=<project_id>" \
    -F "handler_id=0" \
    -F "category=packaging" \
    -F "reproducibility=10" \
    -F "severity=50" \
    -F "summary=Depend on CSWggettextrt" \
    -F "description=Rutime for gettext is now in CSWggettextrt, please update dependencies from CSWgettext to CSWgettextrt" \
    -F "max_file_size=5000000" \
    -F "view_state=10" \
    http://www.opencsw.org/bugtrack/bug_report.php > /dev/null

The numeric levels above translate to the following strings

  • Priority: 10:none,20:low,30:normal,40:high,50:urgent,60:immediate
  • Severity: 10:feature,20:trivial,30:text,40:tweak,50:minor,60:major,70:crash,80:block
  • Reproducability: 10:always,30:sometimes,50:random,70:have not tried,90:unable to duplicate,100:N/A
  • View State: 10:public,50:private
  • Status: 10:new,20:feedback,30:acknowledged,40:confirmed,50:assigned,80:resolved,90:closed
  • Resolution: 10:open,20:fixed,30:reopened,40:unable to duplicate,50:not fixable,60:duplicate,70:not a bug,80:suspended,90:wont fix

For a full reference please see the section "Mantis Enum Strings" in config_defaults.inc.php

Filing a bug via the Mantis SOAP service and python + suds

The following example python snippet uses the suds library to file a bug using the Mantis SOAP API. suds is easy to use in general and is pretty straight-forward when it comes to complex data types in SOAP (in comparison both, SOAPpy and ZSI are a royal PITA). suds is available as a OpenCSW package.

from suds.client import Client
client = Client('http://www.opencsw.org/mantis/api/soap/mantisconnect.php?wsdl')

issue = client.factory.create('IssueData')
issue.project.name = "httping"
issue.project.id = 0 # Mantis will try to evaluate it, chokes if unset
issue.summary = "Testing CLI bug submission"
issue.description = "Testing CLI bug submission"
issue.category = "other"
issue.reproducibility.name = "N/A"
issue.severity.name = "minor"
issue.priority.name = "normal"
issue.view_state.name = "public"
issue.resolution.name = "open"
issue.projection.name = "none"
issue.eta.name = "none"
issue.status.name = "new"

client.service.mc_issue_add('<username>','<password>',issue)

Quite a bit of information from the issue above shouldn't be needed for an initial bug report (resolution, projection, eta, status), yet it is required due to Mantis bug #9132 mc_issue_add does not set values for all submitted fields which is only fixed in the 1.2.x branch.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License