Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 30 additions & 28 deletions server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import os.path as op
import json
import tornado.httpserver
import tornado.ioloop
import tornado.web
import sys
import ssl
import base64
Expand Down Expand Up @@ -579,8 +581,8 @@ def put(self):
try:
body = json_decode(self.request.body)
except ValueError as e:
msg = "JSON Parser Error: " + e.message
log.info(msg)
msg = "JSON Parser Error: " + str(e)
self.log.info(msg)
raise HTTPError(400, reason=msg)

childUuid = None
Expand Down Expand Up @@ -906,7 +908,7 @@ def put(self):
try:
body = json_decode(self.request.body)
except ValueError as e:
msg = "JSON Parser Error: " + e.message
msg = "JSON Parser Error: " + str(e)
self.log.info(msg)
raise HTTPError(400, reason=msg)

Expand Down Expand Up @@ -1134,7 +1136,7 @@ def put(self):
try:
body = json_decode(self.request.body)
except ValueError as e:
msg = "JSON Parser Error: " + e.message
msg = "JSON Parser Error: " + str(e)
self.log.info(msg)
raise HTTPError(400, reason=msg)

Expand Down Expand Up @@ -1394,7 +1396,7 @@ def getSliceQueryParam(self, dim, extent):
fields = dim_query.split(":")
if len(fields) > 3:
msg = "Bad Request: Too many ':' seperators for dimension: " + str(dim)
log.info(msg)
self.log.info(msg)
raise HTTPError(400, reason=msg)
try:
if fields[0]:
Expand Down Expand Up @@ -1516,8 +1518,8 @@ def get(self):
try:
limit = int(limit) # convert to int
except ValueError as e:
msg = "invalid Limit: " + e.message
log.info(msg)
msg = "invalid Limit: " + str(e)
self.log.info(msg)
raise HTTPError(400, msg)

if query_selection:
Expand Down Expand Up @@ -1582,7 +1584,7 @@ def get(self):
self.log.info("values type: " + str(type(values)))

else:
msg = "Internal Server Error: unexpected shape class: " + shape['class']
msg = "Internal Server Error: unexpected shape class: " + item_shape['class']
self.log.error(msg)
raise HTTPError(500, reason=msg)

Expand Down Expand Up @@ -1644,7 +1646,7 @@ def post(self):
try:
body = json_decode(self.request.body)
except ValueError as e:
msg = "JSON Parser Error: " + e.message
msg = "JSON Parser Error: " + str(e)
self.log.info(msg)
raise HTTPError(400, reason=msg)

Expand Down Expand Up @@ -1691,10 +1693,10 @@ def post(self):
msg = "Bad Request: elements of points should be list type for datasets of rank >1"
self.log.info(msg)
raise HTTPError(400, reason=msg)
if len(point) != rank:
msg = "Bad Request: one or more points have a missing coordinate value"
self.log.info(msg)
raise HTTPError(400, reason=msg)
if len(point) != rank:
msg = "Bad Request: one or more points have a missing coordinate value"
self.log.info(msg)
raise HTTPError(400, reason=msg)

values = db.getDatasetPointSelectionByUuid(self.reqUuid, points)

Expand Down Expand Up @@ -1735,10 +1737,10 @@ def put(self):
body = json_decode(self.request.body)
except ValueError as e:
try:
msg = "JSON Parser Error: " + e.message
msg = "JSON Parser Error: " + str(e)
except AttributeError:
msg = "JSON Parser Error"
log.info(msg)
self.log.info(msg)
raise HTTPError(400, reason=msg)

if "value" in body:
Expand Down Expand Up @@ -1881,7 +1883,7 @@ def getRequestCollectionName(self):

npos = uri.find('/')
if npos < 0:
log.info("bad uri")
self.log.info("bad uri")
raise HTTPError(400)
uri = uri[(npos+1):]
npos = uri.find('/') # second '/'
Expand Down Expand Up @@ -1911,7 +1913,7 @@ def get(self):
try:
limit = int(limit)
except ValueError:
log.info("expected int type for limit")
self.log.info("expected int type for limit")
raise HTTPError(400)
marker = self.get_query_argument("Marker", None)

