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
A command line application, written in Python, for interacting with Spotify.

spotify-py-cli A command line application, written in Python, for interacting with Spotify. The primary purpose behind developing this app was to gain

Drew Loukusa 0 Oct 7, 2021
A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Stream your favorite shows straight from the command line.

A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Installation pip install -r requirements.txt It use

Jonardon Hazarika 17 Dec 11, 2022
AML Command Transfer. A lightweight tool to transfer any command line to Azure Machine Learning Services

AML Command Transfer (ACT) ACT is a lightweight tool to transfer any command from the local machine to AML or ITP, both of which are Azure Machine Lea

Microsoft 11 Aug 10, 2022
A command line tool (and Python library) for archiving Twitter JSON

A command line tool (and Python library) for archiving Twitter JSON

Documenting the Now 1.3k Dec 28, 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 3, 2023
Ros command - Unifying the ROS command line tools

Unifying the ROS command line tools One impairment to ROS 2 adoption is that all

null 37 Dec 15, 2022
Python command line tool and python engine to label table fields and fields in data files.

Python command line tool and python engine to label table fields and fields in data files. It could help to find meaningful data in your tables and data files or to find Personal identifable information (PII).

APICrafter 22 Dec 5, 2022
A lightweight Python module and command-line tool for generating NATO APP-6(D) compliant military symbols from both ID codes and natural language names

Python military symbols This is a lightweight Python module, including a command-line script, to generate NATO APP-6(D) compliant military symbol icon

Nick Royer 5 Dec 27, 2022
gget is a free and open-source command-line tool and Python package that enables efficient querying of genomic databases.

gget is a free and open-source command-line tool and Python package that enables efficient querying of genomic databases. gget consists of a collection of separate but interoperable modules, each designed to facilitate one type of database querying in a single line of code.

Pachter Lab 570 Dec 29, 2022
MsfMania is a command line tool developed in Python that is designed to bypass antivirus software on Windows and Linux/Mac in the future

MsfMania MsfMania is a command line tool developed in Python that is designed to bypass antivirus software on Windows and Linux/Mac in the future. Sum

null 446 Dec 21, 2022
A python command line tool to calculate options max pain for a given company symbol and options expiry date.

Options-Max-Pain-Calculator A python command line tool to calculate options max pain for a given company symbol and options expiry date. Overview - Ma

null 13 Dec 26, 2022
A command line tool to hide and reveal information inside images (works for both PNGs and JPGs)

Imgrerite A command line tool to hide and reveal information inside images (works for both PNGs and JPGs) Dependencies Python 3 Git Most of the Linux

Jigyasu 10 Jul 27, 2022
Splitgraph command line client and python library

Splitgraph Overview Splitgraph is a tool for building, versioning and querying reproducible datasets. It's inspired by Docker and Git, so it feels fam

Splitgraph 313 Dec 24, 2022
PwnWiki command line searching tool & bindings written in Python

pwsearch PwnWiki 数据库搜索命令行工具。 安装 您可以直接用 pip 命令从 PyPI 安装 pwsearch: pip3 install -U pwsearch 您也可以 clone 该仓库并直接从源码启动

PwnWiki 20 Jun 21, 2021
PyArmor is a command line tool used to obfuscate python scripts

PyArmor is a command line tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.

Dashingsoft 2k Jan 7, 2023
Unofficial Open Corporates CLI: OpenCorporates is a website that shares data on corporations under the copyleft Open Database License. This is an unofficial open corporates python command line tool.

Unofficial Open Corporates CLI OpenCorporates is a website that shares data on corporations under the copyleft Open Database License. This is an unoff

Richard Mwewa 30 Sep 8, 2022
Professor Wordlist is a free open source command line tool written in python

Professor Wordlist is a free open source command line tool written in python, With the aim of generating custom wordlists with a variety of unique parameters and functions providing many possibilities.

オークO A K Z E H オーク 1 Oct 28, 2021
A simple command line tool written in python to manage a to-do list

A simple command line tool written in python to manage a to-do list Dependencies: python Commands: todolist (-a | --add) [(-p | --priority)] [(-l | --

edwloef 0 Nov 2, 2021