g3w-admin-processing 1.2.1b1.dev1__py3-none-any.whl

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.
Files changed (80) hide show
  1. g3w_admin_processing-1.2.1b1.dev1.dist-info/METADATA +258 -0
  2. g3w_admin_processing-1.2.1b1.dev1.dist-info/RECORD +80 -0
  3. g3w_admin_processing-1.2.1b1.dev1.dist-info/WHEEL +5 -0
  4. g3w_admin_processing-1.2.1b1.dev1.dist-info/licenses/LICENSE +373 -0
  5. g3w_admin_processing-1.2.1b1.dev1.dist-info/top_level.txt +1 -0
  6. qprocessing/__init__.py +7 -0
  7. qprocessing/admin.py +21 -0
  8. qprocessing/api/__init__.py +0 -0
  9. qprocessing/api/permissions.py +41 -0
  10. qprocessing/api/views/__init__.py +4 -0
  11. qprocessing/api/views/actions.py +84 -0
  12. qprocessing/api/views/admin.py +76 -0
  13. qprocessing/api/views/models.py +219 -0
  14. qprocessing/api/views/upload.py +177 -0
  15. qprocessing/apiurls.py +64 -0
  16. qprocessing/apps.py +38 -0
  17. qprocessing/configs.py +131 -0
  18. qprocessing/forms.py +133 -0
  19. qprocessing/migrations/0001_initial.py +24 -0
  20. qprocessing/migrations/0002_auto_20230615_1609.py +23 -0
  21. qprocessing/migrations/0003_qprocessinginputupload.py +32 -0
  22. qprocessing/migrations/0004_auto_20230809_0920.py +26 -0
  23. qprocessing/migrations/0005_alter_qprocessinginputupload_user.py +21 -0
  24. qprocessing/migrations/__init__.py +0 -0
  25. qprocessing/models.py +143 -0
  26. qprocessing/receivers.py +100 -0
  27. qprocessing/sitetrees.py +31 -0
  28. qprocessing/static/qprocessing/js/components/DrawInputVectorFeatures.js +180 -0
  29. qprocessing/static/qprocessing/js/components/InputFieldChooser.js +226 -0
  30. qprocessing/static/qprocessing/js/components/InputPrjRasterLayer.js +135 -0
  31. qprocessing/static/qprocessing/js/components/InputPrjVectorLayer.js +415 -0
  32. qprocessing/static/qprocessing/js/components/ModelPanel.js +496 -0
  33. qprocessing/static/qprocessing/js/components/ModelResults.js +73 -0
  34. qprocessing/static/qprocessing/js/components/OutputFile.js +63 -0
  35. qprocessing/static/qprocessing/js/components/OutputRasterLayer.js +63 -0
  36. qprocessing/static/qprocessing/js/components/OutputVectorLayer.js +115 -0
  37. qprocessing/static/qprocessing/js/components/UploadVectorFile.js +53 -0
  38. qprocessing/static/qprocessing/js/i18n/en.js +33 -0
  39. qprocessing/static/qprocessing/js/i18n/index.js +7 -0
  40. qprocessing/static/qprocessing/js/i18n/it.js +33 -0
  41. qprocessing/static/qprocessing/js/plugin.js +122 -0
  42. qprocessing/tasks.py +136 -0
  43. qprocessing/templates/qprocessing/project_form.html +70 -0
  44. qprocessing/templates/qprocessing/projects_list.html +72 -0
  45. qprocessing/tests/__init__.py +0 -0
  46. qprocessing/tests/base.py +104 -0
  47. qprocessing/tests/data/models/qbuffer.model3 +233 -0
  48. qprocessing/tests/data/models/qintersection.model3 +288 -0
  49. qprocessing/tests/data/models/qpointspolygons.model3 +222 -0
  50. qprocessing/tests/data/models/test.model3 +321 -0
  51. qprocessing/tests/data/models/test_buffer_all_inputs.model3 +269 -0
  52. qprocessing/tests/data/models/test_buffer_layer1.model3 +201 -0
  53. qprocessing/tests/data/project_data/buildings.geojson +15 -0
  54. qprocessing/tests/data/project_data/qprocessing.gpkg +0 -0
  55. qprocessing/tests/data/qprocessing_qprocessing.qgs +2813 -0
  56. qprocessing/tests/data/qprocessing_qprocessing_attachments.zip +0 -0
  57. qprocessing/tests/data/test_qgis_328.qgs +954 -0
  58. qprocessing/tests/data/test_qgis_328_attachments.zip +0 -0
  59. qprocessing/tests/data/upload/fail_shp_to_upload.zip +0 -0
  60. qprocessing/tests/data/upload/linestring_to_upload.geojson +9 -0
  61. qprocessing/tests/data/upload/point_to_upload.geojson +10 -0
  62. qprocessing/tests/data/upload/point_to_upload_espg4326.geojson +10 -0
  63. qprocessing/tests/data/upload/point_to_upload_espg4326.qmd +26 -0
  64. qprocessing/tests/data/upload/polygon_to_upload.geojson +9 -0
  65. qprocessing/tests/data/upload/shp_to_upload.cpg +1 -0
  66. qprocessing/tests/data/upload/shp_to_upload.dbf +0 -0
  67. qprocessing/tests/data/upload/shp_to_upload.prj +1 -0
  68. qprocessing/tests/data/upload/shp_to_upload.qix +0 -0
  69. qprocessing/tests/data/upload/shp_to_upload.shp +0 -0
  70. qprocessing/tests/data/upload/shp_to_upload.shx +0 -0
  71. qprocessing/tests/data/upload/shp_to_upload.zip +0 -0
  72. qprocessing/tests/test_algorithm.py +52 -0
  73. qprocessing/tests/test_api.py +173 -0
  74. qprocessing/tests/test_api_models.py +459 -0
  75. qprocessing/urls.py +33 -0
  76. qprocessing/utils/__init__.py +0 -0
  77. qprocessing/utils/data.py +283 -0
  78. qprocessing/utils/exceptions.py +20 -0
  79. qprocessing/utils/formtypes.py +521 -0
  80. qprocessing/views.py +96 -0
