jaaql-middleware-python 4.32.0__tar.gz → 4.32.2__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.
Files changed (76) hide show
  1. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/PKG-INFO +1 -1
  2. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/constants.py +1 -1
  3. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/email/email_manager_service.py +48 -13
  4. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql_middleware_python.egg-info/PKG-INFO +1 -1
  5. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/LICENSE.txt +0 -0
  6. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/README.md +0 -0
  7. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/__init__.py +0 -0
  8. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/config/__init__.py +0 -0
  9. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/config/config-docker.ini +0 -0
  10. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/config/config-test.ini +0 -0
  11. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/config/config.ini +0 -0
  12. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/config_constants.py +0 -0
  13. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/db/__init__.py +0 -0
  14. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/db/db_interface.py +0 -0
  15. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/db/db_pg_interface.py +0 -0
  16. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/db/db_utils.py +0 -0
  17. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/db/db_utils_no_circ.py +0 -0
  18. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/documentation/__init__.py +0 -0
  19. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/documentation/documentation_internal.py +0 -0
  20. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/documentation/documentation_public.py +0 -0
  21. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/documentation/documentation_shared.py +0 -0
  22. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/email/__init__.py +0 -0
  23. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/email/email_manager.py +0 -0
  24. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/email/patch_ems.py +0 -0
  25. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/exceptions/__init__.py +0 -0
  26. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/exceptions/custom_http_status.py +0 -0
  27. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/exceptions/http_status_exception.py +0 -0
  28. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/exceptions/jaaql_interpretable_handled_errors.py +0 -0
  29. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/exceptions/not_yet_implement_exception.py +0 -0
  30. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/generated_constants.py +0 -0
  31. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/interpreter/__init__.py +0 -0
  32. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/interpreter/interpret_jaaql.py +0 -0
  33. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/jaaql.py +0 -0
  34. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/migrations/__init__.py +0 -0
  35. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/migrations/migrations.py +0 -0
  36. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/mvc/__init__.py +0 -0
  37. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/mvc/base_controller.py +0 -0
  38. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/mvc/base_model.py +0 -0
  39. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/mvc/controller.py +0 -0
  40. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/mvc/controller_interface.py +0 -0
  41. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/mvc/exception_queries.py +0 -0
  42. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/mvc/generated_queries.py +0 -0
  43. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/mvc/handmade_queries.py +0 -0
  44. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/mvc/model.py +0 -0
  45. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/mvc/model_interface.py +0 -0
  46. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/mvc/response.py +0 -0
  47. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/openapi/__init__.py +0 -0
  48. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/openapi/swagger_documentation.py +0 -0
  49. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/patch.py +0 -0
  50. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/scripts/01.install_domains.generated.sql +0 -0
  51. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/scripts/02.install_super_user.exceptions.sql +0 -0
  52. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/scripts/03.install_super_user.handwritten.sql +0 -0
  53. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/scripts/04.install_jaaql_data_structures.generated.sql +0 -0
  54. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/scripts/05.install_static_data.generated.sql +0 -0
  55. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/scripts/06.install_jaaql.exceptions.sql +0 -0
  56. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/scripts/ZZZZ.generated_functions_views_and_permissions.sql +0 -0
  57. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/scripts/ZZZZ.reset_references.sql +0 -0
  58. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/scripts/swagger_template.html +0 -0
  59. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/services/__init__.py +0 -0
  60. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/services/cached_canned_query_service.py +0 -0
  61. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/services/migrations_manager_service.py +0 -0
  62. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/services/patch_mms.py +0 -0
  63. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/services/patch_shared_var_service.py +0 -0
  64. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/services/shared_var_service.py +0 -0
  65. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/utilities/__init__.py +0 -0
  66. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/utilities/crypt_utils.py +0 -0
  67. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/utilities/options.py +0 -0
  68. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/utilities/utils.py +0 -0
  69. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/utilities/utils_no_project_imports.py +0 -0
  70. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql/utilities/vault.py +0 -0
  71. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql_middleware_python.egg-info/SOURCES.txt +0 -0
  72. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql_middleware_python.egg-info/dependency_links.txt +0 -0
  73. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql_middleware_python.egg-info/requires.txt +0 -0
  74. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/jaaql_middleware_python.egg-info/top_level.txt +0 -0
  75. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/setup.cfg +0 -0
  76. {jaaql_middleware_python-4.32.0 → jaaql_middleware_python-4.32.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jaaql-middleware-python
3
- Version: 4.32.0
3
+ Version: 4.32.2
4
4
  Summary: The jaaql package, allowing for rapid development and deployment of RESTful HTTP applications
5
5
  Home-page: https://github.com/JAAQL/JAAQL-middleware-python
6
6
  Author: Software Quality Measurement and Improvement bv
@@ -191,5 +191,5 @@ ROLE__postgres = "postgres"
191
191
 
192
192
  PROTOCOL__postgres = "postgresql://"
193
193
 
194
- VERSION = "4.32.0"
194
+ VERSION = "4.32.2"
195
195
 
@@ -1,8 +1,8 @@
1
- import os
2
1
  import traceback
3
2
  import uuid
4
3
  import time
5
4
  from http import HTTPStatus
5
+ from urllib.parse import urlparse
6
6
 
7
7
  from selenium.common.exceptions import NoSuchElementException
8
8
  from datetime import datetime
@@ -71,6 +71,11 @@ KEY__template_base = "template_base"
71
71
  QUERY__purge_rendered_documents = "DELETE FROM document_request rd USING document_template able WHERE rd.template = able.name AND completed is not null and completed > current_timestamp + interval '5 minutes' RETURNING rd.uuid as document_id, rd.create_file, 'pdf' as render_as"
72
72
  QUERY__fetch_unrendered_document = "SELECT able.content_path as url, a.base_url, 'pdf' as render_as, rd.uuid as document_id, rd.encrypted_parameters as parameters, rd.create_file, rd.encrypted_access_token as oauth_token FROM document_request rd INNER JOIN document_template able ON rd.template = able.name INNER JOIN application a ON rd.application = a.name WHERE rd.completed is null ORDER BY rd.request_timestamp LIMIT 1"
73
73
  QUERY__mark_rendered_document_completed = "UPDATE document_request SET completed = current_timestamp, file_name = :file_name, content = :content WHERE uuid = :document_id"
74
+ QUERY__mark_rendered_document_completed_with_error = "UPDATE document_request SET completed = current_timestamp WHERE uuid = :document_id"
75
+
76
+
77
+ CHROME_DEBUGGING = False
78
+
74
79
 
75
80
  class DrivenChrome:
76
81
  def __init__(self, db_interface: DBInterface, db_key: bytes, is_deployed: bool):
@@ -107,9 +112,25 @@ class DrivenChrome:
107
112
 
108
113
  return "?" + "&".join([key + "=" + quote(itm if isinstance(itm, bytes) else itm.encode("UTF-8")) for key, itm in parameters.items()])
109
114
 
110
- def chrome_page_to_pdf(self, url: str, access_token: str, parameters: dict):
115
+ def chrome_page_to_pdf(self, url: str, access_token: str, parameters: dict, document_id: str):
111
116
  with self.chrome_lock:
112
- self.driver.get(url + self.parameters_to_get_str(access_token, parameters))
117
+ origin = "{uri.scheme}://{uri.netloc}".format(uri=urlparse(url))
118
+ self.driver.execute_cdp_cmd(
119
+ "Storage.clearDataForOrigin",
120
+ {
121
+ "origin": origin,
122
+ "storageTypes": "local_storage,session_storage"
123
+ }
124
+ )
125
+
126
+ old_handle = self.driver.current_window_handle
127
+ self.driver.switch_to.new_window('tab')
128
+ self.driver.switch_to.window(old_handle)
129
+ self.driver.close()
130
+ survivor_handles = [h for h in self.driver.window_handles if h != old_handle]
131
+ self.driver.switch_to.window(survivor_handles[0])
132
+
133
+ self.driver.get(url + self.parameters_to_get_str(access_token, parameters) + "&BS_document_id=" + document_id)
113
134
  start_time = datetime.now()
114
135
  while True:
115
136
  passed = False
@@ -138,15 +159,13 @@ class DrivenChrome:
138
159
  print("CHROMEFAILURE: " + (log if isinstance(log, str) else json.dumps(log)))
139
160
 
140
161
  if time_delta_ms(start_time, datetime.now()) > TIMEOUT__attachment_render:
141
- print("Failed to render!")
142
- try:
143
- current_dom = self.driver.execute_script("return document.documentElement.outerHTML;")
144
- print("\nCURRENT <body> DOM (sanitised):\n\n\n" + current_dom)
145
- except Exception as exc:
146
- print(f"[chrome_page_to_pdf] Unable to capture DOM: {exc}")
147
162
  raise HttpStatusException(ERR__attachment_timeout_render)
163
+ else:
164
+ time.sleep(0.1)
148
165
 
149
- return filename, base64.b64decode(self.driver.execute_cdp_cmd("Page.printToPDF", self.a4_params)["data"])
166
+ pdf_data = base64.b64decode(self.driver.execute_cdp_cmd("Page.printToPDF", self.a4_params)["data"])
167
+ self.driver.execute_cdp_cmd("HeapProfiler.collectGarbage", {})
168
+ return filename, pdf_data
150
169
 
151
170
  def purge_rendered_documents(self):
152
171
  while True:
@@ -162,6 +181,7 @@ class DrivenChrome:
162
181
 
163
182
  def render_document_requests(self):
164
183
  while True:
184
+ resp = None
165
185
  try:
166
186
  resp = execute_supplied_statement_singleton(self.db_interface, QUERY__fetch_unrendered_document,
167
187
  as_objects=True,
@@ -173,7 +193,7 @@ class DrivenChrome:
173
193
 
174
194
  base_url = EmailAttachment.static_format_attached_url(resp[KG__application__base_url] + "/" + resp["url"], self.is_deployed)
175
195
 
176
- filename, content = self.chrome_page_to_pdf(base_url, resp[KEY__oauth_token], parameters)
196
+ filename, content = self.chrome_page_to_pdf(base_url, resp[KEY__oauth_token], parameters, str(resp[KEY__document_id]))
177
197
 
178
198
  inputs = {KEY__document_id: resp[KEY__document_id], KEY__content: None, KG__document_request__file_name: filename}
179
199
  if resp[KEY__create_file]:
@@ -188,6 +208,10 @@ class DrivenChrome:
188
208
  execute_supplied_statement(self.db_interface, QUERY__mark_rendered_document_completed, inputs)
189
209
  except HttpStatusException as ex:
190
210
  if ex.response_code == HTTPStatus.UNPROCESSABLE_ENTITY:
211
+ if resp is not None:
212
+ execute_supplied_statement(self.db_interface,
213
+ QUERY__mark_rendered_document_completed_with_error,
214
+ { KEY__document_id: resp[KEY__document_id] })
191
215
  time.sleep(0.25)
192
216
  else:
193
217
  traceback.print_exc()
@@ -197,7 +221,18 @@ class DrivenChrome:
197
221
  options.add_argument("--window-size=1920,1080")
198
222
  options.add_argument("--force-color-profile=srgb")
199
223
  options.add_argument("--font-render-hinting=none")
200
- options.headless = True
224
+ options.add_argument("--disable-gpu")
225
+ options.add_argument("--disable-dev-shm-usage") # ✱ stop /dev/shm exhaustion
226
+ options.add_argument("--disable-extensions")
227
+ options.add_argument("--headless=new")
228
+ if CHROME_DEBUGGING:
229
+ options.add_argument("--enable-logging=stderr")
230
+ options.add_argument("--v=1")
231
+ options.set_capability(
232
+ "goog:loggingPrefs",
233
+ {"browser": "ALL", "performance": "ALL"}
234
+ )
235
+
201
236
  service_args = []
202
237
 
203
238
  if self.is_deployed:
@@ -214,7 +249,7 @@ class DrivenChrome:
214
249
  if not content_path.endswith(".html"):
215
250
  content_path += ".html"
216
251
  content_path = current_attachment.template_base + "/" + content_path
217
- filename, content = self.chrome_page_to_pdf(content_path, current_attachment.access_token, current_attachment.parameters)
252
+ filename, content = self.chrome_page_to_pdf(content_path, current_attachment.access_token, current_attachment.parameters, str(uuid.uuid4()))
218
253
  current_attachment.content = content
219
254
  current_attachment.filename = filename
220
255
  except HttpStatusException as ex:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jaaql-middleware-python
3
- Version: 4.32.0
3
+ Version: 4.32.2
4
4
  Summary: The jaaql package, allowing for rapid development and deployment of RESTful HTTP applications
5
5
  Home-page: https://github.com/JAAQL/JAAQL-middleware-python
6
6
  Author: Software Quality Measurement and Improvement bv