OpenGeodeWeb-Back 3.1.0__tar.gz → 3.2.0rc2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {OpenGeodeWeb-Back-3.1.0/src/OpenGeodeWeb_Back.egg-info → OpenGeodeWeb-Back-3.2.0rc2}/PKG-INFO +2 -1
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/pyproject.toml +4 -1
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/requirements.txt +4 -0
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2/src/OpenGeodeWeb_Back.egg-info}/PKG-INFO +2 -1
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/src/OpenGeodeWeb_Back.egg-info/SOURCES.txt +3 -1
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/src/OpenGeodeWeb_Back.egg-info/requires.txt +1 -0
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/src/opengeodeweb_back/geode_functions.py +2 -3
- OpenGeodeWeb-Back-3.2.0rc2/src/opengeodeweb_back/routes/blueprint_routes.py +178 -0
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/tests/test_functions.py +2 -2
- OpenGeodeWeb-Back-3.2.0rc2/tests/test_routes.py +131 -0
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/LICENSE +0 -0
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/README.md +0 -0
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/setup.cfg +0 -0
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/src/OpenGeodeWeb_Back.egg-info/dependency_links.txt +0 -0
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/src/OpenGeodeWeb_Back.egg-info/top_level.txt +0 -0
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/src/opengeodeweb_back/__init__.py +0 -0
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/src/opengeodeweb_back/geode_objects.py +0 -0
- {OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/src/opengeodeweb_back/inspector_functions.py +0 -0
{OpenGeodeWeb-Back-3.1.0/src/OpenGeodeWeb_Back.egg-info → OpenGeodeWeb-Back-3.2.0rc2}/PKG-INFO
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: OpenGeodeWeb-Back
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.2.0rc2
|
4
4
|
Summary: OpenGeodeWeb-Back is an open source framework that proposes handy python functions and wrappers for the OpenGeode ecosystem
|
5
5
|
Author-email: Geode-solutions <team-web@geode-solutions.com>
|
6
6
|
Project-URL: Homepage, https://github.com/Geode-solutions/OpenGeodeWeb-Back
|
@@ -17,6 +17,7 @@ Requires-Dist: blinker==1.7.0
|
|
17
17
|
Requires-Dist: click==8.1.7
|
18
18
|
Requires-Dist: colorama==0.4.6
|
19
19
|
Requires-Dist: flask[async]==3.0.0
|
20
|
+
Requires-Dist: flask-cors==4.0.0
|
20
21
|
Requires-Dist: geode-background==7.4.9
|
21
22
|
Requires-Dist: geode-common==30.0.5
|
22
23
|
Requires-Dist: geode-conversion==5.1.7
|
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|
5
5
|
|
6
6
|
[project]
|
7
7
|
name = "OpenGeodeWeb-Back"
|
8
|
-
version = "3.
|
8
|
+
version = "3.2.0-rc.2"
|
9
9
|
dynamic = ["dependencies"]
|
10
10
|
authors = [
|
11
11
|
{ name="Geode-solutions", email="team-web@geode-solutions.com" },
|
@@ -26,6 +26,9 @@ classifiers = [
|
|
26
26
|
[tool.setuptools.dynamic]
|
27
27
|
dependencies = {file = ["requirements.txt"]}
|
28
28
|
|
29
|
+
[tool.setuptools.package-data]
|
30
|
+
'src' = ['src/*.json']
|
31
|
+
|
29
32
|
[tool.semantic_release]
|
30
33
|
version_toml = [
|
31
34
|
"pyproject.toml:project.version",
|
{OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2/src/OpenGeodeWeb_Back.egg-info}/PKG-INFO
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: OpenGeodeWeb-Back
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.2.0rc2
|
4
4
|
Summary: OpenGeodeWeb-Back is an open source framework that proposes handy python functions and wrappers for the OpenGeode ecosystem
|
5
5
|
Author-email: Geode-solutions <team-web@geode-solutions.com>
|
6
6
|
Project-URL: Homepage, https://github.com/Geode-solutions/OpenGeodeWeb-Back
|
@@ -17,6 +17,7 @@ Requires-Dist: blinker==1.7.0
|
|
17
17
|
Requires-Dist: click==8.1.7
|
18
18
|
Requires-Dist: colorama==0.4.6
|
19
19
|
Requires-Dist: flask[async]==3.0.0
|
20
|
+
Requires-Dist: flask-cors==4.0.0
|
20
21
|
Requires-Dist: geode-background==7.4.9
|
21
22
|
Requires-Dist: geode-common==30.0.5
|
22
23
|
Requires-Dist: geode-conversion==5.1.7
|
{OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/src/OpenGeodeWeb_Back.egg-info/SOURCES.txt
RENAMED
@@ -11,4 +11,6 @@ src/opengeodeweb_back/__init__.py
|
|
11
11
|
src/opengeodeweb_back/geode_functions.py
|
12
12
|
src/opengeodeweb_back/geode_objects.py
|
13
13
|
src/opengeodeweb_back/inspector_functions.py
|
14
|
-
|
14
|
+
src/opengeodeweb_back/routes/blueprint_routes.py
|
15
|
+
tests/test_functions.py
|
16
|
+
tests/test_routes.py
|
{OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/src/opengeodeweb_back/geode_functions.py
RENAMED
@@ -1,16 +1,15 @@
|
|
1
1
|
# Standard library imports
|
2
|
-
import base64
|
3
2
|
import os
|
4
3
|
import time
|
5
4
|
import threading
|
6
5
|
import uuid
|
6
|
+
import zipfile
|
7
7
|
|
8
8
|
# Third party imports
|
9
9
|
import flask
|
10
10
|
import opengeode_geosciences as og_gs
|
11
11
|
import opengeode as og
|
12
12
|
import pkg_resources
|
13
|
-
import werkzeug
|
14
13
|
from jsonschema import validate
|
15
14
|
from jsonschema.exceptions import ValidationError
|
16
15
|
|
@@ -311,7 +310,7 @@ def send_file(upload_folder, saved_files, new_file_name):
|
|
311
310
|
mimetype = "application/octet-binary"
|
312
311
|
else:
|
313
312
|
mimetype = "application/zip"
|
314
|
-
new_file_name =
|
313
|
+
new_file_name = os.path.splitext(new_file_name)[0] + ".zip"
|
315
314
|
with zipfile.ZipFile(os.path.join(upload_folder, new_file_name), "w") as zipObj:
|
316
315
|
for saved_file_path in saved_files:
|
317
316
|
zipObj.write(
|
@@ -0,0 +1,178 @@
|
|
1
|
+
# Standard library imports
|
2
|
+
import json
|
3
|
+
import os
|
4
|
+
|
5
|
+
# Third party imports
|
6
|
+
import flask
|
7
|
+
import flask_cors
|
8
|
+
from .. import geode_functions
|
9
|
+
import werkzeug
|
10
|
+
|
11
|
+
|
12
|
+
routes = flask.Blueprint("routes", __name__)
|
13
|
+
flask_cors.CORS(routes)
|
14
|
+
|
15
|
+
|
16
|
+
schemas = os.path.join(os.path.dirname(__file__), "schemas")
|
17
|
+
|
18
|
+
with open(
|
19
|
+
os.path.join(schemas, "allowed_files.json"),
|
20
|
+
"r",
|
21
|
+
) as file:
|
22
|
+
allowed_files_json = json.load(file)
|
23
|
+
|
24
|
+
|
25
|
+
@routes.route(
|
26
|
+
allowed_files_json["route"],
|
27
|
+
methods=allowed_files_json["methods"],
|
28
|
+
)
|
29
|
+
def allowed_files():
|
30
|
+
geode_functions.validate_request(flask.request, allowed_files_json)
|
31
|
+
extensions = geode_functions.list_input_extensions(flask.request.json["key"])
|
32
|
+
return {"status": 200, "extensions": extensions}
|
33
|
+
|
34
|
+
|
35
|
+
with open(
|
36
|
+
os.path.join(schemas, "upload_file.json"),
|
37
|
+
"r",
|
38
|
+
) as file:
|
39
|
+
upload_file_json = json.load(file)
|
40
|
+
|
41
|
+
|
42
|
+
@routes.route(
|
43
|
+
upload_file_json["route"],
|
44
|
+
methods=upload_file_json["methods"],
|
45
|
+
)
|
46
|
+
def upload_file():
|
47
|
+
if flask.request.method == "OPTIONS":
|
48
|
+
return flask.make_response({}, 200)
|
49
|
+
|
50
|
+
UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
|
51
|
+
if not os.path.exists(UPLOAD_FOLDER):
|
52
|
+
os.mkdir(UPLOAD_FOLDER)
|
53
|
+
file = flask.request.files["file"]
|
54
|
+
filename = werkzeug.utils.secure_filename(os.path.basename(file.filename))
|
55
|
+
file.save(os.path.join(UPLOAD_FOLDER, filename))
|
56
|
+
return flask.make_response({"message": "File uploaded"}, 201)
|
57
|
+
|
58
|
+
|
59
|
+
with open(
|
60
|
+
os.path.join(schemas, "allowed_objects.json"),
|
61
|
+
"r",
|
62
|
+
) as file:
|
63
|
+
allowed_objects_json = json.load(file)
|
64
|
+
|
65
|
+
|
66
|
+
@routes.route(
|
67
|
+
allowed_objects_json["route"],
|
68
|
+
methods=allowed_objects_json["methods"],
|
69
|
+
)
|
70
|
+
def allowed_objects():
|
71
|
+
if flask.request.method == "OPTIONS":
|
72
|
+
return flask.make_response({}, 200)
|
73
|
+
|
74
|
+
UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
|
75
|
+
geode_functions.validate_request(flask.request, allowed_objects_json)
|
76
|
+
file_absolute_path = os.path.join(UPLOAD_FOLDER, flask.request.json["filename"])
|
77
|
+
allowed_objects = geode_functions.list_geode_objects(
|
78
|
+
file_absolute_path, flask.request.json["key"]
|
79
|
+
)
|
80
|
+
return flask.make_response({"allowed_objects": allowed_objects}, 200)
|
81
|
+
|
82
|
+
|
83
|
+
with open(
|
84
|
+
os.path.join(schemas, "missing_files.json"),
|
85
|
+
"r",
|
86
|
+
) as file:
|
87
|
+
missing_files_json = json.load(file)
|
88
|
+
|
89
|
+
|
90
|
+
@routes.route(
|
91
|
+
missing_files_json["route"],
|
92
|
+
methods=missing_files_json["methods"],
|
93
|
+
)
|
94
|
+
def missing_files():
|
95
|
+
UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
|
96
|
+
geode_functions.validate_request(flask.request, missing_files_json)
|
97
|
+
|
98
|
+
missing_files = geode_functions.missing_files(
|
99
|
+
flask.request.json["input_geode_object"],
|
100
|
+
os.path.join(UPLOAD_FOLDER, flask.request.json["filename"]),
|
101
|
+
)
|
102
|
+
has_missing_files = missing_files.has_missing_files()
|
103
|
+
|
104
|
+
mandatory_files = []
|
105
|
+
for mandatory_file in missing_files.mandatory_files:
|
106
|
+
mandatory_files.append(os.path.basename(mandatory_file))
|
107
|
+
|
108
|
+
additional_files = []
|
109
|
+
for additional_file in missing_files.additional_files:
|
110
|
+
additional_files.append(os.path.basename(additional_file))
|
111
|
+
|
112
|
+
return flask.make_response(
|
113
|
+
{
|
114
|
+
"has_missing_files": has_missing_files,
|
115
|
+
"mandatory_files": mandatory_files,
|
116
|
+
"additional_files": additional_files,
|
117
|
+
},
|
118
|
+
200,
|
119
|
+
)
|
120
|
+
|
121
|
+
|
122
|
+
with open(
|
123
|
+
os.path.join(schemas, "geographic_coordinate_systems.json"),
|
124
|
+
"r",
|
125
|
+
) as file:
|
126
|
+
geographic_coordinate_systems_json = json.load(file)
|
127
|
+
|
128
|
+
|
129
|
+
@routes.route(
|
130
|
+
geographic_coordinate_systems_json["route"],
|
131
|
+
methods=geographic_coordinate_systems_json["methods"],
|
132
|
+
)
|
133
|
+
def crs_converter_geographic_coordinate_systems():
|
134
|
+
geode_functions.validate_request(flask.request, geographic_coordinate_systems_json)
|
135
|
+
infos = geode_functions.geographic_coordinate_systems(
|
136
|
+
flask.request.json["input_geode_object"]
|
137
|
+
)
|
138
|
+
crs_list = []
|
139
|
+
|
140
|
+
for info in infos:
|
141
|
+
crs = {}
|
142
|
+
crs["name"] = info.name
|
143
|
+
crs["code"] = info.code
|
144
|
+
crs["authority"] = info.authority
|
145
|
+
crs_list.append(crs)
|
146
|
+
|
147
|
+
return flask.make_response({"crs_list": crs_list}, 200)
|
148
|
+
|
149
|
+
|
150
|
+
with open(
|
151
|
+
os.path.join(schemas, "geode_objects_and_output_extensions.json"),
|
152
|
+
"r",
|
153
|
+
) as file:
|
154
|
+
geode_objects_and_output_extensions_json = json.load(file)
|
155
|
+
|
156
|
+
|
157
|
+
@routes.route(
|
158
|
+
geode_objects_and_output_extensions_json["route"],
|
159
|
+
methods=geode_objects_and_output_extensions_json["methods"],
|
160
|
+
)
|
161
|
+
def geode_objects_and_output_extensions():
|
162
|
+
UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
|
163
|
+
geode_functions.validate_request(
|
164
|
+
flask.request, geode_objects_and_output_extensions_json
|
165
|
+
)
|
166
|
+
data = geode_functions.load(
|
167
|
+
flask.request.json["input_geode_object"],
|
168
|
+
os.path.join(UPLOAD_FOLDER, flask.request.json["filename"]),
|
169
|
+
)
|
170
|
+
geode_objects_and_output_extensions = (
|
171
|
+
geode_functions.geode_objects_output_extensions(
|
172
|
+
flask.request.json["input_geode_object"], data
|
173
|
+
)
|
174
|
+
)
|
175
|
+
return flask.make_response(
|
176
|
+
{"geode_objects_and_output_extensions": geode_objects_and_output_extensions},
|
177
|
+
200,
|
178
|
+
)
|
@@ -83,7 +83,7 @@ def test_load():
|
|
83
83
|
viewable_file_path = geode_functions.save_viewable(
|
84
84
|
geode_object,
|
85
85
|
data,
|
86
|
-
os.path.abspath(f"
|
86
|
+
os.path.abspath(f"./output"),
|
87
87
|
uu_id,
|
88
88
|
)
|
89
89
|
os.remove(viewable_file_path)
|
@@ -109,7 +109,7 @@ def test_load():
|
|
109
109
|
saved_files = geode_functions.save(
|
110
110
|
output_geode_object,
|
111
111
|
data,
|
112
|
-
os.path.abspath(f"
|
112
|
+
os.path.abspath(f"./output"),
|
113
113
|
filename,
|
114
114
|
)
|
115
115
|
assert type(saved_files) is list
|
@@ -0,0 +1,131 @@
|
|
1
|
+
import os
|
2
|
+
import base64
|
3
|
+
from werkzeug.datastructures import FileStorage
|
4
|
+
|
5
|
+
|
6
|
+
def test_allowed_files(client):
|
7
|
+
route = f"/allowed_files"
|
8
|
+
response = client.post(route, json={"key": None})
|
9
|
+
assert response.status_code == 200
|
10
|
+
extensions = response.json["extensions"]
|
11
|
+
assert type(extensions) is list
|
12
|
+
for extension in extensions:
|
13
|
+
assert type(extension) is str
|
14
|
+
|
15
|
+
|
16
|
+
def test_allowed_objects(client):
|
17
|
+
route = f"/allowed_objects"
|
18
|
+
|
19
|
+
def get_full_data():
|
20
|
+
return {
|
21
|
+
"filename": "corbi.og_brep",
|
22
|
+
"key": None,
|
23
|
+
}
|
24
|
+
|
25
|
+
# Normal test with filename 'corbi.og_brep'
|
26
|
+
response = client.post(route, json=get_full_data())
|
27
|
+
assert response.status_code == 200
|
28
|
+
allowed_objects = response.json["allowed_objects"]
|
29
|
+
assert type(allowed_objects) is dict
|
30
|
+
for allowed_object in allowed_objects:
|
31
|
+
assert type(allowed_object) is str
|
32
|
+
|
33
|
+
for key, value in get_full_data().items():
|
34
|
+
json = get_full_data()
|
35
|
+
json.pop(key)
|
36
|
+
response = client.post(route, json=json)
|
37
|
+
assert response.status_code == 400
|
38
|
+
error_description = response.json["description"]
|
39
|
+
assert error_description == f"Validation error: '{key}' is a required property"
|
40
|
+
|
41
|
+
|
42
|
+
def test_upload_file(client):
|
43
|
+
response = client.put(
|
44
|
+
f"/upload_file",
|
45
|
+
data={"file": FileStorage(open("./tests/corbi.og_brep", "rb"))},
|
46
|
+
)
|
47
|
+
|
48
|
+
assert response.status_code == 201
|
49
|
+
|
50
|
+
|
51
|
+
def test_missing_files(client):
|
52
|
+
route = f"/missing_files"
|
53
|
+
|
54
|
+
def get_full_data():
|
55
|
+
return {
|
56
|
+
"input_geode_object": "BRep",
|
57
|
+
"filename": "corbi.og_brep",
|
58
|
+
}
|
59
|
+
|
60
|
+
json = get_full_data()
|
61
|
+
response = client.post(
|
62
|
+
route,
|
63
|
+
json=json,
|
64
|
+
)
|
65
|
+
|
66
|
+
assert response.status_code == 200
|
67
|
+
has_missing_files = response.json["has_missing_files"]
|
68
|
+
mandatory_files = response.json["mandatory_files"]
|
69
|
+
additional_files = response.json["additional_files"]
|
70
|
+
assert type(has_missing_files) is bool
|
71
|
+
assert type(mandatory_files) is list
|
72
|
+
assert type(additional_files) is list
|
73
|
+
|
74
|
+
for key, value in get_full_data().items():
|
75
|
+
json = get_full_data()
|
76
|
+
json.pop(key)
|
77
|
+
response = client.post(route, json=json)
|
78
|
+
assert response.status_code == 400
|
79
|
+
error_description = response.json["description"]
|
80
|
+
assert error_description == f"Validation error: '{key}' is a required property"
|
81
|
+
|
82
|
+
|
83
|
+
def test_geographic_coordinate_systems(client):
|
84
|
+
route = f"/geographic_coordinate_systems"
|
85
|
+
|
86
|
+
# Normal test with geode_object 'BRep'
|
87
|
+
response = client.post(route, json={"input_geode_object": "BRep"})
|
88
|
+
assert response.status_code == 200
|
89
|
+
crs_list = response.json["crs_list"]
|
90
|
+
assert type(crs_list) is list
|
91
|
+
for crs in crs_list:
|
92
|
+
assert type(crs) is dict
|
93
|
+
|
94
|
+
# Test without geode_object
|
95
|
+
response = client.post(route, json={})
|
96
|
+
assert response.status_code == 400
|
97
|
+
error_message = response.json["description"]
|
98
|
+
assert (
|
99
|
+
error_message == "Validation error: 'input_geode_object' is a required property"
|
100
|
+
)
|
101
|
+
|
102
|
+
|
103
|
+
def test_geode_objects_and_output_extensions(client):
|
104
|
+
route = "/geode_objects_and_output_extensions"
|
105
|
+
|
106
|
+
def get_full_data():
|
107
|
+
return {
|
108
|
+
"input_geode_object": "BRep",
|
109
|
+
"filename": "corbi.og_brep",
|
110
|
+
}
|
111
|
+
|
112
|
+
response = client.post(route, json=get_full_data())
|
113
|
+
|
114
|
+
assert response.status_code == 200
|
115
|
+
geode_objects_and_output_extensions = response.json[
|
116
|
+
"geode_objects_and_output_extensions"
|
117
|
+
]
|
118
|
+
assert type(geode_objects_and_output_extensions) is dict
|
119
|
+
for geode_object, values in geode_objects_and_output_extensions.items():
|
120
|
+
assert type(values) is dict
|
121
|
+
for output_extension, value in values.items():
|
122
|
+
assert type(value) is dict
|
123
|
+
assert type(value["is_saveable"]) is bool
|
124
|
+
|
125
|
+
# Test without input_geode_object
|
126
|
+
response = client.post(route, json={})
|
127
|
+
assert response.status_code == 400
|
128
|
+
error_message = response.json["description"]
|
129
|
+
assert (
|
130
|
+
error_message == "Validation error: 'input_geode_object' is a required property"
|
131
|
+
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/src/OpenGeodeWeb_Back.egg-info/top_level.txt
RENAMED
File without changes
|
File without changes
|
{OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/src/opengeodeweb_back/geode_objects.py
RENAMED
File without changes
|
{OpenGeodeWeb-Back-3.1.0 → OpenGeodeWeb-Back-3.2.0rc2}/src/opengeodeweb_back/inspector_functions.py
RENAMED
File without changes
|