commandertui 1.4.2__tar.gz → 1.4.3__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 (48) hide show
  1. {commandertui-1.4.2 → commandertui-1.4.3}/PKG-INFO +1 -1
  2. commandertui-1.4.3/commandertui/__init__.py +1 -0
  3. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/main_screen.py +3 -1
  4. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/updater.py +22 -4
  5. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui.egg-info/PKG-INFO +1 -1
  6. {commandertui-1.4.2 → commandertui-1.4.3}/tests/test_updater.py +34 -2
  7. commandertui-1.4.2/commandertui/__init__.py +0 -1
  8. {commandertui-1.4.2 → commandertui-1.4.3}/LICENSE +0 -0
  9. {commandertui-1.4.2 → commandertui-1.4.3}/README.md +0 -0
  10. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/app.py +0 -0
  11. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/ascii_font.py +0 -0
  12. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/bookmarks.py +0 -0
  13. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/boot.py +0 -0
  14. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/cli.py +0 -0
  15. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/compare_screen.py +0 -0
  16. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/diff.py +0 -0
  17. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/editor.py +0 -0
  18. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/executor.py +0 -0
  19. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/modals.py +0 -0
  20. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/models.py +0 -0
  21. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/netlocations.py +0 -0
  22. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/plan.py +0 -0
  23. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/preview.py +0 -0
  24. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/progress_screen.py +0 -0
  25. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/run_queue.py +0 -0
  26. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/scanner.py +0 -0
  27. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/settings.py +0 -0
  28. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/sync.py +0 -0
  29. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/theme.py +0 -0
  30. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/trash.py +0 -0
  31. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui/widgets.py +0 -0
  32. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui.egg-info/SOURCES.txt +0 -0
  33. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui.egg-info/dependency_links.txt +0 -0
  34. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui.egg-info/entry_points.txt +0 -0
  35. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui.egg-info/requires.txt +0 -0
  36. {commandertui-1.4.2 → commandertui-1.4.3}/commandertui.egg-info/top_level.txt +0 -0
  37. {commandertui-1.4.2 → commandertui-1.4.3}/pyproject.toml +0 -0
  38. {commandertui-1.4.2 → commandertui-1.4.3}/setup.cfg +0 -0
  39. {commandertui-1.4.2 → commandertui-1.4.3}/tests/test_app_smoke.py +0 -0
  40. {commandertui-1.4.2 → commandertui-1.4.3}/tests/test_bookmarks.py +0 -0
  41. {commandertui-1.4.2 → commandertui-1.4.3}/tests/test_diff.py +0 -0
  42. {commandertui-1.4.2 → commandertui-1.4.3}/tests/test_executor.py +0 -0
  43. {commandertui-1.4.2 → commandertui-1.4.3}/tests/test_netlocations.py +0 -0
  44. {commandertui-1.4.2 → commandertui-1.4.3}/tests/test_plan.py +0 -0
  45. {commandertui-1.4.2 → commandertui-1.4.3}/tests/test_preview.py +0 -0
  46. {commandertui-1.4.2 → commandertui-1.4.3}/tests/test_scanner.py +0 -0
  47. {commandertui-1.4.2 → commandertui-1.4.3}/tests/test_sync.py +0 -0
  48. {commandertui-1.4.2 → commandertui-1.4.3}/tests/test_widgets.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: commandertui
3
- Version: 1.4.2
3
+ Version: 1.4.3
4
4
  Summary: Dual-pane retro terminal file manager: compare, sync, copy and move folders
5
5
  Author: Humberto Barchini
6
6
  License-Expression: MIT
@@ -0,0 +1 @@
1
+ __version__ = "1.4.3"
@@ -350,7 +350,9 @@ class MainScreen(Screen):
350
350
  )
351
351
  else:
352
352
  self.app.push_screen(
353
- MessageScreen("The update did not finish. Check the terminal output, then try again.")
353
+ MessageScreen(
354
+ "The update did not finish. The package index may not have the new version yet:\nwait a few minutes and try again, or check the terminal output."
355
+ )
354
356
  )
355
357
 
356
358
  self.app.push_screen(UpdateScreen(info), on_choice)
@@ -112,10 +112,12 @@ makepkg -si
112
112
 
113
113
  def update_command(install: str, latest: str) -> list[str] | None:
114
114
  """The command to run for `install`, or None when there isn't a safe one."""
115
+ # --no-cache-dir: pip keeps the package index for minutes, so right after a release it
116
+ # can still say "already up to date" for a version PyPI already serves.
115
117
  if install == "pipx":
116
- return ["pipx", "upgrade", PACKAGE]
118
+ return ["pipx", "upgrade", "--pip-args=--no-cache-dir", PACKAGE]
117
119
  if install == "pip":
