Python library and command line tool for interacting with Bugzilla

Overview

CI codecov PyPI

python-bugzilla

This package provides two bits:

  • bugzilla python module for talking to a Bugzilla instance over XMLRPC or REST
  • /usr/bin/bugzilla command line tool for performing actions from the command line: create or edit bugs, various queries, etc.

This was originally written specifically for Red Hat's Bugzilla instance and is used heavily at Red Hat and in Fedora, but it should be generically useful.

You can find some code examples in the examples directory.

For questions about submitting patches, see CONTRIBUTING.md

Comments
  • Use a more portable LICENSE?

    Use a more portable LICENSE?

    Any hope of getting this on a permissive license?

    I can't use this on github.com/tony/patches, as I'm hoping to be able to use it to grab bugzilla issues/attachments, GPL isn't backward compatible with MIT (only forwards).

    Looks like you may be able to keep it permissively licensed:

    'bugzilla' python module for talking to a Bugzilla instance over XMLRPC

    But I haven't looked over the code closely enough.

    If not, the only other client lib I see is https://github.com/gdestuynder/simple_bugzilla (MPL), but this lib has more activity ATM.

    opened by tony 34
  • RFE: Option for 'minor_update' to not send email

    RFE: Option for 'minor_update' to not send email

    I have the option to 'not send email as this is a minor update" option in the Red Hat bugzilla, I'd like to be able to use this from the command line.

    Is this something that I can be set with a CLI option or is it a field in can trigger? If not, please consider this as a feature request.

    Thanks in advance.

    opened by wmealing 13
  • RFE: Support bugzilla REST API

    RFE: Support bugzilla REST API

    For bugzilla 5 and later, the XMLRPC API is deprecated and won't be receiving new features, and eventually removed (though I suspect not for a while). So we need to add support for the REST API to python-bugzilla soon

    opened by crobinso 13
  • RFE Support API Keys when using the cli tool

    RFE Support API Keys when using the cli tool

    This library seems to have support for using API keys, but they don't seem to be able to be used by the command line client.

    This would be very useful.

    opened by pgagne 9
  • package broken on bugzilla 4.4.1

    package broken on bugzilla 4.4.1

    Hi, I have a bugzilla running on 4.4.1 which the package works fine with if I use 1.2.2. If I use 2.1.0 though, I start getting these stack traces

    Traceback (most recent call last):
      File "ok2.py", line 6, in <module>
        BZ.login('user', 'password')
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/bugzilla/base.py", line 608, in login
        ret = self._login(self.user, self.password)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/bugzilla/base.py", line 574, in _login
        return self._proxy.User.login({'login': user, 'password': password})
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1240, in __call__
        return self.__send(self.__name, args)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/bugzilla/transport.py", line 100, in _ServerProxy__request
        ret = ServerProxy._ServerProxy__request(self, methodname, params)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1599, in __request
        verbose=self.__verbose
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/bugzilla/transport.py", line 195, in request
        return self._request_helper(url, request_body)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/bugzilla/transport.py", line 158, in _request_helper
        url, data=request_body, **self.request_defaults)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/requests/sessions.py", line 549, in post
        return self.request('POST', url, data=data, json=json, **kwargs)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/requests/sessions.py", line 502, in request
        resp = self.send(prep, **send_kwargs)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/requests/sessions.py", line 612, in send
        r = adapter.send(request, **kwargs)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/q.py", line 279, in wrapper
        result = func(*args, **kwargs)
      File "/Users/trupp/src/envs/ansible-2.0/lib/python2.7/site-packages/requests/adapters.py", line 492, in send
        raise ConnectionError(err, request=request)
    requests.exceptions.ConnectionError: ('Connection aborted.', error("(54, 'ECONNRESET')",))
    

    This seems to happen whether I use the Bugzilla class or the Bugzilla44 class.

    Any thoughts on why this might be occurring? I recognize that there are quite a number of changes between the two versions. Just curious if you have any insight.

    opened by caphrim007 9
  • Client side certificate support

    Client side certificate support

    Adds the cert command line and configuration options that allow you to specify a client-side certificate file to use for TLS authentication against the web server.

    File format should be concatenated certificate and (unencrypted) private key. Encrypted private key should also be possible, but would have to deal with passing the password along to requests, and I'm not comfortable enough with Python to actually facilitate that.

    opened by towo 7
  • Fetching component details does not work in Bugzilla 5.0

    Fetching component details does not work in Bugzilla 5.0

    When requesting the component details in Bugzilla 5.0, the following error comes:

    RuntimeError: This bugzilla version does not support fetching component details.

    The related code is:

    def _getcomponentsdetails(self, product): # Originally this was a RH extension getProdCompDetails # Upstream support has been available since 4.2 if not self._check_version(4, 2): raise RuntimeError("This bugzilla version does not support " "fetching component details.")

    However, when omitting this check, the function seems to be supported.

    opened by janhollevoet 7
  • Fix path rules, add basic auth

    Fix path rules, add basic auth

    This PR rewrites path rules in a standard way, using urlparse/urlunparse as well as adds sometimes required Basic authentication via headers, so the XML-RPC API URL can be at all accessed before even calling any functions.

    Example usage:

    # coding: utf-8
    import bugzilla
    import getpass
    
    bug_id = input("Bug ID: ")
    user = input("Username: ")
    pwd = getpass.getpass("Password: ")
    
    bz = bugzilla.Bugzilla(url='https://apibugzilla.suse.com',
        user=user, password=pwd, basic_auth=True)
    print(bz.getbug(bug_id).id)
    
    opened by isbm 6
  • [RFE] Add coroutines (asyncio) support

    [RFE] Add coroutines (asyncio) support

    I'd like to use Python to talk to Bugzilla from a coroutine. Currently, python-bugzilla uses xmlrpc.client and every call to Bugzilla is blocking. This is an RFC to also allow async operations. Maybe via aiohttp-xmlrpc.

    Currently I can get around this problem by using asyncio.loop.run_in_executor like this:

    def _bugzillas():
        bzapi = bugzilla.Bugzilla(BUGZILLA)
        query = bzapi.build_query(product='Fedora')
        query['blocks'] = TRACKER
        return sorted(bzapi.query(query), key=lambda b: -b.id)
    
    
    async def bugzillas():
        loop = asyncio.get_event_loop()
        with concurrent.futures.ThreadPoolExecutor() as pool:
            return await loop.run_in_executor(pool, _bugzillas)
    

    Thanks for considering.

    wishlist 
    opened by hroncok 6
  • Fix missing authentication regression

    Fix missing authentication regression

    Identifiers with a leading "__" are mangled, ensure that the original method is overridden such that authentication tokens are added.

    Fixes: v2.1.0-11-g3c692f4f4e ("_BugzillaServerProxy as new-style class")


    This should have been caught by the rw test (#52).

    opened by Lekensteyn 6
  • Feature Request: enhance output for external trackers

    Feature Request: enhance output for external trackers

    Today, if you query for information (from the cli) and use 'external_bug' the data you get back is in the BZ's array of 1 format, which gets translated, to a dictionary of sub-elements.

    Because of this, the --outputformats inability to parse/define what (subfields) you see from this, the output is not very usable, or parsable!

    Is there a way, like what we do with CVE/comments to improve this?

    Mainly the (fields):

    • [ ] ext_bz_bug_id
    • [ ] ext_status
    • [ ] ext_description
    opened by sferich888 6
  • IndexError raised in Bugzilla._getbug

    IndexError raised in Bugzilla._getbug

    When using/enforcing the use of the REST API, the _getbug method raises an IndexError, if

    1. the specified bug ID does not exist or
    2. the user is not authorized to access the bug

    1. ID does not exist

    >>> b = Bugzilla(url='https://bugzilla.redhat.com', force_rest=True)
    >>> b.getbug(214525300)
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
      File "/usr/lib/python3.6/site-packages/bugzilla/base.py", line 1133, in getbug
        extra_fields=extra_fields)
      File "/usr/lib/python3.6/site-packages/bugzilla/base.py", line 1123, in _getbug
        return self._getbugs([objid], permissive=False, **kwargs)[0]
    IndexError: list index out of range
    

    2. Not authorized

    >>> b = Bugzilla(url='https://bugzilla.redhat.com', force_rest=True)
    >>> b.getbug(2145254)
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
      File "/usr/lib/python3.6/site-packages/bugzilla/base.py", line 1133, in getbug
        extra_fields=extra_fields)
      File "/usr/lib/python3.6/site-packages/bugzilla/base.py", line 1123, in _getbug
        return self._getbugs([objid], permissive=False, **kwargs)[0]
    IndexError: list index out of range
    

    Preliminary analysis

    When using the API route /rest/bug/<bug_id> one would get appropriate answers from the API (i.e. error 404 and 401), but the _getbug method uses the /rest/bug endpoint instead with an ids argument containing a single ID. In this case the API returns an empty list, which seems to be the direct cause of the IndexError.

    opened by crazyscientist 0
  • Provide 'total_matches' in query response if server provides it

    Provide 'total_matches' in query response if server provides it

    The RH Bugzilla provides a 'total_matches' value in a query response which the querier can use to know whether the response included all matching bugs or not. This patch adds a proxy object wrapped around the list of returned bugs to expose this value if the server has provided it. The proxy object implements enough of the Python iterator protocol so that it can be used as a replacement for existing code issuing queries, as long as that code does not attempt to modify the returned list object.

    Related to #149. Read-only functional tests pass with this patch except for testFaults which fails even without the patch :-)

    opened by kpfleming 0
  • rest api: Post process bugzilla code on HTTP error

    rest api: Post process bugzilla code on HTTP error

    Bugzilla REST API map result codes to HTTP status codes: https://github.com/bugzilla/bugzilla/blob/7581e08f9136ec32219af6c3192e42ff1c8e9691/Bugzilla/WebService/Constants.pm#L262-L287

    But python-bugzilla don't propagate those Bugzilla codes.

    Fixes: https://github.com/python-bugzilla/python-bugzilla/issues/171

    opened by stanislavlevin 0
  • REST API and HTTP errors

    REST API and HTTP errors

    The following query crashes:

    import bugzilla
    
    
    URL = "bugzilla.stage.redhat.com"
    bzapi = bugzilla.Bugzilla(URL, force_rest=True, use_creds=False)
    print(bzapi.logged_in)
    
    Traceback (most recent call last):
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/_session.py", line 108, in request
        response.raise_for_status()
      File "/usr/lib/python3/site-packages/requests/models.py", line 1021, in raise_for_status
        raise HTTPError(http_error_msg, response=self)
    requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://bugzilla.stage.redhat.com/rest/user?ids=1
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/usr/src/test.py", line 6, in <module>
        print(bzapi.logged_in)
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/base.py", line 720, in logged_in
        raise e
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/base.py", line 714, in logged_in
        self._backend.user_get({"ids": [1]})
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/_backendrest.py", line 182, in user_get
        return self._get("/user", paramdict)
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/_backendrest.py", line 63, in _get
        return self._op("GET", *args, **kwargs)
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/_backendrest.py", line 58, in _op
        response = self._bugzillasession.request(method, fullurl, data=data,
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/_session.py", line 112, in request
        raise type(e)(message).with_traceback(sys.exc_info()[2])
      File "/usr/src/RPM/BUILD/python-bugzilla/bugzilla/_session.py", line 108, in request
        response.raise_for_status()
      File "/usr/lib/python3/site-packages/requests/models.py", line 1021, in raise_for_status
        raise HTTPError(http_error_msg, response=self)
    requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://bugzilla.stage.redhat.com/rest/user?ids=1
    

    The problem is that logged_in expects BugzillaError or any other exception having code or faultCode attribute.

    Bugzilla codes are mapped to HTTP status codes: https://github.com/bugzilla/bugzilla/blob/7581e08f9136ec32219af6c3192e42ff1c8e9691/Bugzilla/WebService/Constants.pm#L262-L287

    But this project don't handle such codes on HTTP errors.

    opened by stanislavlevin 0
  • include_fields in bz.getbug with string-named bug instead of id results in IndexError

    include_fields in bz.getbug with string-named bug instead of id results in IndexError

    bz = bugzilla.Bugzilla(url="bugzilla.redhat.com", api_key="key", force_rest=True)
    
    bz.getbug(2135298) # works
    bz.getbug(2135298, include_fields=["id"]) # works
    
    bz.getbug("F37FinalBlocker") # works
    bz.getbug("F37FinalBlocker", include_fields=["id"]) # broken:
    
    ---------------------------------------------------------------------------
    IndexError                                Traceback (most recent call last)
    Input In [9], in <cell line: 0>()
    ----> 1 bz.getbug("F37FinalBlocker", include_fields=["id"])
    
    File /usr/lib/python3.11/site-packages/bugzilla/base.py:1129, in Bugzilla.getbug(self, objid, include_fields, exclude_fields, extra_fields)
       1123 def getbug(self, objid,
       1124            include_fields=None, exclude_fields=None, extra_fields=None):
       1125     """
       1126     Return a Bug object with the full complement of bug data
       1127     already loaded.
       1128     """
    -> 1129     data = self._getbug(objid,
       1130         include_fields=include_fields, exclude_fields=exclude_fields,
       1131         extra_fields=extra_fields)
       1132     return Bug(self, dict=data, autorefresh=self.bug_autorefresh)
    
    File /usr/lib/python3.11/site-packages/bugzilla/base.py:1121, in Bugzilla._getbug(self, objid, **kwargs)
       1112 def _getbug(self, objid, **kwargs):
       1113     """
       1114     Thin wrapper around _getbugs to handle the slight argument tweaks
       1115     for fetching a single bug. The main bit is permissive=False, which
       (...)
       1119     This logic is called from Bug() too
       1120     """
    -> 1121     return self._getbugs([objid], permissive=False, **kwargs)[0]
    
    IndexError: list index out of range
    
    opened by frantisekz 2
Releases(v3.2.0)
Owner
Python Bugzilla Project
Python Bugzilla Project
Alacritty terminal used with Bash, Tmux, Vim, Mutt, Lynx, etc. and the many different additions added to each configuration file

Alacritty terminal used with Bash, Tmux, Vim, Mutt, Lynx, etc. and the many different additions added to each configuration file

Carter 19 Aug 24, 2022
Bryce Geiser 4 Aug 04, 2022
Neovim integration for Google Keep, built using gkeepapi

Gkeep.nvim Neovim integration for Google Keep, built using gkeepapi Requirements Neovim 0.5 Python 3.6+ A patched font (optional. Used for icons) Tabl

Steven Arcangeli 143 Jan 02, 2023
Code for the Open Data Day 2022 publicbodies.org Nepal data scraping activities.

Open Data Day Publicbodies.org Nepal We've gathered on Saturday, 5th March 2022 with Open Knowledge Nepal in order to try and automate the collection

Augusto Herrmann 2 Mar 12, 2022
This is an app for creating your own color scheme for Termux!

Termux Terminal Theme Creator [WIP] If you need help on how to use the program, you can either create a GitHub issue or join this temporary Discord se

asxlvm 3 Dec 31, 2022
Detect secret in source code, scan your repo for leaks. Find secrets with GitGuardian and prevent leaked credentials. GitGuardian is an automated secrets detection & remediation service.

GitGuardian Shield: protect your secrets with GitGuardian GitGuardian shield (ggshield) is a CLI application that runs in your local environment or in

GitGuardian 1.2k Jan 06, 2023
Write Django management command using the click CLI library

Django Click Project information: Automated code metrics: django-click is a library to easily write Django management commands using the click command

Jonathan Stoppani 215 Dec 19, 2022
tiptop is a command-line system monitoring tool in the spirit of top.

Command-line system monitoring. tiptop is a command-line system monitoring tool in the spirit of top. It displays various interesting system stats, gr

Nico Schlömer 1.3k Jan 08, 2023
Booky - A command line utility for bookmarking files on your terminal!

Booky A command line utility for bookmarking files for quick access With it you can: Bookmark and delete your (aliases of) files at demand Launch them

Pran 1 Sep 11, 2022
A supercharged AWS command line interface (CLI).

SAWS Motivation AWS CLI Although the AWS CLI is a great resource to manage your AWS-powered services, it's tough to remember usage of: 70+ top-level c

Donne Martin 5.1k Jan 05, 2023
Simple command-line implementation of minesweeper

minesweeper This is a Python implementation of 2-D Minesweeper! Check out the tutorial here: https://youtu.be/Fjw7Lc9zlyU You start a game by running

Kylie 49 Dec 10, 2022
Hurry is a CLI tool to speed setting up MoniGoMani HyperStrategy & co. #freqtrade #hyperopting #trading #strategy

Hurry is a CLI tool to speed setting up MoniGoMani HyperStrategy & co. #freqtrade #hyperopting #trading #strategy

10 Dec 29, 2022
A CLI for creating styled-components for React projects quickly

new-component Ian Cleary (iancleary) Description Welcome! This is a CLI for creating styled-components for React projects quickly. Note: I've rewrote

Ian Cleary (he/him/his) 1 Feb 15, 2022
A curated list of awesome things related to Textual

Awesome Textual | A curated list of awesome things related to Textual. Textual is a TUI (Text User Interface) framework for Python inspired by modern

Marcelo Trylesinski 5 May 08, 2022
Official AIdea command line tool

AIdea CLI Official AIdea command line tool for https://aidea-web.tw. Installation Make sure you have installed both Python 3 and pip package manager.

AIdea 5 Dec 15, 2021
GitFun - A Simplified Automated CLI tool for GIT😃

GitFun A Simplified Automated CLI tool for GIT, It's for Lazy Developers and Newbies 😜 Table of contents GitFun Installation Usage Development Contri

Astaqc 8 Feb 22, 2022
Todo list console based application. Todo's save to a seperate file.

Todo list console based application. Todo's save to a seperate file.

1 Dec 24, 2021
CLTools provides various tools and command to use in the terminal.

CLTools provides various tools and command to use in the terminal. As of date, CLTools is only able to generate temporary email addresses and receive emails. There are plans to integrate more tools a

Ashwin Chugh 2 Feb 14, 2022
texel - Command line interface for reading spreadsheets inside terminal

texel - Command line interface for reading spreadsheets inside terminal. Sometimes, you have to deal with spreadsheets. Those are sad times. Fortunate

128 Dec 19, 2022
A cd command that learns - easily navigate directories from the command line

NAME autojump - a faster way to navigate your filesystem DESCRIPTION autojump is a faster way to navigate your filesystem. It works by maintaining a d

William Ting 14.5k Jan 03, 2023