c2cwsgiutils 6.2.0.dev27__py3-none-any.whl → 6.2.0.dev29__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.
@@ -68,12 +68,7 @@ def _dump_memory_impl(
68
68
  and not (FILES_FIELDS - set(obj["globals"].keys()))
69
69
  ):
70
70
  python_internal = True
71
- if (
72
- python_internal
73
- and not python_internals_map
74
- or not python_internal
75
- and python_internals_map
76
- ):
71
+ if python_internal != python_internals_map:
77
72
  continue
78
73
  size = get_size(obj) / 1024
79
74
  if len(biggest_objects) < limit or size > biggest_objects[0][0]:
@@ -49,7 +49,7 @@ def _dump_memory(request: pyramid.request.Request) -> list[Mapping[str, Any]]:
49
49
  auth.auth_view(request)
50
50
  limit = int(request.params.get("limit", "30"))
51
51
  analyze_type = request.params.get("analyze_type")
52
- python_internals_map = request.params.get("python_internals_map", "0").lower() in ("", "1", "true", "on")
52
+ python_internals_map = request.params.get("python_internals_map", "0").lower() in ("1", "true", "on")
53
53
  result = broadcast.broadcast(
54
54
  "c2c_dump_memory",
55
55
  params={"limit": limit, "analyze_type": analyze_type, "python_internals_map": python_internals_map},
@@ -77,7 +77,7 @@ def _dump_memory_diff(request: pyramid.request.Request) -> list[Any]:
77
77
 
78
78
  # warm-up run
79
79
  try:
80
- if "no_warmup" not in request.params:
80
+ if request.params.get("no_warmup", "0").lower() in ("1", "true", "on"):
81
81
  request.invoke_subrequest(sub_request)
82
82
  except Exception: # nosec # pylint: disable=broad-except
83
83
  pass
c2cwsgiutils/index.py CHANGED
@@ -122,8 +122,20 @@ def input_(
122
122
  if type_ is None:
123
123
  if isinstance(value, int):
124
124
  type_ = "number"
125
+ elif isinstance(value, bool):
126
+ type_ = "checkbox"
125
127
  else:
126
128
  type_ = "text"
129
+ if type_ == "checkbox":
130
+ checked = " checked" if value else ""
131
+ return f"""
132
+ <div class="form-check">
133
+ <input class="form-check-input" type="checkbox" name="{name}" value="true" id="{id_}"{checked}>
134
+ <label class="form-check-label" for="{id_}">
135
+ {label}
136
+ </label>
137
+ </div>"""
138
+
127
139
  result = ""
128
140
  if label is not None:
129
141
  result += f'<div class="row mb-3"><label class="col-sm-2 col-form-label" for="{id_}">{label}</label>'
@@ -201,7 +213,7 @@ def _index(request: pyramid.request.Request) -> dict[str, str]:
201
213
  def _versions(request: pyramid.request.Request) -> str:
202
214
  versions_url = _url(request, "c2c_versions")
203
215
  if versions_url:
204
- return section("Versions", paragraph(link(versions_url, "Get")), sep=False)
216
+ return section("Versions " + link(versions_url, "Get"), sep=False)
205
217
  else:
206
218
  return ""
207
219
 
@@ -280,6 +292,7 @@ def _logging(request: pyramid.request.Request) -> str:
280
292
  def _debug(request: pyramid.request.Request) -> str:
281
293
  dump_memory_url = _url(request, "c2c_debug_memory")
282
294
  if dump_memory_url:
295
+ as_dot = 'as <a href="https://graphviz.org/">dot diagram</a>, can be open with <a href="https://pypi.org/project/xdot/">xdot</a>'
283
296
  return section(
284
297
  " ".join(
285
298
  [
@@ -289,32 +302,42 @@ def _debug(request: pyramid.request.Request) -> str:
289
302
  link(_url(request, "c2c_debug_memory_maps"), "Mapped memory"),
290
303
  ]
291
304
  ),
305
+ '<h2>Memory usage<span style="font-size: 0.5em;">, with <a href="https://mg.pov.lt/objgraph/">objgraph</a></span></h2>',
306
+ "<p>Runs the garbage collector and dumps the memory usage as JSON.</p>",
292
307
  form(
293
308
  dump_memory_url,
294
309
  input_("limit", value=30),
295
310
  input_("analyze_type"),
311
+ input_("python_internals_map", type_="checkbox"),
296
312
  button("Dump memory usage"),
297
313
  ),
314
+ f"<p>Runs the garbage collector and dumps the memory refs {as_dot}.</p>",
298
315
  form(
299
316
  _url(request, "c2c_debug_show_refs"),
300
317
  input_("analyze_type", value="gunicorn.app.wsgiapp.WSGIApplication"),
301
- input_("max_depth", value=3),
302
- input_("too_many", value=10),
318
+ input_("analyze_id", type_="number"),
319
+ input_("max_depth", type_="number", value=3),
320
+ input_("too_many", type_="number", value=10),
303
321
  input_("min_size_kb", type_="number"),
304
322
  button("Object refs"),
305
323
  ),
324
+ "<p>Runs the garbage collector, query the path, runs the garbage collector again, get the memory diff as JSON.</p>",
306
325
  form(
307
326
  _url(request, "c2c_debug_memory_diff"),
308
327
  input_("path"),
309
328
  input_("limit", value=30),
329
+ input_("no_warmup", type_="checkbox"),
310
330
  button("Memory diff"),
311
331
  ),
332
+ "<h2>Sleep</h2>",
312
333
  form(
313
334
  _url(request, "c2c_debug_sleep"),
314
335
  input_("time", value=1),
315
336
  button("Sleep"),
316
337
  ),
317
- form(_url(request, "c2c_debug_time"), button("Time")),
338
+ "<h2>Server times</h2>",
339
+ form(_url(request, "c2c_debug_time"), button("Get")),
340
+ "<h2>HTTP error</h2>",
318
341
  form(
319
342
  _url(request, "c2c_debug_error"),
320
343
  input_("status", value=500),
@@ -24,7 +24,7 @@
24
24
  crossorigin="anonymous"
25
25
  referrerpolicy="no-referrer"
26
26
  />
27
- <title>c2cwsgiutils tools</title>
27
+ <title>C2C WSGI Utils tools</title>
28
28
  <style>
29
29
  body {
30
30
  margin-top: 0.5rem;
@@ -32,6 +32,9 @@
32
32
  button, p {
33
33
  margin-bottom: 0.5rem;
34
34
  }
35
+ .row > h2 {
36
+ margin-top: 1rem;
37
+ }
35
38
  </style>
36
39
  </head>
37
40
  <body>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: c2cwsgiutils
3
- Version: 6.2.0.dev27
3
+ Version: 6.2.0.dev29
4
4
  Summary: Common utilities for Camptocamp WSGI applications
5
5
  Home-page: https://github.com/camptocamp/c2cwsgiutils
6
6
  License: BSD-2-Clause
@@ -19,12 +19,12 @@ c2cwsgiutils/coverage_setup.py,sha256=BrdjYUmqYl1C-gHuKA7EI5gbQs8Dtdeb2eZKtzr-5L
19
19
  c2cwsgiutils/db.py,sha256=JT5F9Dqm2r0Jsh3w3CX79ngAUtakMLpf1secfN1nQnk,16106
20
20
  c2cwsgiutils/db_maintenance_view.py,sha256=58F-p9drkhCI99GoLRPIqT5U-Pm8ckSSUEl-tNxMmjU,3088
21
21
  c2cwsgiutils/debug/__init__.py,sha256=GkYNt2fU5PFykw9HmqPEwZrF2mTJumjSu54pp38EhOM,1325
22
- c2cwsgiutils/debug/_listeners.py,sha256=RZYwQRh86rU-Vtjxc3xOZL2A8D_5LHIBd-xWAMQCrj0,4421
23
- c2cwsgiutils/debug/_views.py,sha256=rxvxxzSIiwfdRieGkR6BG4zGa3hd1e17r-GMoQOSzgM,8511
22
+ c2cwsgiutils/debug/_listeners.py,sha256=-fk3KFeB_E4m_YFXJ5MfxuqfA1sWCje9p3FH_93WfXM,4248
23
+ c2cwsgiutils/debug/_views.py,sha256=s4SmrfCRhbfyVtLd7CPFQROQJjtf4PrfSkBH-cEtEPQ,8541
24
24
  c2cwsgiutils/debug/utils.py,sha256=sIKZHQ8empzxE2OI3h7Uce8cvv4O7AD1y_VYeZfLVCA,2320
25
25
  c2cwsgiutils/errors.py,sha256=-hWLQ1qDlh9kn06-33U2c39BbOxuCvJIkBkdxriE5mo,6644
26
26
  c2cwsgiutils/health_check.py,sha256=OhfPcApBht1qtBOX8e8pdeq3QwF4FbgGkofjqpl8GvQ,20068
27
- c2cwsgiutils/index.py,sha256=km_iP4w3oMqlI04e2RIetknAVxooO5p2ThZ8LcjBaU0,16751
27
+ c2cwsgiutils/index.py,sha256=zQTp2dlb50DZy0TZOPYDxJv84kivcYirswz7rFMbSDA,17988
28
28
  c2cwsgiutils/loader.py,sha256=vU7yEobl9TlSFZwdLI2eF1ceUJ6xgiu2re31HA5sw1g,623
29
29
  c2cwsgiutils/logging_view.py,sha256=d0UkvYRGkVUMY9_vbjEzXmm8-6CCec2B43a3mJAqWyw,3370
30
30
  c2cwsgiutils/models_graph.py,sha256=q5dW_gZ5iUZCzBya5Kpy57y9oqsG-rGi9AvrXCDgYqs,2679
@@ -58,10 +58,10 @@ c2cwsgiutils/static/favicon-32x32.png,sha256=i4ucx08zAZARd8e7JTMGK-gb5WcOmyuDN6I
58
58
  c2cwsgiutils/stats_pyramid/__init__.py,sha256=alSRhpCa5Kh9JnMnR5XqcMqr5wyL8ogROprrfsIl_qU,786
59
59
  c2cwsgiutils/stats_pyramid/_db_spy.py,sha256=A61t6VKIrRRIjbyZTldmAUl_Q3ZDVFYqyxjuntzmllc,2919
60
60
  c2cwsgiutils/stats_pyramid/_pyramid_spy.py,sha256=mRiOmQXV9x8JjkGV4MsaC7sD3qO6dWUTog0bharLLD0,3517
61
- c2cwsgiutils/templates/index.html.mako,sha256=Ey9ppHLe-eFGYXYPV5Z2WbMBSif86sYPiTviksnG7TI,1362
61
+ c2cwsgiutils/templates/index.html.mako,sha256=cK8qGBDeQG5SiJJCfvL0oKpgacr7dPKx634AAQivmjA,1416
62
62
  c2cwsgiutils/version.py,sha256=1ghPu-aKMJdfCSUrxgBENNqNQ-7JMKJr6tS14dDmW4Q,3110
63
- c2cwsgiutils-6.2.0.dev27.dist-info/LICENSE,sha256=r7ueGz9Fl2Bv3rmeQy0DEtohLmAiufRaCuv6Y5fyNhE,1304
64
- c2cwsgiutils-6.2.0.dev27.dist-info/METADATA,sha256=FzdiFUvSshMPqfGefTnWFHwB6Gdd6OjOvRJHxOwGUjg,34461
65
- c2cwsgiutils-6.2.0.dev27.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
66
- c2cwsgiutils-6.2.0.dev27.dist-info/entry_points.txt,sha256=ujgqMTL1awN9qDg8WXmrF7m0fgR-hslUM6zKH86pvy0,703
67
- c2cwsgiutils-6.2.0.dev27.dist-info/RECORD,,
63
+ c2cwsgiutils-6.2.0.dev29.dist-info/LICENSE,sha256=r7ueGz9Fl2Bv3rmeQy0DEtohLmAiufRaCuv6Y5fyNhE,1304
64
+ c2cwsgiutils-6.2.0.dev29.dist-info/METADATA,sha256=VGE_wRigebpoupW5REBis2XB5fZ9T0izFkLJOIsZVBs,34461
65
+ c2cwsgiutils-6.2.0.dev29.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
66
+ c2cwsgiutils-6.2.0.dev29.dist-info/entry_points.txt,sha256=ujgqMTL1awN9qDg8WXmrF7m0fgR-hslUM6zKH86pvy0,703
67
+ c2cwsgiutils-6.2.0.dev29.dist-info/RECORD,,