vortex-cli 8.4.0__tar.gz → 8.4.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 (62) hide show
  1. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/PKG-INFO +12 -3
  2. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/README.md +11 -2
  3. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/pyproject.toml +1 -1
  4. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/clone.py +44 -2
  5. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/models.py +53 -2
  6. vortex_cli-8.4.2/vortex/session_store.py +67 -0
  7. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/workspace.py +4 -0
  8. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex_cli.egg-info/PKG-INFO +12 -3
  9. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex_cli.egg-info/SOURCES.txt +1 -0
  10. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/LICENSE +0 -0
  11. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/setup.cfg +0 -0
  12. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/__init__.py +0 -0
  13. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/__main__.py +0 -0
  14. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/cli.py +0 -0
  15. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/colour.py +0 -0
  16. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/__init__.py +0 -0
  17. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/agenda.py +0 -0
  18. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/app.py +0 -0
  19. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/clean.py +0 -0
  20. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/code.py +0 -0
  21. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/compile.py +0 -0
  22. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/db.py +0 -0
  23. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/diff.py +0 -0
  24. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/docs.py +0 -0
  25. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/execute.py +0 -0
  26. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/fetch.py +0 -0
  27. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/file.py +0 -0
  28. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/info.py +0 -0
  29. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/keyword.py +0 -0
  30. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/libs.py +0 -0
  31. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/log.py +0 -0
  32. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/object_.py +0 -0
  33. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/pull.py +0 -0
  34. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/search.py +0 -0
  35. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/servers.py +0 -0
  36. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/stats.py +0 -0
  37. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/use.py +0 -0
  38. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/watch.py +0 -0
  39. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/commands/weblog.py +0 -0
  40. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/constants.py +0 -0
  41. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/docs/Blackbook v2.md +0 -0
  42. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/docs/Blackbook.pdf +0 -0
  43. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/docs/index.html +0 -0
  44. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/docs/marked.min.js +0 -0
  45. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/git.py +0 -0
  46. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/lib/puakma-6.0.40.jar +0 -0
  47. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/libs.py +0 -0
  48. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/logging.py +0 -0
  49. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/main.py +0 -0
  50. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/output.py +0 -0
  51. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/registry.py +0 -0
  52. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/schedule.py +0 -0
  53. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/server_options.py +0 -0
  54. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/soap.py +0 -0
  55. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/spinner.py +0 -0
  56. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/sync.py +0 -0
  57. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/util.py +0 -0
  58. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex/webdesign.py +0 -0
  59. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex_cli.egg-info/dependency_links.txt +0 -0
  60. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex_cli.egg-info/entry_points.txt +0 -0
  61. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex_cli.egg-info/requires.txt +0 -0
  62. {vortex_cli-8.4.0 → vortex_cli-8.4.2}/vortex_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vortex_cli
3
- Version: 8.4.0
3
+ Version: 8.4.2
4
4
  Summary: Vortex CLI
5
5
  Author-email: Jordan Amos <jordan.amos@gmail.com>
6
6
  License: MIT License
@@ -113,6 +113,14 @@ While it is possible to use without it, this software has been purposefully desi
113
113
  Puakma root's disk marked (see [Server statistics](#server-statistics)); `--json` adds them
114
114
  as `disks`. It needs vortex/gateway 0.3.0, which adds them to `GET stats`; with an older
115
115
  gateway the overview says so in one line.
116
+ - **8.4.1: `vortex clone` ignores case in a TemplateName or `group/name`.** `vortex clone
117
+ ui20complete/mastercustom` clones `ui20Complete/MasterCustom`; the name must still match in
118
+ full. If two applications differ only in case, the one typed exactly wins.
119
+ - **8.4.2: vortex reuses one server session.** Every command used to start a new Puakma
120
+ session, and parallel requests each started their own, leaving thousands of idle sessions
121
+ on the server until SessionTimeout. Session cookies are now kept per server in
122
+ `config/.sessions/` (owner-only; treat them like a login) and parallel requests share one
123
+ session. Delete the file to start a new session.
116
124
 
