diff --git a/server/app.py b/server/app.py index e0e8a85..26fbb17 100755 --- a/server/app.py +++ b/server/app.py @@ -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 @@ -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 @@ -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) @@ -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) @@ -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]: @@ -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: @@ -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) @@ -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) @@ -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) @@ -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: @@ -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 '/' @@ -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) @@ -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: @@ -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 @@ -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 @@ -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) @@ -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) @@ -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) @@ -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) @@ -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 @@ -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) @@ -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 @@ -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) diff --git a/server/tocUtil.py b/server/tocUtil.py index 3d50952..8c5da14 100755 --- a/server/tocUtil.py +++ b/server/tocUtil.py @@ -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 @@ -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) @@ -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()