c2cwsgiutils 6.2.0.dev77__tar.gz → 6.2.0.dev79__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 (67) hide show
  1. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/PKG-INFO +1 -1
  2. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/auth.py +2 -2
  3. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/config_utils.py +1 -1
  4. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/db.py +2 -2
  5. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/db_maintenance_view.py +1 -1
  6. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/debug/_listeners.py +1 -1
  7. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/debug/_views.py +1 -1
  8. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/health_check.py +1 -1
  9. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/index.py +1 -1
  10. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/loader.py +1 -1
  11. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/prometheus.py +11 -4
  12. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/scripts/genversion.py +1 -1
  13. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/scripts/stats_db.py +2 -2
  14. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/setup_process.py +1 -1
  15. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/version.py +1 -1
  16. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/pyproject.toml +2 -2
  17. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/LICENSE +0 -0
  18. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/README.md +0 -0
  19. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/__init__.py +0 -0
  20. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/acceptance/__init__.py +0 -0
  21. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/acceptance/connection.py +0 -0
  22. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/acceptance/image.py +0 -0
  23. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/acceptance/package-lock.json +0 -0
  24. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/acceptance/package.json +0 -0
  25. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/acceptance/print.py +0 -0
  26. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/acceptance/screenshot.js +0 -0
  27. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/acceptance/utils.py +0 -0
  28. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/broadcast/__init__.py +0 -0
  29. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/broadcast/interface.py +0 -0
  30. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/broadcast/local.py +0 -0
  31. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/broadcast/redis.py +0 -0
  32. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/broadcast/utils.py +0 -0
  33. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/client_info.py +0 -0
  34. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/coverage_setup.py +0 -0
  35. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/debug/__init__.py +0 -0
  36. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/debug/utils.py +0 -0
  37. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/errors.py +0 -0
  38. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/logging_view.py +0 -0
  39. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/models_graph.py +0 -0
  40. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/pretty_json.py +0 -0
  41. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/profiler.py +0 -0
  42. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/py.typed +0 -0
  43. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/pyramid.py +0 -0
  44. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/pyramid_logging.py +0 -0
  45. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/redis_stats.py +0 -0
  46. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/redis_utils.py +0 -0
  47. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/request_tracking/__init__.py +0 -0
  48. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/request_tracking/_sql.py +0 -0
  49. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/scripts/__init__.py +0 -0
  50. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/scripts/test_print.py +0 -0
  51. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/sentry.py +0 -0
  52. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/services.py +0 -0
  53. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/sql_profiler/__init__.py +0 -0
  54. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/sql_profiler/_impl.py +0 -0
  55. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/sqlalchemylogger/README.md +0 -0
  56. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/sqlalchemylogger/__init__.py +0 -0
  57. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/sqlalchemylogger/_filters.py +0 -0
  58. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/sqlalchemylogger/_models.py +0 -0
  59. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/sqlalchemylogger/examples/__init__.py +0 -0
  60. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/sqlalchemylogger/examples/example.py +0 -0
  61. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/sqlalchemylogger/handlers.py +0 -0
  62. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/static/favicon-16x16.png +0 -0
  63. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/static/favicon-32x32.png +0 -0
  64. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/stats_pyramid/__init__.py +0 -0
  65. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/stats_pyramid/_db_spy.py +0 -0
  66. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/stats_pyramid/_pyramid_spy.py +0 -0
  67. {c2cwsgiutils-6.2.0.dev77 → c2cwsgiutils-6.2.0.dev79}/c2cwsgiutils/templates/index.html.mako +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: c2cwsgiutils
3
- Version: 6.2.0.dev77
3
+ Version: 6.2.0.dev79
4
4
  Summary: Common utilities for Camptocamp WSGI applications
5
5
  License: BSD-2-Clause
6
6
  Keywords: geo,gis,sqlalchemy,orm,wsgi
@@ -59,7 +59,7 @@ class AuthConfig(TypedDict, total=False):
59
59
  def get_expected_secret(request: pyramid.request.Request) -> str:
60
60
  """Return the secret expected from the client."""
61
61
  settings = request.registry.settings
62
- return cast(str, env_or_settings(settings, SECRET_ENV, SECRET_PROP, default=False))
62
+ return cast("str", env_or_settings(settings, SECRET_ENV, SECRET_PROP, default=False))
63
63
 
64
64
 
65
65
  def _hash_secret(secret: str) -> str:
