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 terminal tool for git. When we use git, do you feel very uncomfortable with too long commands

PIGIT A terminal tool for git. When we use git, do you feel very uncomfortable with too long commands. For example: git status --short, this project c

Zachary 1 Apr 09, 2022
This is a repository for collecting global custom management extensions for the Django Framework.

Django Extensions Django Extensions is a collection of custom extensions for the Django Framework. Getting Started The easiest way to figure out what

Django Extensions 6k Jan 03, 2023
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 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 (work

Jigyasu 10 Jul 27, 2022
Open-Source Python CLI package for copying DynamoDB tables and items in parallel batch processing + query natural & Global Secondary Indexes (GSIs)

Python Command-Line Interface Package to copy Dynamodb data in parallel batch processing + query natural & Global Secondary Indexes (GSIs).

1 Oct 31, 2021
A Telegram Bot Written In Python To Upload Medias To telegra.ph

Telegraph-Uploader A Telegram Bot Written In Python To Upload Medias To telegra.ph DEPLOY YOU CAN SIMPLY DEPLOY ON HEROKU BY CLICKING THE BUTTON BELOW

Rithunand 31 Dec 03, 2022
vimBrain is a brainfuck-based vim-inspired esoteric programming language.

vimBrain vimBrain is a brainfuck-based vim-inspired esoteric programming language. vimBrainPy Currently, the only interpreter available is written in

SalahDin Ahmed 3 May 08, 2022
CLI for SQLite Databases with auto-completion and syntax highlighting

litecli Docs A command-line client for SQLite databases that has auto-completion and syntax highlighting. Installation If you already know how to inst

dbcli 1.8k Dec 31, 2022
Ros command - Unifying the ROS command line tools

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

37 Dec 15, 2022
🌈 Generate color palettes based on Neovim colorschemes.

Iris Iris is a Neovim plugin that generates a normalized color palette based on your colorscheme. It is named for the goddess Iris of Greek mythology,

N. G. Scheurich 45 Jul 28, 2022
Simple CLI tool to track your cryptocurrency portfolio in real time.

Simple tool to track your crypto portfolio in realtime. It can be used to track any coin on the BNB network, even obscure coins that are not listed or trackable by major portfolio tracking applicatio

Trevor White 69 Oct 24, 2022
Standalone Tailwind CSS CLI, installable via pip

Standalone Tailwind CSS CLI, installable via pip Use Tailwind CSS without Node.j

Tim Kamanin 144 Dec 22, 2022
swarmexec executes command in swarm service

Swarmexec swarmexec executes command in swarm service Install pip install git+https://github.com/filimon43g/swarmexec.git Config In swarm_config.ini

Phil 2 Nov 23, 2021
PdpCLI is a pandas DataFrame processing CLI tool which enables you to build a pandas pipeline from a configuration file.

PdpCLI Quick Links Introduction Installation Tutorial Basic Usage Data Reader / Writer Plugins Introduction PdpCLI is a pandas DataFrame processing CL

Yasuhiro Yamaguchi 15 Jan 07, 2022
keep your machine's shell history synchronize

SyncShell Yet another tool for laziness Keep your machine's shell history synchronize Get SyncShell Currently, SyncShell is just available on PyPi and

Masoud Ghorbani 53 Dec 12, 2022
A CLI Password Manager made using Python and Postgresql database.

ManageMyPasswords (CLI Edition) A CLI Password Manager made using Python and Postgresql database. Quick Start Guide First Clone The Project git clone

Imira Randeniya 1 Sep 11, 2022
Easily turn single threaded command line applications into a fast, multi-threaded application with CIDR and glob support.

Easily turn single threaded command line applications into a fast, multi-threaded application with CIDR and glob support.

Michael Skelton 1k Jan 07, 2023
A CLI tools to get you started on any project in any language

Any Template A faster easier to Quick start any programming project. Installation pip3 install any-template Features No third party dependencies. Tem

Adwaith Rajesh 2 Jan 11, 2022
lfb (light file browser) is a terminal file browser

lfb (light file browser) is a terminal file browser. The whole program is a mess as of now. In the feature I will remove the need for external dependencies, tidy up the code, make an actual readme, a

2 Apr 09, 2022
Output Analyzer for you terminal commands

Output analyzer (OZER) You can specify a few words inside config.yaml file and specify the color you want to be used. installing: Install command usin

Ehsan Shirzadi 1 Oct 21, 2021