117
125
  ## Upgrading to 8.3
118
126
 
@@ -906,8 +914,9 @@ outright is always cloned. Groups are matched the way `app list --group` matches
906
914
  case-insensitive substring - except that an exact group name always wins, so cloning
907
915
  `BetTrackr` never drags in `BetTrackrLegacy`. If a partial name still spans several groups,
908
916
  vortex stops and lists them. A bare word that is genuinely both a TemplateName and a group
909
- is refused: use `--group NAME` or the ID. References may be qualified as `SERVER:REF`
910
- (`dev:BetTrackr`).
917
+ is refused: use `--group NAME` or the ID. A TemplateName or `group/name` must match in full but
918
+ ignores case; if two applications differ only in case, the one typed exactly wins. References
919
+ may be qualified as `SERVER:REF` (`dev:BetTrackr`).
911
920
 
912
921
  ### Working with Multiple Servers
913
922
 
@@ -69,6 +69,14 @@ While it is possible to use without it, this software has been purposefully desi
69
69
  Puakma root's disk marked (see [Server statistics](#server-statistics)); `--json` adds them
70
70
  as `disks`. It needs vortex/gateway 0.3.0, which adds them to `GET stats`; with an older
71
71
  gateway the overview says so in one line.
72
+ - **8.4.1: `vortex clone` ignores case in a TemplateName or `group/name`.** `vortex clone
73
+ ui20complete/mastercustom` clones `ui20Complete/MasterCustom`; the name must still match in
74
+ full. If two applications differ only in case, the one typed exactly wins.
75
+ - **8.4.2: vortex reuses one server session.** Every command used to start a new Puakma
76
+ session, and parallel requests each started their own, leaving thousands of idle sessions
77
+ on the server until SessionTimeout. Session cookies are now kept per server in
78
+ `config/.sessions/` (owner-only; treat them like a login) and parallel requests share one
79
+ session. Delete the file to start a new session.
72
80
 
73
81
  ## Upgrading to 8.3
74
82
 
@@ -862,8 +870,9 @@ outright is always cloned. Groups are matched the way `app list --group` matches
862
870
  case-insensitive substring - except that an exact group name always wins, so cloning
863
871
  `BetTrackr` never drags in `BetTrackrLegacy`. If a partial name still spans several groups,
864
872
  vortex stops and lists them. A bare word that is genuinely both a TemplateName and a group
865
- is refused: use `--group NAME` or the ID. References may be qualified as `SERVER:REF`
866
- (`dev:BetTrackr`).
873
+ is refused: use `--group NAME` or the ID. A TemplateName or `group/name` must match in full but
874
+ ignores case; if two applications differ only in case, the one typed exactly wins. References
875
+ may be qualified as `SERVER:REF` (`dev:BetTrackr`).
867
876
 
868
877
  ### Working with Multiple Servers
869
878
 
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
 
6
6
  [project]
7
7
  name = "vortex_cli"
8
- version = "8.4.0"
8
+ version = "8.4.2"
9
9
  description = "Vortex CLI"
10
10
  requires-python = ">=3.10"
11
11
  readme = { file = "README.md", content-type = "text/markdown" }
@@ -288,6 +288,46 @@ def _fetch_apps(
288
288
  )
289
289
 
290
290
 
