Welcome to Bugsy!

Bugsy is a tool that allows you to programmatically work with Bugzilla using its native REST API.

To use you will do

import bugsy
bugzilla = bugsy.Bugsy()
bug = bugzilla.get(123456)
bug123456.status = 'RESOLVED'
bug123456.resolution = 'FIXED'
bugzilla.put(bug123456)

Installing Bugsy

To install Bugsy, simply use pip or easy install

Pip

pip install bugsy

easy_install

easy_install bugsy

Using Bugsy

Getting a bug from Bugzilla

Getting a bug is quite simple. Create a Bugsy object and then get the bug number that you want.

import bugsy
bugzilla = bugsy.Bugsy()
bug = bugzilla.get(123456)

Creating a new bug

To create a new bug, create a Bug object, populate it with the items that you need and then use the Bugsy object to put the bug into Bugzilla

import bugsy
bug = bugsy.Bug()
bug.summary = "I really realy love cheese"
bug.add_comment("and I really want sausages with it!")

bugzilla = bugsy.Bugsy("username", "password")
bugzilla.put(bug)
bug.id #returns the bug id from Bugzilla

Searching Bugzilla

To search for bugs you will need to create a Bugsy object and then you can call search_for and chain the search. The Search API is a Fluent API o you just chain the items that you need and then call search when the search is complete.

import bugsy
bugzilla = bugsy.Bugsy()
bugs = bugzilla.search_for\
                .keywords("checkin-needed")\
                .include_fields("flags")\
                .search()

More details can be found in from the Search class

To see further details look at:

Bugsy

class bugsy.Bugsy(username=None, password=None, bugzilla_url='https://bugzilla.mozilla.org/rest')

Bugsy allows easy getting and putting of Bugzilla bugs

get(bug_number)

Get a bug from Bugzilla. If there is a login token created during object initialisation it will be part of the query string passed to Bugzilla

Parameters:bug_number – Bug Number that will be searched. If found will return a Bug object.
>>> bugzilla = Bugsy()
>>> bug = bugzilla.get(123456)
put(bug)

This method allows you to create or update a bug on Bugzilla. You will have had to pass in a valid username and password to the object initialisation and recieved back a token.

Parameters:bug – A Bug object either created by hand or by using get()

If there is no valid token then a BugsyException will be raised. If the object passed in is not a Bug then a BugsyException will be raised.

>>> bugzilla = Bugsy()
>>> bug = bugzilla.get(123456)
>>> bug.summary = "I like cheese and sausages"
>>> bugzilla.put(bug)
request(path, method='GET', **kwargs)

Perform a HTTP request.

Given a relative Bugzilla URL path, an optional request method, and arguments suitable for requests.Request(), perform a HTTP request.

class bugsy.BugsyException(msg)

If while interacting with Bugzilla and we try do something that is not supported this error will be raised.

class bugsy.LoginException(msg)

If a username and password are passed in but we don’t receive a token then this error will be raised.

Bug

class bugsy.Bug(bugsy=None, **kwargs)

This represents a Bugzilla Bug

OS

Property for getting or setting the OS that the bug occured on

>>> bug.OS
"All"
add_comment(comment)

Adds a comment to a bug. If a bug does not have a bug ID then you need call put on the Bugsy class.

>>> bug.add_comment("I like sausages")
>>> bugzilla.put(bug)

If it does have a bug id then this will do a post to the server

>>> bug.add_comment("I like eggs too")
component

Property for getting the bug component

>>> bug.component
General
get_comments()

Obtain comments for this bug.

Returns a list of Comment instances.

id

Property for getting the ID of a bug.

>>> bug.id
123456
platform

Property for getting the bug platform

>>> bug.platform
"ARM"
product

Property for getting the bug product

>>> bug.product
Core
resolution

Property for getting or setting the bug resolution

>>> bug.resolution
"FIXED"
status

Property for getting or setting the bug status

>>> bug.status
"REOPENED"
summary

Property for getting and setting the bug summary

>>> bug.summary
"I like cheese"
to_dict()

Return the raw dict that is used inside this object

update()

Update this object with the latest changes from Bugzilla

>>> bug.status
'NEW'
#Changes happen on Bugzilla
>>> bug.update()
>>> bug.status
'FIXED'
version

Property for getting the bug platform

>>> bug.version
"TRUNK"
class bugsy.BugException(msg)

If we try do something that is not allowed to a bug then this error is raised

Indices and tables