118
- return [sys.executable, "-m", "pip", "install", "--upgrade", PACKAGE]
120
+ return [sys.executable, "-m", "pip", "install", "--upgrade", "--no-cache-dir", PACKAGE]
119
121
  if install == "pacman":
120
122
  return ["bash", "-c", _ARCH_SCRIPT.format(repo=REPO, latest=latest)]
121
123
  return None # git checkout: the user updates it with git
@@ -174,9 +176,25 @@ def skip_version(version: str) -> None:
174
176
  _save_cache(cache)
175
177
 
176
178
 
179
+ def installed_version() -> str | None:
180
+ """The version on disk right now (not the one this process started with), or None if unknown."""
181
+ try:
182
+ from importlib import metadata
183
+
184
+ metadata.MetadataPathFinder.invalidate_caches()
185
+ return metadata.version(PACKAGE)
186
+ except Exception:
187
+ return None
188
+
189
+
177
190
  def run_update(info: UpdateInfo) -> bool:
178
- """Run the upgrade attached to the real terminal. True if it exited 0."""
191
+ """Run the upgrade attached to the real terminal. True only if it exited 0 AND the
192
+ new version is really installed: a package manager can exit 0 with "already up to date"
193
+ when its index has not caught up with the release yet."""
179
194
  command = update_command(info.install, info.latest)
180
195
  if command is None:
181
196
  return False
182
- return subprocess.run(command).returncode == 0
197
+ if subprocess.run(command).returncode != 0:
198
+ return False
199
+ now = installed_version()
200
+ return now is None or now == info.latest # unknown version: trust the exit code
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: commandertui
3
- Version: 1.4.2
3
+ Version: 1.4.3
4
4
  Summary: Dual-pane retro terminal file manager: compare, sync, copy and move folders
5
5
  Author: Humberto Barchini
6
6
  License-Expression: MIT
@@ -62,9 +62,14 @@ def test_fake_latest_env_shows_an_update_without_a_release(monkeypatch):
62
62
 
63
63
 
64
64
  def test_update_commands_per_install_kind():
65
- assert updater.update_command("pipx", "2.0.0") == ["pipx", "upgrade", "commandertui"]
65
+ assert updater.update_command("pipx", "2.0.0") == [
66
+ "pipx",
67
+ "upgrade",
68
+ "--pip-args=--no-cache-dir",
69
+ "commandertui",
70
+ ]
66
71
  pip = updater.update_command("pip", "2.0.0")
67
- assert pip[1:] == ["-m", "pip", "install", "--upgrade", "commandertui"]
72
+ assert pip[1:] == ["-m", "pip", "install", "--upgrade", "--no-cache-dir", "commandertui"]
68
73
  assert updater.update_command("source", "2.0.0") is None
69
74
  arch = updater.update_command("pacman", "2.0.0")
70
75
  assert arch[:2] == ["bash", "-c"]
@@ -116,3 +121,30 @@ def test_check_status_tells_ok_new_skipped_and_offline(monkeypatch):
116
121
  assert updater.check_status(current="1.1.0") == (None, "skipped")
117
122
  monkeypatch.setattr(updater, "fetch_latest", lambda: None)
118
123
  assert updater.check_status(current="1.1.0") == (None, "offline")
124
+
125
+
126
+ def _info(latest="2.0.0", install="pipx"):
127
+ return updater.UpdateInfo(current="1.0.0", latest=latest, install=install)
128
+
129
+
130
+ def test_run_update_requires_the_new_version_to_be_installed(monkeypatch):
131
+ import subprocess
132
+
133
+ monkeypatch.setattr(updater.subprocess, "run", lambda cmd, **kw: subprocess.CompletedProcess(cmd, 0))
134
+ monkeypatch.setattr(updater, "installed_version", lambda: "2.0.0")
135
+ assert updater.run_update(_info()) is True
136
+ # pipx said "already up to date" (exit 0) but the old version is still there
137
+ monkeypatch.setattr(updater, "installed_version", lambda: "1.0.0")
138
+ assert updater.run_update(_info()) is False
139
+ # version unknown: trust the exit code
140
+ monkeypatch.setattr(updater, "installed_version", lambda: None)
141
+ assert updater.run_update(_info()) is True
142
+
143
+
144
+ def test_run_update_fails_on_nonzero_exit_without_checking_version(monkeypatch):
145
+ import subprocess
146
+
147
+ monkeypatch.setattr(updater.subprocess, "run", lambda cmd, **kw: subprocess.CompletedProcess(cmd, 1))
148
+ monkeypatch.setattr(updater, "installed_version", lambda: "2.0.0")
149
+ assert updater.run_update(_info()) is False
150
+ assert updater.run_update(_info(install="source")) is False
@@ -1 +0,0 @@
1
- __version__ = "1.4.2"
File without changes
File without changes
File without changes