From 277c67dd0f8ed92ad274688f7cd2caf316bef636 Mon Sep 17 00:00:00 2001 From: Matt Snyder Date: Thu, 6 Feb 2020 18:35:36 -0600 Subject: [PATCH] Throw exception on permissions error for list channel endpoint --- pyqvrpro/client.py | 12 +++++++++++- setup.py | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pyqvrpro/client.py b/pyqvrpro/client.py index 8863105..b5ae292 100644 --- a/pyqvrpro/client.py +++ b/pyqvrpro/client.py @@ -66,7 +66,12 @@ def get_snapshot(self, camera_guid): def get_channel_list(self): """Get a list of available channels.""" - return self._get('/qvrpro/qshare/StreamingOutput/channels') + resp = self._get('/qvrpro/qshare/StreamingOutput/channels') + + if "message" in resp.keys(): + if resp["message"] == "Insufficient permission.": + raise InsufficientPermissionsError( + "User must have Surveillance Management permission") def get_channel_streams(self, guid): """Get streams for a specific channel.""" @@ -169,3 +174,8 @@ def _base_url(self): class AuthenticationError(ConnectionError): def __init__(self, msg): super(AuthenticationError, self).__init__({msg: msg}) + + +class InsufficientPermissionsError(AuthenticationError): + def __init__(self, msg): + super(AuthenticationError, self).__init__({msg: msg}) diff --git a/setup.py b/setup.py index c4a4e46..c6d6b75 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ EMAIL = 'matt@obscurelogic.com' AUTHOR = 'Matt Snyder' REQUIRES_PYTHON = '>=3.5.0' -VERSION = 0.44 +VERSION = 0.45 # What packages are required for this module to be executed? REQUIRED = [