Expand Down Expand Up @@ -1974,7 +1976,7 @@ def get(self):
else:
if len(responseItems) == 0:
# should have raised exception earlier
log.error("attribute not found: " + attr_name)
self.log.error("attribute not found: " + attr_name)
raise HTTPError(404)
responseItem = responseItems[0]
for k in responseItem:
Expand All @@ -1992,7 +1994,7 @@ def put(self):
attr_name = self.getRequestName()
if attr_name is None:
msg = "Bad Request: attribute name not supplied"
log.info(msg)
self.log.info(msg)
raise HTTPError(400, reason=msg)

body = None
Expand All @@ -2001,7 +2003,7 @@ def put(self):
except ValueError as e:
msg = "JSON Parser Error"
try:
msg += ": " + e.message
msg += ": " + str(e)
except AttributeError:
pass # no message property

Expand Down Expand Up @@ -2231,7 +2233,7 @@ def get(self):
try:
limit = int(limit)
except ValueError:
log.info("expected int type for limit")
self.log.info("expected int type for limit")
raise HTTPError(400)
marker = self.get_query_argument("Marker", None)

Expand Down Expand Up @@ -2281,7 +2283,7 @@ def post(self):
try:
body = json_decode(self.request.body)
except ValueError as e:
msg = "JSON Parser Error: " + e.message
msg = "JSON Parser Error: " + str(e)
self.log.info(msg)
raise HTTPError(400, reason=msg)

Expand Down Expand Up @@ -2400,7 +2402,7 @@ def post(self):

if self.request.uri != '/datasets':
msg = "Method not Allowed: invalid datasets post request"
log.info(msg)
self.log.info(msg)
raise HTTPError(405, reason=msg) # Method not allowed

self.isWritable(self.filePath)
Expand All @@ -2413,7 +2415,7 @@ def post(self):
try:
body = json_decode(self.request.body)
except ValueError as e:
msg = "JSON Parser Error: " + e.message
msg = "JSON Parser Error: " + str(e)
self.log.info(msg)
raise HTTPError(400, reason=msg)

Expand Down Expand Up @@ -2461,7 +2463,7 @@ def post(self):
pass # can use as is
else:
msg = "Bad Request: maxdims is invalid"
log.info(msg)
self.log.info(msg)
raise HTTPError(400, reason=msg)

# validate shape
Expand Down Expand Up @@ -2561,7 +2563,7 @@ def get(self):
limit = int(limit)
except ValueError:
msg = "Bad Request: expected int type for Limit"
log.info(msg)
self.log.info(msg)
raise HTTPError(400, reason=msg)
marker = self.get_query_argument("Marker", None)

Expand Down Expand Up @@ -2601,7 +2603,7 @@ def post(self):

if self.request.uri != '/datatypes':
msg = "Method not Allowed: invalid URI"
log.info(msg)
self.log.info(msg)
raise HTTPError(405, reason=msg) # Method not allowed


Expand All @@ -2611,7 +2613,7 @@ def post(self):
try:
body = json_decode(self.request.body)
except ValueError as e:
msg = "JSON Parser Error: " + e.message
msg = "JSON Parser Error: " + str(e)
self.log.info(msg)
raise HTTPError(400, reason=msg)

Expand Down
5 changes: 3 additions & 2 deletions server/tocUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# distribution tree. If you do not have access to this file, you may #
# request a copy from help@hdfgroup.org. #
##############################################################################
import errno
import os
import os.path as op
import re
Expand Down Expand Up @@ -102,7 +103,7 @@ def addTocEntry(domain, filePath, userid=None):
if userid is not None:
acl = db.getAcl(group_uuid, userid)
if not acl['create']:
self.log.info("unauthorized access to group:" + group_uuid)
db.log.info("unauthorized access to group:" + group_uuid)
raise IOError(errno.EACCES) # unauthorized
log.info("createExternalLink -- uuid %s, domain: %s, linkName: %s", group_uuid, domain, linkName)
db.createExternalLink(group_uuid, domain, '/', linkName)
Expand All @@ -112,7 +113,7 @@ def addTocEntry(domain, filePath, userid=None):
if userid is not None:
acl = db.getAcl(group_uuid, userid)
if not acl['create']:
self.log.info("unauthorized access to group:" + group_uuid)
db.log.info("unauthorized access to group:" + group_uuid)
raise IOError(errno.EACCES) # unauthorized
# create subgroup and link to parent group
subgroup_uuid = db.createGroup()
Expand Down