@@ -117,7 +117,7 @@ def _is_auth_user_github(request: pyramid.request.Request) -> tuple[bool, UserDe
117
117
  if cookie:
118
118
  try:
119
119
  return True, cast(
120
- UserDetails,
120
+ "UserDetails",
121
121
  jwt.decode(
122
122
  cookie,
123
123
  env_or_settings(
@@ -9,7 +9,7 @@ import pyramid.config
9
9
 
10
10
  def get_base_path(config: pyramid.config.Configurator) -> str:
11
11
  """Get the base path of all the views."""
12
- return cast(str, env_or_config(config, "C2C_BASE_PATH", "c2c.base_path", "/c2c"))
12
+ return cast("str", env_or_config(config, "C2C_BASE_PATH", "c2c.base_path", "/c2c"))
13
13
 
14
14
 
15
15
  def env_or_config(
@@ -236,8 +236,8 @@ class SessionFactory(_sessionmaker):
236
236
  def engine_name(self, readwrite: bool) -> str:
237
237
  """Get the engine name."""
238
238
  if readwrite:
239
- return cast(str, self.rw_engine.c2c_name) # type: ignore[attr-defined]
240
- return cast(str, self.ro_engine.c2c_name) # type: ignore[attr-defined]
239
+ return cast("str", self.rw_engine.c2c_name) # type: ignore[attr-defined]
240
+ return cast("str", self.ro_engine.c2c_name) # type: ignore[attr-defined]
241
241
 
242
242
  def __call__( # type: ignore[override]
243
243
  self,
@@ -34,7 +34,7 @@ def includeme(config: pyramid.config.Configurator) -> None:
34
34
 
35
35
  def _db_maintenance(request: pyramid.request.Request) -> Mapping[str, Any]:
36
36
  auth.auth_view(request)
37
- readonly_param = cast(str, request.params.get("readonly"))
37
+ readonly_param = cast("str", request.params.get("readonly"))
38
38
  if readonly_param is not None:
39
39
  readonly = readonly_param.lower() == "true"
40
40
 
@@ -92,7 +92,7 @@ def _dump_memory_impl(
92
92
  cache = linecache.cache
93
93
  result[analyze_type]["biggest_objects"] = sorted(
94
94
  ({"filename": k, "size_kb": get_size(v)} for k, v in cache.items()),
95
- key=lambda i: -(cast(int, i["size_kb"])),
95
+ key=lambda i: -(cast("int", i["size_kb"])),
96
96
  )
97
97
  else:
98
98
  biggest_objects.reverse()
@@ -185,7 +185,7 @@ def _add_view(
185
185
 
186
186
  def _dump_memory_maps(request: pyramid.request.Request) -> list[dict[str, Any]]:
187
187
  auth.auth_view(request)
188
- return sorted(dump_memory_maps(), key=lambda i: cast(int, -i.get("pss_kb", 0)))
188
+ return sorted(dump_memory_maps(), key=lambda i: cast("int", -i.get("pss_kb", 0)))
189
189
 
190
190
 
191
191
  def _show_refs(request: pyramid.request.Request) -> pyramid.response.Response:
@@ -117,7 +117,7 @@ class _OldBinding(_Binding):
117
117
  self.prev_bind = None
118
118
 
119
119
  def name(self) -> str:
120
- return cast(str, self.engine.c2c_name) # type: ignore[attr-defined]
120
+ return cast("str", self.engine.c2c_name) # type: ignore[attr-defined]
121
121
 
122
122
  def __enter__(self) -> _scoped_session:
123
123
  self.prev_bind = self.session.bind # type: ignore[assignment]
@@ -459,7 +459,7 @@ def _github_login_callback(request: pyramid.request.Request) -> dict[str, Any]:
459
459
  "c2c-auth-jwt",
460
460
  ),
461
461
  jwt.encode(
462
- cast(dict[str, Any], user_information),
462
+ cast("dict[str, Any]", user_information),
463
463
  env_or_settings(
464
464
  settings,
465
465
  GITHUB_AUTH_SECRET_ENV,
@@ -14,7 +14,7 @@ class Loader(BaseLoader): # type: ignore[misc]
14
14
  def _get_defaults(self, defaults: dict[str, str] | None = None) -> dict[str, str]:
15
15
  d = get_config_defaults()
16
16
  d.update(defaults or {})
17
- return cast(dict[str, str], super()._get_defaults(d))
17
+ return cast("dict[str, str]", super()._get_defaults(d))
18
18
 
19
19
  def __repr__(self) -> str:
20
20
  """Get the object representation."""
@@ -3,8 +3,9 @@
3
3
  import os
4
4
  import re
5
5
  import resource
6
- from collections.abc import Generator, Iterable
7
- from typing import Any, TypedDict, cast
6
+ from collections.abc import Generator
7
+ from pathlib import Path
8
+ from typing import TYPE_CHECKING, Any, TypedDict, cast
8
9
 
9
10
  import prometheus_client
10
11
  import prometheus_client.core
@@ -16,6 +17,10 @@ import pyramid.config
16
17
  from c2cwsgiutils import broadcast, redis_utils
17
18
  from c2cwsgiutils.debug.utils import dump_memory_maps
18
19
 
20
+ if TYPE_CHECKING:
21
+ from collections.abc import Iterable
22
+
23
+
19
24
  PSUTILS = True
20
25
  try:
21
26
  import psutil
@@ -136,7 +141,7 @@ class MultiProcessCustomCollector(prometheus_client.registry.Collector):
136
141
  for channel in MULTI_PROCESS_COLLECTOR_BROADCAST_CHANNELS:
137
142
  result = broadcast.broadcast(channel, expect_answers=True)
138
143
  if result is not None:
139
- results.extend(cast(Iterable[list[SerializedMetric]], result))
144
+ results.extend(cast("Iterable[list[SerializedMetric]]", result))
140
145
  return _deserialize_collected_data(results)
141
146
 
142
147
 
@@ -192,7 +197,9 @@ class MemoryMapCollector(prometheus_client.registry.Collector):
192
197
  )
193
198
 
194
199
  for pid in (
195
- [p for p in os.listdir("/proc/") if _NUMBER_RE.match(p)] if self.pids is None else self.pids
200
+ [p.name for p in Path("/proc/").iterdir() if _NUMBER_RE.match(p.name)]
201
+ if self.pids is None
202
+ else self.pids
196
203
  ):
197
204
  for e in dump_memory_maps(pid):
198
205
  gauge.add_metric([pid, e["name"]], e[self.memory_type + "_kb"] * 1024)
@@ -23,7 +23,7 @@ def _get_package_version(comp: str) -> tuple[str | None, str | None]:
23
23
  src_matcher = _SRC_VERSION_RE.match(comp)
24
24
  matcher = src_matcher or _VERSION_RE.match(comp)
25
25
  if matcher:
26
- return cast(tuple[str, str], matcher.groups())
26
+ return cast("tuple[str, str]", matcher.groups())
27
27
  if len(comp) > 0 and comp[:3] != "-e ":
28
28
  print("Cannot parse package version: " + comp)
29
29
  return None, None
@@ -307,14 +307,14 @@ def main() -> None:
307
307
  success = False
308
308
  args = _parse_args()
309
309
  c2cwsgiutils.setup_process.init(args.config_uri)
310
- for _ in range(int(os.environ.get("C2CWSGIUTILS_STATS_DB_TRYNUMBER", 10))):
310
+ for _ in range(int(os.environ.get("C2CWSGIUTILS_STATS_DB_TRYNUMBER", "10"))):
311
311
  try:
312
312
  _do_dtats_db(args)
313
313
  success = True
314
314
  break
315
315
  except: # pylint: disable=bare-except
316
316
  _LOG.exception("Exception during run")
317
- time.sleep(float(os.environ.get("C2CWSGIUTILS_STATS_DB_SLEEP", 1)))
317
+ time.sleep(float(os.environ.get("C2CWSGIUTILS_STATS_DB_SLEEP", "1")))
318
318
 
319
319
  if not success:
320
320
  _LOG.error("Not in success, exiting")
@@ -102,4 +102,4 @@ def bootstrap_application(
102
102
  loader = get_config_loader(config_uri)
103
103
  loader.setup_logging(options)
104
104
  logging.getLogger(__name__).info("Loading the application from %s", config_uri)
105
- return cast(PyramidEnv, bootstrap(config_uri, options=options))
105
+ return cast("PyramidEnv", bootstrap(config_uri, options=options))
@@ -88,7 +88,7 @@ def _read_versions() -> dict[str, dict[str, str]]:
88
88
  """Read the version."""
89
89
  with _VERSIONS_PATH.open(encoding="utf-8") as file:
90
90
  versions = json.load(file)
91
- return cast(dict[str, dict[str, str]], versions)
91
+ return cast("dict[str, dict[str, str]]", versions)
92
92
 
93
93
 
94
94
  def get_version() -> str | None:
@@ -7,7 +7,7 @@ convention = "numpy"
7
7
 
8
8
  [tool.poetry]
9
9
  name = "c2cwsgiutils"
10
- version = "6.2.0.dev77"
10
+ version = "6.2.0.dev79"
11
11
  description = "Common utilities for Camptocamp WSGI applications"
12
12
  readme = "README.md"
13
13
  authors = ["Camptocamp <info@camptocamp.com>"]
@@ -187,7 +187,7 @@ test_images = ["scikit-image"]
187
187
 
188
188
  [tool.poetry.group.dev.dependencies]
189
189
  # pylint = { version = "2.15.6" }
190
- prospector = { version = "1.15.3", extras = ["with_bandit", "with_mypy", "with_pyroma", "with_ruff"] }
190
+ prospector = { version = "1.16.0", extras = ["with_bandit", "with_mypy", "with_pyroma", "with_ruff"] }
191
191
  prospector-profile-duplicated = "1.10.5"
192
192
  prospector-profile-utils = "1.22.3"
193
193
  junit2html = "31.0.2"