291
+ def _fetch_exact_apps(
292
+ server: PuakmaServer,
293
+ *,
294
+ name: str | None = None,
295
+ group: str | None = None,
296
+ template: str | None = None,
297
+ ) -> list[PuakmaApplication]:
298
+ """
299
+ Applications whose name, group and TemplateName equal the given
300
+ values, ignoring case - 'ui20complete/mastercustom' finds
301
+ 'ui20Complete/MasterCustom'. Should the server have applications
302
+ differing only in case, the exact-case match wins. A named
303
+ application is always looked up in full, inherited ones included.
304
+ """
305
+
306
+ def equal(app: PuakmaApplication, fold: bool) -> bool:
307
+ def eq(actual: str | None, want: str | None) -> bool:
308
+ if want is None:
309
+ return True
310
+ actual = actual or ""
311
+ return actual.casefold() == want.casefold() if fold else actual == want
312
+
313
+ return (
314
+ eq(app.name, name)
315
+ and eq(app.group, group)
316
+ and eq(app.template_name, template)
317
+ )
318
+
319
+ def wanted(value: str | None) -> list[str]:
320
+ return [value] if value is not None else []
321
+
322
+ # The non-strict filter is a case-insensitive substring match, so it
323
+ # narrows the inventory without losing any case-insensitive equal
324
+ apps = _fetch_apps(server, wanted(name), wanted(group), wanted(template), False)
325
+ matches = [app for app in apps if equal(app, True)]
326
+ if len(matches) > 1:
327
+ return [app for app in matches if equal(app, False)] or matches
328
+ return matches
329
+
330
+
291
331
  def _resolve_one(
292
332
  server: PuakmaServer, matches: list[PuakmaApplication], desc: str
293
333
  ) -> list[int] | None:
