Browse Source

Fix missing Exception.message in Python 3

tags/nilmdb-2.0.0
Jim Paris 4 years ago
parent
commit
0e6ccd687b
3 changed files with 5 additions and 6 deletions
  1. +1
    -1
      nilmdb/client/httpclient.py
  2. +2
    -3
      nilmdb/server/errors.py
  3. +2
    -2
      nilmdb/server/server.py

+ 1
- 1
nilmdb/client/httpclient.py View File

@@ -87,7 +87,7 @@ class HTTPClient(object):
session.close()
except requests.RequestException as e:
raise ServerError(status = "502 Error", url = url,
message = str(e.message))
message = str(e))
if response.status_code != 200:
self._handle_error(url, response.status_code, response.content)
self._last_response = response


+ 2
- 3
nilmdb/server/errors.py View File

@@ -2,9 +2,8 @@

class NilmDBError(Exception):
"""Base exception for NilmDB errors"""
def __init__(self, message = "Unspecified error"):
super().__init__(message)
self.message = message
def __init__(self, msg = "Unspecified error"):
super().__init__(msg)

class StreamError(NilmDBError):
pass


+ 2
- 2
nilmdb/server/server.py View File

@@ -166,7 +166,7 @@ class Stream(NilmApp):
try:
data = self.db.stream_get_metadata(path)
except nilmdb.server.nilmdb.StreamError as e:
raise cherrypy.HTTPError("404 Not Found", e.message)
raise cherrypy.HTTPError("404 Not Found", str(e))
if key is None: # If no keys specified, return them all
key = list(data.keys())
elif not isinstance(key, list):
@@ -185,7 +185,7 @@ class Stream(NilmApp):
try:
data = dict(json.loads(data))
except TypeError as e:
raise NilmDBError("can't parse 'data' parameter: " + e.message)
raise NilmDBError("can't parse 'data' parameter: " + str(e))
for key in data:
if not (isinstance(data[key], str) or
isinstance(data[key], float) or


Loading…
Cancel
Save