Skip to content

Commit 5760840

Browse files
test
1 parent c4c3a18 commit 5760840

4 files changed

Lines changed: 68 additions & 89 deletions

File tree

src/opengeodeweb_back/routes/blueprint_routes.py

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -558,71 +558,71 @@ def import_project() -> flask.Response:
558558
return flask.make_response({"snapshot": snapshot}, 200)
559559

560560

561-
@routes.route(
562-
schemas_dict["import_extension"]["route"],
563-
methods=schemas_dict["import_extension"]["methods"],
564-
)
565-
def import_extension() -> flask.Response:
566-
"""Import a .vext extension file and extract its contents."""
567-
utils_functions.validate_request(flask.request, schemas_dict["import_extension"])
568-
569-
if "file" not in flask.request.files:
570-
flask.abort(400, "No .vext file provided under 'file'")
571-
572-
vext_file = flask.request.files["file"]
573-
assert vext_file.filename is not None
574-
filename = werkzeug.utils.secure_filename(os.path.basename(vext_file.filename))
575-
576-
if not filename.lower().endswith(".vext"):
577-
flask.abort(400, "Uploaded file must be a .vext")
578-
579-
# Create extensions directory in the data folder
580-
extensions_folder = flask.current_app.config["EXTENSIONS_FOLDER_PATH"]
581-
os.makedirs(extensions_folder, exist_ok=True)
582-
583-
extension_name = (
584-
filename.rsplit("-", 1)[0] if "-" in filename else filename.replace(".vext", "")
585-
)
586-
extension_path = os.path.join(extensions_folder, extension_name)
587-
588-
# Remove existing extension if present
589-
if os.path.exists(extension_path):
590-
shutil.rmtree(extension_path)
591-
592-
os.makedirs(extension_path, exist_ok=True)
593-
594-
# Extract the .vext file
595-
vext_file.stream.seek(0)
596-
with zipfile.ZipFile(vext_file.stream) as zip_archive:
597-
zip_archive.extractall(extension_path)
598-
599-
# Look for the backend executable and frontend JS
600-
backend_executable = None
601-
frontend_file = None
602-
603-
for file in os.listdir(extension_path):
604-
file_path = os.path.join(extension_path, file)
605-
if os.path.isfile(file_path):
606-
if file.endswith(".es.js"):
607-
frontend_file = file_path
608-
elif not file.endswith(".js") and not file.endswith(".css"):
609-
backend_executable = file_path
610-
os.chmod(backend_executable, 0o755)
611-
612-
if not frontend_file:
613-
flask.abort(400, "Invalid .vext file: missing frontend JavaScript")
614-
if not backend_executable:
615-
flask.abort(400, "Invalid .vext file: missing backend executable")
616-
617-
assert frontend_file is not None
618-
with open(frontend_file, "r", encoding="utf-8") as f:
619-
frontend_content = f.read()
620-
621-
return flask.make_response(
622-
{
623-
"extension_name": extension_name,
624-
"frontend_content": frontend_content,
625-
"backend_path": backend_executable,
626-
},
627-
200,
628-
)
561+
# @routes.route(
562+
# schemas_dict["import_extension"]["route"],
563+
# methods=schemas_dict["import_extension"]["methods"],
564+
# )
565+
# def import_extension() -> flask.Response:
566+
# """Import a .vext extension file and extract its contents."""
567+
# utils_functions.validate_request(flask.request, schemas_dict["import_extension"])
568+
569+
# if "file" not in flask.request.files:
570+
# flask.abort(400, "No .vext file provided under 'file'")
571+
572+
# vext_file = flask.request.files["file"]
573+
# assert vext_file.filename is not None
574+
# filename = werkzeug.utils.secure_filename(os.path.basename(vext_file.filename))
575+
576+
# if not filename.lower().endswith(".vext"):
577+
# flask.abort(400, "Uploaded file must be a .vext")
578+
579+
# # Create extensions directory in the data folder
580+
# extensions_folder = flask.current_app.config["EXTENSIONS_FOLDER_PATH"]
581+
# os.makedirs(extensions_folder, exist_ok=True)
582+
583+
# extension_name = (
584+
# filename.rsplit("-", 1)[0] if "-" in filename else filename.replace(".vext", "")
585+
# )
586+
# extension_path = os.path.join(extensions_folder, extension_name)
587+
588+
# # Remove existing extension if present
589+
# if os.path.exists(extension_path):
590+
# shutil.rmtree(extension_path)
591+
592+
# os.makedirs(extension_path, exist_ok=True)
593+
594+
# # Extract the .vext file
595+
# vext_file.stream.seek(0)
596+
# with zipfile.ZipFile(vext_file.stream) as zip_archive:
597+
# zip_archive.extractall(extension_path)
598+
599+
# # Look for the backend executable and frontend JS
600+
# backend_executable = None
601+
# frontend_file = None
602+
603+
# for file in os.listdir(extension_path):
604+
# file_path = os.path.join(extension_path, file)
605+
# if os.path.isfile(file_path):
606+
# if file.endswith(".es.js"):
607+
# frontend_file = file_path
608+
# elif not file.endswith(".js") and not file.endswith(".css"):
609+
# backend_executable = file_path
610+
# os.chmod(backend_executable, 0o755)
611+
612+
# if not frontend_file:
613+
# flask.abort(400, "Invalid .vext file: missing frontend JavaScript")
614+
# if not backend_executable:
615+
# flask.abort(400, "Invalid .vext file: missing backend executable")
616+
617+
# assert frontend_file is not None
618+
# with open(frontend_file, "r", encoding="utf-8") as f:
619+
# frontend_content = f.read()
620+
621+
# return flask.make_response(
622+
# {
623+
# "extension_name": extension_name,
624+
# "frontend_content": frontend_content,
625+
# "backend_path": backend_executable,
626+
# },
627+
# 200,
628+
# )

src/opengeodeweb_back/routes/schemas/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from .kill import *
1010
from .inspect_file import *
1111
from .import_project import *
12-
from .import_extension import *
1312
from .geographic_coordinate_systems import *
1413
from .geode_objects_and_output_extensions import *
1514
from .export_project import *

src/opengeodeweb_back/routes/schemas/import_extension.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/opengeodeweb_back/routes/schemas/import_extension.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)