@@ -378,7 +418,7 @@ def _resolve_bare_word(
378
418
  '--group' clones the group. A TemplateName names one application,
379
419
  so it is looked up in full; the group expansion honours include_all.
380
420
  """
381
- templates = _fetch_apps(server, [], [], [word], True)
421
+ templates = _fetch_exact_apps(server, template=word)
382
422
  group_apps = _fetch_group_apps(server, word, include_all)
383
423
  if templates and group_apps:
384
424
  logger.error(
@@ -414,7 +454,9 @@ def _resolve_refs_to_ids(
414
454
  elif ref.template is not None:
415
455
  resolved = _resolve_bare_word(server, ref.template, include_all)
416
456
  else:
417
- matches = _fetch_apps(server, [ref.name or ""], [ref.group or ""], [], True)
457
+ matches = _fetch_exact_apps(
458
+ server, name=ref.name or "", group=ref.group or ""
459
+ )
418
460
  resolved = _resolve_one(
419
461
  server, matches, f"application '{ref.group}/{ref.name}'"
420
462
  )
@@ -21,6 +21,7 @@ from typing import NamedTuple
21
21
 
22
22
  import httpx
23
23
 
24
+ from vortex.session_store import SessionStore
24
25
  from vortex.soap import ServerDesigner
25
26
 
26
27
  if TYPE_CHECKING:
@@ -253,6 +254,12 @@ class PuakmaServer:
253
254
  self._sync_client: httpx.Client | None = None
254
255
  self._async_client: httpx.AsyncClient | None = None
255
256
  self.server_designer = ServerDesigner(self)
257
+ # Set by Workspace: where this server's session cookies are kept
258
+ # between runs. Puakma creates a session for every request that
259
+ # arrives without one and keeps it for SessionTimeout (prod: 30
260
+ # days), so a fresh session per command - or per parallel request -
261
+ # piles up tens of thousands of idle sessions on the server
262
+ self.session_store: SessionStore | None = None
256
263
 
257
264
  @property
258
265
  def host(self) -> str:
@@ -333,15 +340,59 @@ class PuakmaServer:
333
340
  @property
334
341
  def _client(self) -> httpx.Client:
335
342
  if self._sync_client is None:
336
- self._sync_client = httpx.Client(auth=self.auth)
343
+ cookies = (
344
+ self.session_store.load(self.username) if self.session_store else None
345
+ )
346
+ self._sync_client = httpx.Client(
347
+ auth=self.auth,
348
+ cookies=cookies,
349
+ event_hooks={"response": [self._save_session]},
350
+ )
337
351
  return self._sync_client
338
352
 
339
353
  @property
340
354
  def _aclient(self) -> httpx.AsyncClient:
341
355
  if self._async_client is None:
342
- self._async_client = httpx.AsyncClient(auth=self.auth)
356
+ # Requests sent in parallel before the server has issued a
357
+ # session cookie each get a session of their own. Get one first
358
+ # on the sync client, so the async client starts with it
359
+ self._prime_session()
360
+ self._async_client = httpx.AsyncClient(
361
+ auth=self.auth,
362
+ cookies=self._client.cookies,
363
+ event_hooks={"response": [self._asave_session]},
364
+ )
343
365
  return self._async_client
344
366
 
367
+ def _prime_session(self) -> None:
368
+ if self._client.cookies.get(SessionStore.SESSION_COOKIE) is not None:
369
+ return
370
+ if not self.gateway_path:
371
+ # webdesign has no cheap endpoint to ask for one
372
+ return
373
+ url = f"{self.base_gateway_url}/api/whoami"
374
+ try:
375
+ self._client.get(url, timeout=10)
376
+ except httpx.HTTPError as e:
377
+ # Not fatal: the real requests report their own errors
378
+ logger.debug(f"Unable to get a session before parallel requests: {e}")
379
+
380
+ def _save_session(self, response: httpx.Response) -> None:
381
+ if self.session_store is None or "set-cookie" not in response.headers:
382
+ return
383
+ client = self._sync_client
384
+ if client is not None:
385
+ client.cookies.extract_cookies(response)
386
+ self.session_store.save(self.username, client.cookies)
387
+
388
+ async def _asave_session(self, response: httpx.Response) -> None:
389
+ if self.session_store is None or "set-cookie" not in response.headers:
390
+ return
391
+ client = self._async_client
392
+ if client is not None:
393
+ client.cookies.extract_cookies(response)
394
+ self.session_store.save(self.username, client.cookies)
395
+
345
396
  @property
346
397
  def base_soap_url(self) -> str:
347
398
  return f"{self}/{self.soap_path}"
@@ -0,0 +1,67 @@
1
+ """
2
+ The server's session cookies, kept between vortex runs.
3
+
4
+ Puakma gives every request that arrives without a session cookie a new
5
+ session, and keeps a logged-in session until it has been idle for the
6
+ server's SessionTimeout - 30 days on some servers. Every vortex command
7
+ used to start without cookies, and parallel requests (clone, fetch, weblog
8
+ --all...) each started their own, so a busy agent left tens of thousands
9
+ of idle 'Vortex Agent' sessions in the server's session list.
10
+
11
+ The cookies are written per server and per user, readable only by the
12
+ owner: the session cookie and LtpaToken are as good as a login until the
13
+ session expires.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import json
19
+ import logging
20
+ import os
21
+ from pathlib import Path
22
+
23
+ import httpx
24
+
25
+ logger = logging.getLogger("vortex")
26
+
27
+
28
+ class SessionStore:
29
+ SESSION_COOKIE = "_pma_sess_id"
30
+
31
+ def __init__(self, path: Path) -> None:
32
+ self.path = path
33
+
34
+ def load(self, username: str) -> httpx.Cookies | None:
35
+ try:
36
+ data = json.loads(self.path.read_text())
37
+ except (OSError, ValueError):
38
+ return None
39
+ if not isinstance(data, dict) or data.get("username") != username:
40
+ return None
41
+ cookies = httpx.Cookies()
42
+ for c in data.get("cookies", []):
43
+ try:
44
+ cookies.set(c["name"], c["value"], domain=c["domain"], path=c["path"])
45
+ except (KeyError, TypeError):
46
+ continue
47
+ return cookies
48
+
49
+ def save(self, username: str, cookies: httpx.Cookies) -> None:
50
+ data = {
51
+ "username": username,
52
+ "cookies": [
53
+ {"name": c.name, "value": c.value, "domain": c.domain, "path": c.path}
54
+ for c in cookies.jar
55
+ ],
56
+ }
57
+ try:
58
+ self.path.parent.mkdir(parents=True, exist_ok=True)
59
+ # Per process: two vortex runs may save at the same time
60
+ tmp = self.path.with_suffix(f".{os.getpid()}.tmp")
61
+ fd = os.open(tmp, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
62
+ with os.fdopen(fd, "w") as f:
63
+ json.dump(data, f)
64
+ os.replace(tmp, self.path)
65
+ except OSError as e:
66
+ # Not fatal: the next run just starts a new session
67
+ logger.debug(f"Unable to save the session to '{self.path}': {e}")
@@ -27,6 +27,7 @@ from vortex.models import PuakmaServer
27
27
  from vortex.server_options import OPTIONS_BY_NAME
28
28
  from vortex.server_options import ServersConfig
29
29
  from vortex.server_options import secret_interpolation_error
30
+ from vortex.session_store import SessionStore
30
31
  from vortex.util import file_lock
31
32
  from vortex.util import locked_by_message
32
33
 
@@ -684,6 +685,9 @@ class Workspace:
684
685
  protected,
685
686
  gateway_path or None,
686
687
  )
688
+ server.session_store = SessionStore(
689
+ self.config_dir / ".sessions" / f"{server_name}.json"
690
+ )
687
691
  self._server_cache[server_name] = server
688
692
  return server
689
693
  except (configparser.Error, ValueError) as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vortex_cli
3
- Version: 8.4.0
3
+ Version: 8.4.2
4
4
  Summary: Vortex CLI
5
5
  Author-email: Jordan Amos <jordan.amos@gmail.com>
6
6
  License: MIT License
@@ -113,6 +113,14 @@ While it is possible to use without it, this software has been purposefully desi
113
113
  Puakma root's disk marked (see [Server statistics](#server-statistics)); `--json` adds them
114
114
  as `disks`. It needs vortex/gateway 0.3.0, which adds them to `GET stats`; with an older
115
115
  gateway the overview says so in one line.
116
+ - **8.4.1: `vortex clone` ignores case in a TemplateName or `group/name`.** `vortex clone
117
+ ui20complete/mastercustom` clones `ui20Complete/MasterCustom`; the name must still match in
118
+ full. If two applications differ only in case, the one typed exactly wins.
119
+ - **8.4.2: vortex reuses one server session.** Every command used to start a new Puakma
120
+ session, and parallel requests each started their own, leaving thousands of idle sessions
121
+ on the server until SessionTimeout. Session cookies are now kept per server in
122
+ `config/.sessions/` (owner-only; treat them like a login) and parallel requests share one
123
+ session. Delete the file to start a new session.
116
124
 
117
125
  ## Upgrading to 8.3
118
126
 
@@ -906,8 +914,9 @@ outright is always cloned. Groups are matched the way `app list --group` matches
906
914
  case-insensitive substring - except that an exact group name always wins, so cloning
907
915
  `BetTrackr` never drags in `BetTrackrLegacy`. If a partial name still spans several groups,
908
916
  vortex stops and lists them. A bare word that is genuinely both a TemplateName and a group
909
- is refused: use `--group NAME` or the ID. References may be qualified as `SERVER:REF`
910
- (`dev:BetTrackr`).
917
+ is refused: use `--group NAME` or the ID. A TemplateName or `group/name` must match in full but
918
+ ignores case; if two applications differ only in case, the one typed exactly wins. References
919
+ may be qualified as `SERVER:REF` (`dev:BetTrackr`).
911
920
 
912
921
  ### Working with Multiple Servers
913
922
 
@@ -15,6 +15,7 @@ vortex/output.py
15
15
  vortex/registry.py
16
16
  vortex/schedule.py
17
17
  vortex/server_options.py
18
+ vortex/session_store.py
18
19
  vortex/soap.py
19
20
  vortex/spinner.py
20
21
  vortex/sync.py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes