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
Textual: a TUI (Text User Interface) framework for Python inspired by modern web development

Textual Textual is a TUI (Text User Interface) framework for Python inspired by

17.1k Jan 04, 2023
A simple command-line tracert implementation in Python 3 using ICMP packets

Traceroute A simple command-line tracert implementation in Python 3 using ICMP packets Details Traceroute is a networking tool designed for tracing th

James 3 Jul 16, 2022
stonky is a simple command line dashboard for monitoring stocks.

stonky is a simple command line dashboard for monitoring stocks.

Jessy Williams 228 Dec 14, 2022
Execute shell command lines in parallel on Slurm, S(on) of Grid Engine (SGE), PBS/Torque clusters

qbatch Execute shell command lines in parallel on Slurm, S(on) of Grid Engine (SGE), PBS/Torque clusters qbatch is a tool for executing commands in pa

Jon Pipitone 26 Dec 12, 2022
Wappalyzer CLI tool to find Web Technologies

Wappalyzer CLI tool to find Web Technologies

GOKUL A.P 17 Dec 15, 2022
This is a CLI utility that allows you to view RedFlagDeals.com on the command line.

RFD Description Motivation Installation Usage View Hot Deals View and Sort Hot Deals Search Advanced View Posts Shell Completion bash zsh Description

Dave G 8 Nov 29, 2022
kitty - the fast, feature-rich, cross-platform, GPU based terminal

kitty - the fast, feature-rich, cross-platform, GPU based terminal

Kovid Goyal 17.3k Jan 04, 2023
Juniper Command System is a Micro CLI Tool that allows you to manage your files, launch applications, as well as providing extra tools for OS Management.

Juniper Command System is a Micro CLI Tool that allows you to manage your files, launch applications, as well as providing extra tools for OS Management.

Juan Carlos Juárez 1 Feb 02, 2022
Ipylivebash - Run shell script in Jupyter with live output

ipylivebash ipylivebash is a library to run shell script in Jupyter with live ou

Ben Lau 6 Aug 27, 2022
Simple tool, to update linux kernel on ubuntu

Kerbswap Simple tool, to update linux kernel on ubuntu Information At the moment, this tool only supports "Ubuntu" distributions, but will be expanded

dword 1 Oct 31, 2021
Create animated ASCII-art for the command line almost instantly!

clippy Create and play colored 🟥 🟩 🟦 or colorless ⬛️ ⬜️ animated, or static, ASCII-art in the command line! clippy can help if you are wanting to;

Connor 10 Jun 26, 2022
🐍 Python CLI tool to get public information from a GitHub account

🐍 Gitter 🐍 Python CLI tool to get public information from a GitHub account 🤔 What's this? Gitter is a open-source project created to easily uses th

opp? 3 Oct 14, 2022
A terminal spreadsheet multitool for discovering and arranging data

VisiData v2.6.1 A terminal interface for exploring and arranging tabular data. VisiData supports tsv, csv, sqlite, json, xlsx (Excel), hdf5, and many

Saul Pwanson 6.2k Jan 04, 2023
pyGinit is a command line tools that help you to initialize your current project a local git repo and remote repo

pyGinit pyGinit is a command line tools that help you to initialize your current project a local git repo and remote repo Requirements Requirements be

AlphaBeta 15 Feb 26, 2022
The project help you to quickly build layouts in terminal,cross-platform

The project help you to quickly build layouts in terminal,cross-platform

gojuukaze 133 Nov 30, 2022
xonsh is a Python-powered, cross-platform, Unix-gazing shell language and command prompt.

xonsh xonsh is a Python-powered, cross-platform, Unix-gazing shell language and command prompt. The language is a superset of Python 3.6+ with additio

xonsh 6.7k Jan 08, 2023
Themes for the kitty terminal emulator

Themes for the kitty terminal This is a collection of themes for the kitty terminal emulator. The themes were initially imported from dexpota/kitty-th

Kovid Goyal 190 Jan 05, 2023
topalias - Linux alias generator from bash/zsh command history with statistics, written on Python.

topalias topalias - Linux alias generator from bash/zsh command history with statistics, written on Python. Features Generate short alias for popular

Sergey Chudakov 38 May 26, 2022
commandpack - A package of modules for working with commands, command packages, files with command packages.

commandpack Help the project financially: Donate: https://smartlegion.github.io/donate/ Yandex Money: https://yoomoney.ru/to/4100115206129186 PayPal:

4 Sep 04, 2021
A begginer reverse shell tool python.

A begginer reverse shell tool python. Este programa é para apenas estudo e conhecimento. Não use isso em outra pessoas. Não me responsabilizo por uso

Dio brando 2 Jan 05, 2022