@@ -0,0 +1,219 @@
1
+ # coding=utf-8
2
+ """"
3
+ .. note:: This program is free software; you can redistribute it and/or modify
4
+ it under the terms of the Mozilla Public License 2.0.
5
+
6
+ """
7
+
8
+ __author__ = 'lorenzetti@gis3w.it'
9
+ __date__ = '2023-06-09'
10
+ __copyright__ = 'Copyright 2015 - 2023, Gis3w'
11
+ __license__ = 'MPL 2.0'
12
+
13
+
14
+ from django.conf import settings
15
+ from django.utils.translation import gettext_lazy as _
16
+ from django.http import HttpResponse, JsonResponse
17
+ from rest_framework.views import APIView
18
+ from rest_framework.response import Response
19
+ from rest_framework.exceptions import APIException
20
+ from huey.contrib.djhuey import HUEY
21
+ from huey.exceptions import TaskException
22
+ from huey_monitor.models import TaskModel
23
+ from core.api.views import G3WAPIView
24
+ from core.api.authentication import CsrfExemptSessionAuthentication
25
+ from usersmanage.utils import get_viewers_for_object, get_users_for_object, get_user_groups_for_object
26
+ from usersmanage.configs import G3W_VIEWER2, G3W_VIEWER1
27
+ from usersmanage.forms import label_users
28
+ from qdjango.models import Project
29
+ from qprocessing.utils.data import QProcessingModel
30
+ from qprocessing.tasks import run_model_task, run_model, run_model_celery_task
31
+ from qprocessing.models import QProcessingProject
32
+ from qprocessing.api.permissions import RunModelPermission
33
+
34
+ from cryptography.fernet import Fernet
35
+
36
+ import zipfile
37
+ import os
38
+ import io
39
+
40
+
41
+ class QProcessingRunModelView(G3WAPIView):
42
+
43
+ authentication_classes = (
44
+ CsrfExemptSessionAuthentication,
45
+ )
46
+
47
+ permission_classes = (
48
+ RunModelPermission,
49
+ )
50
+
51
+ def post(self, request, **kwargs):
52
+ """
53
+ :param qprocessingproject_pk: int, qprocessing.QProcessingProject model instance pk
54
+ :param project_pk: int, qdjango.Project model instance pk
55
+ """
56
+
57
+ # Asynchronous run
58
+ if settings.QPROCESSING_ASYNC_RUN:
59
+
60
+ task = run_model_task(kwargs, request.data, **{'user': request.user})
61
+
62
+ # Test celery
63
+ # class tsk:
64
+ # pass
65
+ # task = tsk()
66
+ # task.id = run_model_celery_task.delay(kwargs, request.data, **{'user_pk': request.user.pk})
67
+
68
+ self.results.results.update({
69
+ 'task_id': task.id
70
+ })
71
+
72
+ # Synchronous run
73
+ else:
74
+
75
+ try:
76
+
77
+ res = run_model(kwargs, request.data, **{'user': request.user})
78
+ self.results.results.update({
79
+ 'data': res
80
+ })
81
+ except Exception as e:
82
+ raise APIException(e)
83
+
84
+ return Response(self.results.results)
85
+
86
+
87
+
88
+ class QProcessingRunInfoTaskView(G3WAPIView):
89
+ """
90
+ QProcessing view to get progess state ok a huey/celery task.
91
+ """
92
+
93
+ def get(self, request, task_id):
94
+
95
+ #TODO: add code for celery tasks.
96
+
97
+ try:
98
+
99
+ # Try to retrieve the task result, may throw an exception
100
+ try:
101
+ result = HUEY.result(task_id)
102
+ ret_status = 200
103
+ except TaskException:
104
+ result = None
105
+ ret_status = 500
106
+
107
+ task_model = TaskModel.objects.get(task_id=task_id)
108
+ progress_info = task_model.progress_info
109
+
110
+ try:
111
+ progress_percentage = int(
112
+ 100 * progress_info[0] / task_model.total)
113
+ except:
114
+ progress_percentage = 0
115
+
116
+ try:
117
+ return JsonResponse({
118
+ 'status': task_model.state.signal_name,
119
+ 'exception': task_model.state.exception_line,
120
+ 'progress': progress_percentage,
121
+ 'task_result': result
122
+ }, status=ret_status)
123
+ except:
124
+ return JsonResponse({
125
+ 'status': 'error',
126
+ 'exception': 'Error retrieving task informations',
127
+ 'progress': 0,
128
+ 'task_result': result,
129
+ }, status=500)
130
+
131
+ except TaskModel.DoesNotExist:
132
+
133
+ # Handle pending
134
+ pending_task_ids = [task.id for task in HUEY.pending()]
135
+
136
+ if task_id in pending_task_ids:
137
+ return JsonResponse({'result': True, 'status': 'pending'})
138
+
139
+ return JsonResponse({'result': False, 'error': _('Task not found!')}, status=404)
140
+
141
+ class QProcessingDownLoadOutputView(G3WAPIView):
142
+
143
+ permission_classes = (
144
+ RunModelPermission,
145
+ )
146
+
147
+ # Extensions for create zip file
148
+ shp_extentions = ('.shp', '.shx', '.dbf', '.prj')
149
+
150
+ def _create_zip_file(self, down_path, filename):
151
+ """
152
+ Make a zip file with shape files and send by django reponse.
153
+ """
154
+
155
+ # Case shp file
156
+ # Create a zip file
157
+ # ---------------------------------------------------
158
+
159
+ path = os.path.dirname(down_path)
160
+ filename_noext = filename.split('.')[0]
161
+ filenames = ["{}{}".format(filename_noext, ftype)
162
+ for ftype in self.shp_extentions]
163
+
164
+ zip_filename = "{}.zip".format(filename_noext)
165
+
166
+ # Open BytesIO to grab in-memory ZIP contents
167
+ s = io.BytesIO()
168
+
169
+ # The zip compressor
170
+ zf = zipfile.ZipFile(s, "w")
171
+
172
+ for fpath in filenames:
173
+
174
+ # Add file, at correct path
175
+ ftoadd = os.path.join(path, fpath)
176
+ if os.path.exists(ftoadd):
177
+ zf.write(ftoadd, fpath)
178
+
179
+ # Must close zip for all contents to be written
180
+ zf.close()
181
+
182
+ # Grab ZIP file from in-memory, make response with correct MIME-type
183
+ response = HttpResponse(
184
+ s.getvalue(), content_type="application/x-zip-compressed")
185
+ response['Content-Disposition'] = 'attachment; filename=%s' % zip_filename
186
+ response.set_cookie('fileDownload', 'true')
187
+
188
+ return response
189
+
190
+ def get(self, request, qprocessingproject_pk, project_pk, encpath):
191
+ """
192
+ Get encrypted path, download and return file if exists
193
+ """
194
+
195
+ # Get path
196
+ f = Fernet(settings.QPROCESSING_CRYPTO_KEY)
197
+ down_path = f.decrypt(encpath.encode()).decode()
198
+ filename = down_path.split('/')[-1]
199
+ ext = filename.split('.')[-1].lower()
200
+
201
+ # Get content type by extension
202
+ if ext == 'shp':
203
+
204
+ # Custom response for shp
205
+ return self._create_zip_file(down_path, filename)
206
+ elif ext == 'geojson':
207
+ content_type = 'application/json'
208
+ elif ext == 'gpkg':
209
+ content_type = 'application/geopackage+sqlite3'
210
+ elif ext == 'sqlite':
211
+ content_type = 'application / vnd.sqlite3'
212
+ else:
213
+ content_type = 'application/octet-stream'
214
+
215
+
216
+ response = HttpResponse(open(down_path, 'rb'), content_type=f'{content_type}')
217
+ response['Content-Disposition'] = f'attachment; filename="{filename}"'
218
+ return response
219
+
@@ -0,0 +1,177 @@
1
+ # coding=utf-8
2
+ """" API REST for upload processing input file
3
+ .. note:: This program is free software; you can redistribute it and/or modify
4
+ it under the terms of the Mozilla Public License 2.0.
5
+
6
+ """
7
+
8
+ __author__ = "lorenzetti@gis3w.it"
9
+ __date__ = "2023-08-09"
10
+ __copyright__ = "Copyright 2015 - 2023, Gis3w"
11
+ __license__ = "MPL 2.0"
12
+
13
+ from django.conf import settings
14
+ from django.utils.decorators import method_decorator
15
+ from django.views.decorators.csrf import csrf_exempt
16
+ from django.http.response import HttpResponseServerError
17
+ from django.core.files import File
18
+ from django.core.files.storage import FileSystemStorage
19
+ from rest_framework.response import Response
20
+ from core.api.views import G3WAPIView
21
+ from core.api.authentication import CsrfExemptSessionAuthentication
22
+ from qprocessing.api.permissions import RunModelPermission
23
+ from qprocessing.models import QProcessingInputUpload, QProcessingProject
24
+ from qprocessing.utils.formtypes import MAPPING_QPROCESSINGTYPE_FORMTYPE, QProcessingFormTypeException
25
+
26
+ from zipfile import ZipFile
27
+ import os
28
+ import tempfile
29
+
30
+ #Try to fix
31
+ try:
32
+ os.path.sep = os.sep
33
+ except:
34
+ pass
35
+
36
+ # Create custom exception
37
+
38
+ class QProcessingInputUploadValidationException(Exception):
39
+ pass
40
+
41
+ class QProcessingInputUploadView(G3WAPIView):
42
+ """
43
+ Upload View
44
+ """
45
+
46
+ authentication_classes = (
47
+ CsrfExemptSessionAuthentication,
48
+ )
49
+
50
+ permission_classes = (
51
+ RunModelPermission,
52
+ )
53
+
54
+
55
+ def post(self, request, *args, **kwargs):
56
+
57
+ response_status = 200
58
+ try:
59
+ if not request.FILES:
60
+ return Exception('No FILES are uploaded!')
61
+
62
+ to_ret = {}
63
+
64
+ # Get QProcessingProject and input name
65
+ try:
66
+ self.qpp = QProcessingProject.objects.get(pk=kwargs['qprocessingproject_pk'])
67
+ except:
68
+ raise Exception('QProcessingProject instance not found!')
69
+
70
+ try:
71
+ self.qpm = self.qpp.get_qprocessingmodel()
72
+ self.qpi = self.qpm.get_qgsprocessingparameter(kwargs['input_name'])
73
+ except:
74
+ raise Exception(f"{kwargs['input_name']} input not found into the model!")
75
+
76
+ # get files
77
+ for file_field, file in request.FILES.items():
78
+ to_ret[file_field] = self.handle_file(file, **kwargs)
79
+
80
+ self.results.update({
81
+ 'data': to_ret
82
+ })
83
+
84
+ except QProcessingInputUploadValidationException as e:
85
+ self.results.result = False
86
+ self.results.update({"error": str(e)})
87
+ response_status = 400
88
+
89
+ except Exception as e:
90
+ self.results.result = False
91
+ self.results.update({"error": str(e)})
92
+ response_status = 500
93
+
94
+
95
+ return Response(self.results.results, status=response_status)
96
+
97
+ def handle_file(self, f, **kwargs):
98
+
99
+
100
+ # Validate by ext
101
+ # -------------------------------------------------
102
+ ext = os.path.splitext(f.name)[-1][1:].lower()
103
+ formats = [frm['value'] for frm in settings.QPROCESSING_INPUT_UPLOAD_VECTOR_FORMATS]
104
+ if ext not in formats:
105
+ raise QProcessingInputUploadValidationException(
106
+ f"File type not allowed: {ext}. "
107
+ f'Allowed formats are: {", ".join(formats)}'
108
+ )
109
+
110
+ # Save file
111
+ # -------------------------------------------------
112
+ save_path = (
113
+ f"{self.request.user.pk}/"
114
+ if hasattr(self.request, "user") and not self.request.user.is_anonymous
115
+ else f"nouser/"
116
+ )
117
+ save_path += "uploads/"
118
+ absolute_save_path = f"{settings.QPROCESSING_INPUT_UPLOAD_PATH}{save_path}"
119
+
120
+ if not os.path.isdir(absolute_save_path):
121
+ os.makedirs(absolute_save_path)
122
+
123
+ # Zip case for shp files
124
+ # --------------------------------------------------
125
+ if ext == 'zip':
126
+ zipf = ZipFile(f, mode='r')
127
+
128
+ # Check for shape files list
129
+ zip_filelist = [os.path.splitext(zf.filename)[-1][1:].lower() for zf in zipf.infolist()]
130
+ diff = list(set(settings.QPROCESSING_INPUT_SHP_EXTS) - set(zip_filelist))
131
+ diff.sort()
132
+ if len(diff):
133
+ raise QProcessingInputUploadValidationException(
134
+ f"Zip file for shape files is not correct. "
135
+ f'Missing the following files type: {", ".join(diff)}'
136
+ )
137
+
138
+ # Unzip
139
+ for zf in zipf.infolist():
140
+
141
+ # Get path for QProcessingInputUpload
142
+ if os.path.splitext(zf.filename)[-1][1:].lower() == 'shp':
143
+ path = f"{save_path}{zf.filename}"
144
+
145
+ zipf.extractall(path=absolute_save_path)
146
+ zipf.close()
147
+
148
+ else:
149
+ File(f)
150
+ storage = FileSystemStorage(location=settings.QPROCESSING_INPUT_UPLOAD_PATH, base_url=save_path)
151
+ path = storage.save('{}/{}'.format(save_path, f.name), f)
152
+
153
+
154
+ # Check input data by type
155
+ # --------------------------------------------------------------
156
+ try:
157
+ dop = self.qpm.model.parameterDefinition(self.qpi.parameterName())
158
+ vmap = dop.toVariantMap()
159
+ ftype = MAPPING_QPROCESSINGTYPE_FORMTYPE[vmap['parameter_type']](**vmap)
160
+ ftype.validate_type(f"{settings.QPROCESSING_INPUT_UPLOAD_PATH}{path}")
161
+ except QProcessingFormTypeException as e:
162
+ raise QProcessingInputUploadValidationException(e)
163
+
164
+
165
+ # Save data into db
166
+ # -------------------------------------------------
167
+ qpia = QProcessingInputUpload.objects.create(
168
+ user=self.request.user if not self.request.user.is_anonymous else None,
169
+ name=path.split('/')[-1],
170
+ qpp_id=kwargs['qprocessingproject_pk'],
171
+ input_name=kwargs['input_name']
172
+ )
173
+
174
+ return qpia.uuid
175
+
176
+
177
+
qprocessing/apiurls.py ADDED
@@ -0,0 +1,64 @@
1
+ # coding=utf-8
2
+ """"
3
+ .. note:: This program is free software; you can redistribute it and/or modify
4
+ it under the terms of the Mozilla Public License 2.0.
5
+
6
+ """
7
+
8
+ __author__ = 'lorenzetti@gis3w.it'
9
+ __date__ = '2023-06-09'
10
+ __copyright__ = 'Copyright 2015 - 2023, Gis3w'
11
+ __license__ = 'MPL 2.0'
12
+
13
+ from django.urls import path
14
+ from django.contrib.auth.decorators import login_required
15
+ from .api.views import (
16
+ QProcessingRunModelView,
17
+ QProcessingRunInfoTaskView,
18
+ QProcessingDownLoadOutputView,
19
+ QProcessingProjectViewerUsersView,
20
+ QProcessingActionFieldsView,
21
+ QProcessingInputUploadView
22
+ )
23
+ from .configs import (
24
+ __BASE_RUN_MODEL_URL,
25
+ __BASE_TASK_INFO_URL,
26
+ __BASE_OUTPUT_URL,
27
+ __BASE_ACTION_URL,
28
+ __BASE_UPLOAD_URL
29
+ )
30
+
31
+ urlpatterns = [
32
+ # G3W-CLIENT API url:
33
+ # ------------------------------------------------------
34
+ path(f'{__BASE_RUN_MODEL_URL[1:]}<int:qprocessingproject_pk>/<int:project_pk>/',
35
+ QProcessingRunModelView.as_view(),
36
+ name='qprocessing-run-model'),
37
+
38
+ # Use for asyncronous task
39
+ path(f'{__BASE_TASK_INFO_URL[1:]}<str:task_id>/',
40
+ QProcessingRunInfoTaskView.as_view(),
41
+ name='qprocessing-infotask'),
42
+
43
+ # Outputs
44
+ path(f'{__BASE_OUTPUT_URL[1:]}<int:qprocessingproject_pk>/<int:project_pk>/<str:encpath>/',
45
+ QProcessingDownLoadOutputView.as_view(),
46
+ name='qprocessing-download-output'),
47
+
48
+ # Actions: filter_fields
49
+ path(f'{__BASE_ACTION_URL[1:]}fields/<int:project_id>/<str:qgs_layer_id>/',
50
+ QProcessingActionFieldsView.as_view(),
51
+ name='qprocessing-action-fields'),
52
+
53
+ # Actions: upload input file
54
+ path(f'{__BASE_UPLOAD_URL[1:]}<int:qprocessingproject_pk>/<int:project_pk>/<str:input_name>/',
55
+ QProcessingInputUploadView.as_view(),
56
+ name='qprocessing-action-input-upload'),
57
+
58
+ # G3W-ADMIN API url:
59
+ # ------------------------------------------------------
60
+ # For form users
61
+ path('jx/project/viewer_users/',
62
+ login_required(QProcessingProjectViewerUsersView.as_view()),
63
+ name='qprocessing-viewer-users'),
64
+ ]
qprocessing/apps.py ADDED
@@ -0,0 +1,38 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class QprocessingConfig(AppConfig):
5
+ default_auto_field = 'django.db.models.BigAutoField'
6
+ name = 'qprocessing'
7
+
8
+ def ready(self):
9
+
10
+ # Import signals receivers
11
+ from . import receivers
12
+
13
+ # Initialize processing
14
+ from qdjango.apps import QGS_APPLICATION
15
+ import os
16
+ import sys
17
+ from qgis.analysis import QgsNativeAlgorithms
18
+
19
+ sys.path.append(os.path.join(QGS_APPLICATION.prefixPath(),
20
+ 'share', 'qgis', 'python', 'plugins'))
21
+
22
+ import processing
23
+ from processing.core.Processing import Processing
24
+ Processing.initialize()
25
+ from processing.algs.gdal.GdalAlgorithmProvider import GdalAlgorithmProvider
26
+ QGS_APPLICATION.processingRegistry().addProvider(
27
+ QgsNativeAlgorithms(QGS_APPLICATION.processingRegistry()))
28
+ QGS_APPLICATION.processingRegistry().addProvider(
29
+ GdalAlgorithmProvider())
30
+
31
+ from django.conf import settings
32
+ from qprocessing import configs
33
+
34
+ for a in dir(configs):
35
+ if not a.startswith('__') and not hasattr(settings, a):
36
+ setattr(settings, a, getattr(configs, a))
37
+
38
+
qprocessing/configs.py ADDED
@@ -0,0 +1,131 @@
1
+ # coding=utf-8
2
+ """" base configs QProcessing module
3
+ .. note:: This program is free software; you can redistribute it and/or modify
4
+ it under the terms of the Mozilla Public License 2.0.
5
+
6
+ """
7
+
8
+ __author__ = 'lorenzetti@gis3w.it'
9
+ __date__ = '2023-06-07'
10
+ __copyright__ = 'Copyright 2015 - 2023, Gis3w'
11
+ __license__ = 'MPL 2.0'
12
+
13
+ # Module internal settings
14
+ # -------------------------------
15
+ __BASE_RUN_MODEL_URL = '/api/run/'
16
+ __BASE_TASK_INFO_URL = '/api/infotask/'
17
+ __BASE_OUTPUT_URL = '/api/download/'
18
+ __BASE_ACTION_URL = '/api/action/'
19
+ __BASE_UPLOAD_URL = '/api/upload/'
20
+
21
+
22
+ # Customizable settings
23
+ # -------------------------------
24
+
25
+ # Qprocessing asyncronous run model, by default False set to True
26
+ # for run asyncronous model
27
+ QPROCESSING_ASYNC_RUN = False
28
+
29
+ # Qprocessing path directory for model output files
30
+ QPROCESSING_OUTPUT_PATH = '/tmp/'
31
+ QPROCESSING_INPUT_UPLOAD_PATH = QPROCESSING_OUTPUT_PATH
32
+ QPROCESSING_OUTPUT_VECTOR_FORMAT_DEFAULT = 'geojson'
33
+ QPROCESSING_OUTPUT_RASTER_FORMAT_DEFAULT = 'tiff'
34
+ QPROCESSING_OUTPUT_FILE_FORMAT_DEFAULT = 'pdf'
35
+ QPROCESSING_OUTPUT_HTML_FORMAT_DEFAULT = 'html'
36
+
37
+ QPROCESSING_INPUT_SHP_EXTS = ['shp', 'shx', 'prj', 'dbf', 'shx']
38
+
39
+ # Formats available for input upload
40
+ QPROCESSING_INPUT_UPLOAD_VECTOR_FORMATS = [
41
+ {
42
+ 'value': 'zip',
43
+ 'key': 'Shapefile'
44
+ },
45
+ {
46
+ 'value': 'geojson',
47
+ 'key': 'GeoJSON'
48
+ },
49
+ {
50
+ 'value': 'kml',
51
+ 'key': 'KML'
52
+ },
53
+ {
54
+ 'value': 'gpkg',
55
+ 'key': 'GeoPackage'
56
+ },
57
+ {
58
+ 'value': 'sqlite',
59
+ 'key': 'Sqlite/Spatialite'
60
+ }
61
+
62
+ ]
63
+
64
+
65
+ # For Processing form type: input/output
66
+ QPROCESSING_OUTPUT_VECTOR_FORMATS = [
67
+ {
68
+ 'value': 'shp',
69
+ 'key': 'Shapefile'
70
+ },
71
+ {
72
+ 'value': 'geojson',
73
+ 'key': 'GeoJSON'
74
+ },
75
+ {
76
+ 'value': 'kml',
77
+ 'key': 'KML'
78
+ },
79
+ {
80
+ 'value': 'kmz',
81
+ 'key': 'KMZ'
82
+ },
83
+ {
84
+ 'value': 'csv',
85
+ 'key': 'CSV'
86
+ }
87
+ #'gpkg': 'GeoPackage', # g3w-client cannot read this format
88
+ #'sqlite': 'SpatiaLite' # g3w-client cannot read this format
89
+ ]
90
+
91
+ QPROCESSING_OUTPUT_FILE_FORMATS = [
92
+ {
93
+ 'value': 'pdf',
94
+ 'key': 'PDF'
95
+ },
96
+ ]
97
+
98
+ QPROCESSING_OUTPUT_HTML_FORMATS = [
99
+ {
100
+ 'value': 'html',
101
+ 'key': 'HTML'
102
+ },
103
+ ]
104
+
105
+ QPROCESSING_OUTPUT_RASTER_FORMATS = [
106
+ {
107
+ 'value': 'vrt',
108
+ 'key': 'VRT'
109
+ },
110
+ {
111
+ 'value': 'tiff',
112
+ 'key': 'TIFF'
113
+ },
114
+ {
115
+ 'value': 'png',
116
+ 'key': 'PNG'
117
+ },
118
+ {
119
+ 'value': 'jpeg',
120
+ 'key': 'JPEG'
121
+ },
122
+ {
123
+ 'value': 'jpg',
124
+ 'key': 'JPG'
125
+ },
126
+ ]
127
+
128
+ # For download of ouputs
129
+ QPROCESSING_CRYPTO_KEY = b'aAf72grwGaZYH9R7ZaGHgSSbtQVXPplXB4wpiMsKtJM='
130
+
131
+