X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=utils.py;h=00f6f2d200947692cfe64da9636f928ef39d5329;hb=fb1dce6f90f40705665dc615888a67e82aad798b;hp=8102773923b44128e36f2075aa50342a98784e41;hpb=66aa03745ce8fe86b2a2d555317ddf94f74e90fa;p=osm%2FRO.git diff --git a/utils.py b/utils.py old mode 100755 new mode 100644 index 81027739..00f6f2d2 --- a/utils.py +++ b/utils.py @@ -39,7 +39,7 @@ def read_file(file_to_read): f = open(file_to_read, 'r') read_data = f.read() f.close() - except Exception,e: + except Exception as e: return (False, str(e)) return (True, read_data) @@ -50,7 +50,7 @@ def write_file(file_to_write, text): f = open(file_to_write, 'w') f.write(text) f.close() - except Exception,e: + except Exception as e: return (False, str(e)) return (True, None) @@ -61,7 +61,7 @@ def format_in(http_response, schema): js_v(client_data, schema) #print "Input data: ", str(client_data) return True, client_data - except js_e.ValidationError, exc: + except js_e.ValidationError as exc: print "validate_in error, jsonschema exception ", exc.message, "at", exc.path return False, ("validate_in error, jsonschema exception ", exc.message, "at", exc.path) @@ -167,9 +167,15 @@ def convert_str2boolean(data, items): def check_valid_uuid(uuid): id_schema = {"type" : "string", "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$"} + id_schema2 = {"type" : "string", "pattern": "^[a-fA-F0-9]{32}$"} try: js_v(uuid, id_schema) return True except js_e.ValidationError: - return False + try: + js_v(uuid, id_schema2) + return True + except js_e.ValidationError: + return False + return False