Hello community,
here is the log from the commit of package python-pynetbox for openSUSE:Factory
checked in at 2019-09-30 15:59:16
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pynetbox (Old)
and /work/SRC/openSUSE:Factory/.python-pynetbox.new.2352 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pynetbox"
Mon Sep 30 15:59:16 2019 rev:2 rq:733771 version:4.0.8
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pynetbox/python-pynetbox.changes
2019-09-27 14:49:01.584674587 +0200
+++
/work/SRC/openSUSE:Factory/.python-pynetbox.new.2352/python-pynetbox.changes
2019-09-30 15:59:19.761227737 +0200
@@ -1,0 +2,6 @@
+Fri Sep 27 22:21:50 UTC 2019 - Martin Hauke <[email protected]>
+
+- Update to version 4.0.8
+ * Returns ContentError when 2XX response but not JSON.
+
+-------------------------------------------------------------------
Old:
----
pynetbox-4.0.7.tar.gz
New:
----
pynetbox-4.0.8.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pynetbox.spec ++++++
--- /var/tmp/diff_new_pack.xoTHAI/_old 2019-09-30 15:59:20.649225374 +0200
+++ /var/tmp/diff_new_pack.xoTHAI/_new 2019-09-30 15:59:20.653225364 +0200
@@ -18,7 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-pynetbox
-Version: 4.0.7
+Version: 4.0.8
Release: 0
Summary: NetBox API client library
License: Apache-2.0
++++++ pynetbox-4.0.7.tar.gz -> pynetbox-4.0.8.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-4.0.7/PKG-INFO new/pynetbox-4.0.8/PKG-INFO
--- old/pynetbox-4.0.7/PKG-INFO 2019-09-13 17:11:18.000000000 +0200
+++ new/pynetbox-4.0.8/PKG-INFO 2019-09-27 15:57:13.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: pynetbox
-Version: 4.0.7
+Version: 4.0.8
Summary: NetBox API client library
Home-page: https://github.com/digitalocean/pynetbox
Author: Zach Moody
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-4.0.7/pynetbox/__init__.py
new/pynetbox-4.0.8/pynetbox/__init__.py
--- old/pynetbox-4.0.7/pynetbox/__init__.py 2019-09-13 17:11:00.000000000
+0200
+++ new/pynetbox-4.0.8/pynetbox/__init__.py 2019-09-27 15:56:53.000000000
+0200
@@ -1,6 +1,6 @@
from pkg_resources import get_distribution, DistributionNotFound
-from pynetbox.core.query import RequestError
+from pynetbox.core.query import RequestError, AllocationError, ContentError
from pynetbox.api import Api as api
try:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-4.0.7/pynetbox/core/query.py
new/pynetbox-4.0.8/pynetbox/core/query.py
--- old/pynetbox-4.0.7/pynetbox/core/query.py 2019-09-13 17:11:00.000000000
+0200
+++ new/pynetbox-4.0.8/pynetbox/core/query.py 2019-09-27 15:56:53.000000000
+0200
@@ -92,6 +92,29 @@
self.error = message
+class ContentError(Exception):
+ """Content Exception
+
+ If the API URL does not point to a valid NetBox API, the server may
+ return a valid response code, but the content is not json. This
+ exception is raised in those cases.
+ """
+
+ def __init__(self, message):
+ req = message
+
+ message = (
+ "The server returned invalid (non-json) data. Maybe not "
+ "a NetBox server?"
+ )
+
+ super(ContentError, self).__init__(message)
+ self.req = req
+ self.request_body = req.request.body
+ self.url = req.url
+ self.error = message
+
+
class Request(object):
"""Creates requests to the Netbox API
@@ -157,7 +180,10 @@
verify=self.ssl_verify,
)
if req.ok:
- return req.json()["session_key"]
+ try:
+ return req.json()["session_key"]
+ except json.JSONDecodeError:
+ raise ContentError(req)
else:
raise RequestError(req)
@@ -214,6 +240,7 @@
any paginated results.
:raises: RequestError if req.ok returns false.
+ :raises: ContentError if response is not json.
:Returns: List of `Response` objects returned from the
endpoint.
@@ -228,7 +255,10 @@
req = requests.get(url, headers=headers, verify=self.ssl_verify)
if req.ok:
- return req.json()
+ try:
+ return req.json()
+ except json.JSONDecodeError:
+ raise ContentError(req)
else:
raise RequestError(req)
@@ -266,6 +296,7 @@
:param data: (dict) Contains a dict that will be turned into a
json object and sent to the API.
:raises: RequestError if req.ok returns false.
+ :raises: ContentError if response is not json.
:returns: Dict containing the response from NetBox's API.
"""
headers = {
@@ -281,7 +312,10 @@
verify=self.ssl_verify,
)
if req.ok:
- return req.json()
+ try:
+ return req.json()
+ except json.JSONDecodeError:
+ raise ContentError(req)
else:
raise RequestError(req)
@@ -294,6 +328,10 @@
:param data: (dict) Contains a dict that will be turned into a
json object and sent to the API.
:raises: RequestError if req.ok returns false.
+ :raises: AllocationError if req.status_code is 204 (No Content)
+ as with available-ips and available-prefixes when there is
+ no room for the requested allocation.
+ :raises: ContentError if response is not json.
:Returns: Dict containing the response from NetBox's API.
"""
headers = {
@@ -311,7 +349,10 @@
if req.status_code == 204:
raise AllocationError(req)
elif req.ok:
- return req.json()
+ try:
+ return req.json()
+ except json.JSONDecodeError:
+ raise ContentError(req)
else:
raise RequestError(req)
@@ -346,6 +387,7 @@
:param data: (dict) Contains a dict that will be turned into a
json object and sent to the API.
:raises: RequestError if req.ok returns false.
+ :raises: ContentError if response is not json.
:returns: Dict containing the response from NetBox's API.
"""
headers = {
@@ -361,6 +403,9 @@
verify=self.ssl_verify,
)
if req.ok:
- return req.json()
+ try:
+ return req.json()
+ except json.JSONDecodeError:
+ raise ContentError(req)
else:
raise RequestError(req)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pynetbox-4.0.7/pynetbox.egg-info/PKG-INFO
new/pynetbox-4.0.8/pynetbox.egg-info/PKG-INFO
--- old/pynetbox-4.0.7/pynetbox.egg-info/PKG-INFO 2019-09-13
17:11:18.000000000 +0200
+++ new/pynetbox-4.0.8/pynetbox.egg-info/PKG-INFO 2019-09-27
15:57:12.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: pynetbox
-Version: 4.0.7
+Version: 4.0.8
Summary: NetBox API client library
Home-page: https://github.com/digitalocean/pynetbox
Author: Zach Moody