ani-cli-arabic 2.1.2__tar.gz → 2.1.4__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.
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/PKG-INFO +1 -1
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/ani_cli_arabic.egg-info/PKG-INFO +1 -1
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/api.py +5 -2
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/app.py +12 -1
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/providers/anime_slayer.py +1 -1
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/settings.py +1 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/ui.py +1 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/updater.py +156 -49
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/version.py +1 -1
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/tests/test_updater.py +35 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/LICENSE +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/README.md +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/ani_cli_arabic.egg-info/SOURCES.txt +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/ani_cli_arabic.egg-info/dependency_links.txt +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/ani_cli_arabic.egg-info/entry_points.txt +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/ani_cli_arabic.egg-info/requires.txt +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/ani_cli_arabic.egg-info/top_level.txt +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/pyproject.toml +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/setup.cfg +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/__init__.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/__main__.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/broadcast.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/broadcast_popup.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/changelog.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/cli.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/config.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/deps.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/discord_rpc.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/downloader.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/favorites.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/history.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/logger.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/models.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/monitoring.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/player.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/providers/__init__.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/providers/anime3rb.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/providers/animeify.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/providers/base.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/providers/hianime.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/providers/manager.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/providers/stardima.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/providers/stardima_catalog.json +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/providers/stardima_client.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/storage.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/src/utils.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/tests/test_logger.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/tests/test_monitoring.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/tests/test_smart.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/tests/test_stardima.py +0 -0
- {ani_cli_arabic-2.1.2 → ani_cli_arabic-2.1.4}/tests/test_stardima_live.py +0 -0
|
@@ -80,9 +80,12 @@ class CDNHealthManager:
|
|
|
80
80
|
_cdn_health_manager = CDNHealthManager()
|
|
81
81
|
|
|
82
82
|
DEFAULT_HEADERS = {
|
|
83
|
-
"User-Agent": "Mozilla/5.0 (
|
|
84
|
-
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
|
|
83
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
|
84
|
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
|
|
85
85
|
"Accept-Language": "en-US,en;q=0.9,ar;q=0.8",
|
|
86
|
+
"Sec-Ch-Ua": "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Google Chrome\";v=\"120\"",
|
|
87
|
+
"Sec-Ch-Ua-Mobile": "?0",
|
|
88
|
+
"Sec-Ch-Ua-Platform": "\"Windows\"",
|
|
86
89
|
"DNT": "1",
|
|
87
90
|
"Sec-Fetch-Dest": "document",
|
|
88
91
|
"Sec-Fetch-Mode": "navigate",
|
|
@@ -89,6 +89,7 @@ class AniCliArApp:
|
|
|
89
89
|
parser.add_argument('-d', '--debug', action='store_true', help="Enable verbose debug logging to file and console")
|
|
90
90
|
parser.add_argument('-v', '--version', action='store_true', help="Show version information")
|
|
91
91
|
parser.add_argument('-u', '--update', action='store_true', help="Check for and install updates")
|
|
92
|
+
parser.add_argument('--no-update', action='store_true', help="Skip automatic startup update check")
|
|
92
93
|
parser.add_argument('query', nargs='*', help="Anime name to search for")
|
|
93
94
|
|
|
94
95
|
args = parser.parse_args()
|
|
@@ -110,8 +111,18 @@ class AniCliArApp:
|
|
|
110
111
|
|
|
111
112
|
if args.update:
|
|
112
113
|
from .updater import check_for_updates
|
|
113
|
-
check_for_updates(auto_update=True, interactive=True)
|
|
114
|
+
check_for_updates(auto_update=True, interactive=True, force=True)
|
|
114
115
|
sys.exit(0)
|
|
116
|
+
|
|
117
|
+
# Forced automatic update check on launch
|
|
118
|
+
if not getattr(args, "no_update", False) and self.settings.get("auto_update", True):
|
|
119
|
+
try:
|
|
120
|
+
from .updater import perform_auto_update, restart_application
|
|
121
|
+
if perform_auto_update():
|
|
122
|
+
restart_application()
|
|
123
|
+
return
|
|
124
|
+
except Exception as e:
|
|
125
|
+
logger.debug("UPDATER", f"Auto-update check bypassed: {e}")
|
|
115
126
|
|
|
116
127
|
self.force_cli = args.interactive
|
|
117
128
|
initial_query = " ".join(args.query) if args.query else None
|
|
@@ -93,7 +93,7 @@ class AnimeSlayerProvider(BaseAnimeProvider):
|
|
|
93
93
|
"Client-Id": CLIENT_ID,
|
|
94
94
|
"Client-Secret": CLIENT_SECRET,
|
|
95
95
|
"Accept": "application/json",
|
|
96
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/
|
|
96
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
def __init__(self):
|
|
@@ -2059,6 +2059,7 @@ class UIManager:
|
|
|
2059
2059
|
("Download Directory", [], "download_directory"),
|
|
2060
2060
|
]),
|
|
2061
2061
|
("System", [
|
|
2062
|
+
("Auto Updates", [True, False], "auto_update"),
|
|
2062
2063
|
("Discord Rich Presence", [True, False], "discord_rpc"),
|
|
2063
2064
|
("Debug Logging", [False, True], "debug_logging"),
|
|
2064
2065
|
])
|
|
@@ -4,6 +4,7 @@ Supports PyPI (pip/pipx), Arch Linux (AUR yay/paru), macOS (Homebrew),
|
|
|
4
4
|
Windows (winget/scoop/standalone binary), and direct GitHub releases.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
+
import os
|
|
7
8
|
import sys
|
|
8
9
|
import shutil
|
|
9
10
|
import platform
|
|
@@ -19,10 +20,10 @@ from rich.console import Console
|
|
|
19
20
|
console = Console()
|
|
20
21
|
|
|
21
22
|
|
|
22
|
-
def get_latest_pypi_version() -> Optional[str]:
|
|
23
|
+
def get_latest_pypi_version(timeout: float = 4.0) -> Optional[str]:
|
|
23
24
|
"""Fetches the latest version published on PyPI."""
|
|
24
25
|
try:
|
|
25
|
-
resp = requests.get("https://pypi.org/pypi/ani-cli-arabic/json", timeout=
|
|
26
|
+
resp = requests.get("https://pypi.org/pypi/ani-cli-arabic/json", timeout=timeout)
|
|
26
27
|
if resp.status_code == 200:
|
|
27
28
|
return resp.json().get("info", {}).get("version")
|
|
28
29
|
except Exception:
|
|
@@ -30,10 +31,10 @@ def get_latest_pypi_version() -> Optional[str]:
|
|
|
30
31
|
return None
|
|
31
32
|
|
|
32
33
|
|
|
33
|
-
def get_latest_aur_version() -> Optional[str]:
|
|
34
|
+
def get_latest_aur_version(timeout: float = 4.0) -> Optional[str]:
|
|
34
35
|
"""Fetches the latest version published in Arch Linux AUR."""
|
|
35
36
|
try:
|
|
36
|
-
resp = requests.get("https://aur.archlinux.org/rpc/v5/info?arg[]=ani-cli-arabic", timeout=
|
|
37
|
+
resp = requests.get("https://aur.archlinux.org/rpc/v5/info?arg[]=ani-cli-arabic", timeout=timeout)
|
|
37
38
|
if resp.status_code == 200:
|
|
38
39
|
results = resp.json().get("results", [])
|
|
39
40
|
if results:
|
|
@@ -44,10 +45,10 @@ def get_latest_aur_version() -> Optional[str]:
|
|
|
44
45
|
return None
|
|
45
46
|
|
|
46
47
|
|
|
47
|
-
def get_latest_github_release() -> Optional[Dict[str, Any]]:
|
|
48
|
+
def get_latest_github_release(timeout: float = 4.0) -> Optional[Dict[str, Any]]:
|
|
48
49
|
"""Fetches the latest release payload from GitHub Releases API."""
|
|
49
50
|
try:
|
|
50
|
-
resp = requests.get(API_RELEASES_URL, timeout=
|
|
51
|
+
resp = requests.get(API_RELEASES_URL, timeout=timeout)
|
|
51
52
|
if resp.status_code == 200:
|
|
52
53
|
return resp.json()
|
|
53
54
|
except Exception:
|
|
@@ -103,7 +104,7 @@ def detect_install_method() -> str:
|
|
|
103
104
|
return "pip"
|
|
104
105
|
|
|
105
106
|
|
|
106
|
-
def update_aur(latest_ver: str, interactive: bool = False) -> bool:
|
|
107
|
+
def update_aur(latest_ver: str, interactive: bool = False, force: bool = False) -> bool:
|
|
107
108
|
"""Handles AUR updates without clobbering background TUI processes."""
|
|
108
109
|
console.print(f"\n[cyan]Update available: v{__version__} → v{latest_ver}[/cyan]")
|
|
109
110
|
console.print("[dim]Detected Arch Linux package (AUR).[/dim]\n")
|
|
@@ -120,6 +121,17 @@ def update_aur(latest_ver: str, interactive: bool = False) -> bool:
|
|
|
120
121
|
console.print(" paru -S ani-cli-arabic\n")
|
|
121
122
|
return False
|
|
122
123
|
|
|
124
|
+
if force:
|
|
125
|
+
cmd = [helper, "-S", "--noconfirm", "ani-cli-arabic"]
|
|
126
|
+
console.print(f"[cyan]Executing: {' '.join(cmd)}[/cyan]")
|
|
127
|
+
res = subprocess.run(cmd)
|
|
128
|
+
if res.returncode == 0:
|
|
129
|
+
console.print(f"[green]✓ Updated successfully via {helper}.[/green]")
|
|
130
|
+
return True
|
|
131
|
+
else:
|
|
132
|
+
console.print(f"[yellow]{helper} exited with status {res.returncode}.[/yellow]")
|
|
133
|
+
return False
|
|
134
|
+
|
|
123
135
|
cmd = [helper, "-S", "ani-cli-arabic"]
|
|
124
136
|
|
|
125
137
|
if interactive:
|
|
@@ -144,11 +156,19 @@ def update_aur(latest_ver: str, interactive: bool = False) -> bool:
|
|
|
144
156
|
return False
|
|
145
157
|
|
|
146
158
|
|
|
147
|
-
def update_brew(latest_ver: str, interactive: bool = False) -> bool:
|
|
159
|
+
def update_brew(latest_ver: str, interactive: bool = False, force: bool = False) -> bool:
|
|
148
160
|
"""Handles Homebrew updates."""
|
|
149
161
|
console.print(f"\n[cyan]Update available: v{__version__} → v{latest_ver}[/cyan]")
|
|
150
162
|
console.print("[dim]Detected Homebrew installation.[/dim]\n")
|
|
151
163
|
|
|
164
|
+
if force:
|
|
165
|
+
console.print("[dim]Updating via Homebrew...[/dim]\n")
|
|
166
|
+
res = subprocess.run(["brew", "upgrade", "ani-cli-arabic"])
|
|
167
|
+
if res.returncode == 0:
|
|
168
|
+
console.print("[green]✓ Updated successfully via Homebrew.[/green]")
|
|
169
|
+
return True
|
|
170
|
+
return False
|
|
171
|
+
|
|
152
172
|
if interactive:
|
|
153
173
|
try:
|
|
154
174
|
choice = input("Run 'brew upgrade ani-cli-arabic' now? [Y/n]: ").strip().lower()
|
|
@@ -168,11 +188,19 @@ def update_brew(latest_ver: str, interactive: bool = False) -> bool:
|
|
|
168
188
|
return False
|
|
169
189
|
|
|
170
190
|
|
|
171
|
-
def update_pipx(latest_ver: str, interactive: bool = False) -> bool:
|
|
191
|
+
def update_pipx(latest_ver: str, interactive: bool = False, force: bool = False) -> bool:
|
|
172
192
|
"""Handles pipx updates."""
|
|
173
193
|
console.print(f"\n[cyan]Update available: v{__version__} → v{latest_ver}[/cyan]")
|
|
174
194
|
console.print("[dim]Detected pipx installation.[/dim]\n")
|
|
175
195
|
|
|
196
|
+
if force:
|
|
197
|
+
console.print("[dim]Updating via pipx...[/dim]\n")
|
|
198
|
+
res = subprocess.run(["pipx", "upgrade", "ani-cli-arabic"])
|
|
199
|
+
if res.returncode == 0:
|
|
200
|
+
console.print("[green]✓ Updated successfully via pipx.[/green]")
|
|
201
|
+
return True
|
|
202
|
+
return False
|
|
203
|
+
|
|
176
204
|
if interactive:
|
|
177
205
|
try:
|
|
178
206
|
choice = input("Run 'pipx upgrade ani-cli-arabic' now? [Y/n]: ").strip().lower()
|
|
@@ -192,47 +220,54 @@ def update_pipx(latest_ver: str, interactive: bool = False) -> bool:
|
|
|
192
220
|
return False
|
|
193
221
|
|
|
194
222
|
|
|
195
|
-
def update_pip(latest_ver: str, interactive: bool = False) -> bool:
|
|
223
|
+
def update_pip(latest_ver: str, interactive: bool = False, force: bool = False) -> bool:
|
|
196
224
|
"""Handles standard pip updates."""
|
|
197
225
|
console.print(f"\n[cyan]Update available: v{__version__} → v{latest_ver}[/cyan]")
|
|
198
226
|
|
|
199
|
-
if interactive:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
227
|
+
if force or interactive:
|
|
228
|
+
if interactive and not force:
|
|
229
|
+
try:
|
|
230
|
+
choice = input(f"Update to v{latest_ver} via pip now? [Y/n]: ").strip().lower()
|
|
231
|
+
if choice not in ("", "y", "yes"):
|
|
232
|
+
console.print("[dim]Update skipped.[/dim]")
|
|
233
|
+
return False
|
|
234
|
+
except (KeyboardInterrupt, EOFError):
|
|
235
|
+
console.print("\n[dim]Update cancelled.[/dim]")
|
|
236
|
+
return False
|
|
237
|
+
|
|
238
|
+
console.print("[dim]Downloading update from PyPI...[/dim]\n")
|
|
239
|
+
cmd = [sys.executable, "-m", "pip", "install", "--upgrade", "--no-cache-dir", "ani-cli-arabic"]
|
|
240
|
+
is_venv = sys.prefix != getattr(sys, "base_prefix", sys.prefix)
|
|
241
|
+
if platform.system() != "Windows" and not is_venv:
|
|
242
|
+
cmd.append("--user")
|
|
243
|
+
|
|
244
|
+
res = subprocess.run(cmd, capture_output=True, text=True)
|
|
245
|
+
|
|
246
|
+
# Handle PEP 668 (externally-managed-environment on Arch/Debian/Ubuntu)
|
|
247
|
+
if res.returncode != 0 and "externally-managed-environment" in res.stderr:
|
|
248
|
+
console.print("[dim]System-managed Python environment detected; retrying with user override...[/dim]")
|
|
249
|
+
if "--user" not in cmd and not is_venv:
|
|
250
|
+
cmd.append("--user")
|
|
251
|
+
if "--break-system-packages" not in cmd:
|
|
252
|
+
cmd.append("--break-system-packages")
|
|
253
|
+
res = subprocess.run(cmd, capture_output=True, text=True)
|
|
254
|
+
|
|
255
|
+
if res.returncode == 0:
|
|
256
|
+
console.print(f"[green]✓ Successfully updated to v{latest_ver}.[/green]")
|
|
257
|
+
if interactive and not force:
|
|
258
|
+
console.print("Please restart the application.")
|
|
259
|
+
sys.exit(0)
|
|
260
|
+
return True
|
|
223
261
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
console.print("[dim]Update skipped.[/dim]")
|
|
227
|
-
except (KeyboardInterrupt, EOFError):
|
|
228
|
-
console.print("\n[dim]Update cancelled.[/dim]")
|
|
262
|
+
console.print(f"[red]Update failed: {res.stderr.strip() or 'Unknown error'}[/red]")
|
|
263
|
+
return False
|
|
229
264
|
else:
|
|
230
265
|
console.print("[yellow]To update, please run:[/yellow] [bold]pip install --upgrade ani-cli-arabic[/bold]\n")
|
|
231
266
|
|
|
232
267
|
return False
|
|
233
268
|
|
|
234
269
|
|
|
235
|
-
def update_binary(latest_ver: str, release_data: Dict[str, Any], interactive: bool = False) -> bool:
|
|
270
|
+
def update_binary(latest_ver: str, release_data: Dict[str, Any], interactive: bool = False, force: bool = False) -> bool:
|
|
236
271
|
"""Downloads and replaces bundled standalone binary."""
|
|
237
272
|
console.print(f"\n[cyan]Update available: v{__version__} → v{latest_ver}[/cyan]")
|
|
238
273
|
console.print("[dim]Downloading executable update from GitHub...[/dim]\n")
|
|
@@ -273,15 +308,17 @@ def update_binary(latest_ver: str, release_data: Dict[str, Any], interactive: bo
|
|
|
273
308
|
temp_exe.rename(current_exe)
|
|
274
309
|
|
|
275
310
|
console.print(f"[green]✓ Successfully replaced binary with v{latest_ver}.[/green]")
|
|
276
|
-
|
|
277
|
-
|
|
311
|
+
if interactive and not force:
|
|
312
|
+
console.print("Please restart the application.")
|
|
313
|
+
sys.exit(0)
|
|
314
|
+
return True
|
|
278
315
|
except Exception as e:
|
|
279
316
|
console.print(f"[red]Binary update failed: {e}[/red]")
|
|
280
317
|
console.print(f"Download manually: {download_url}")
|
|
281
318
|
return False
|
|
282
319
|
|
|
283
320
|
|
|
284
|
-
def check_for_updates(auto_update: bool = False, interactive: bool = False) -> bool:
|
|
321
|
+
def check_for_updates(auto_update: bool = False, interactive: bool = False, force: bool = False) -> bool:
|
|
285
322
|
"""Checks for newer releases and updates via the appropriate platform package manager."""
|
|
286
323
|
try:
|
|
287
324
|
method = detect_install_method()
|
|
@@ -309,33 +346,103 @@ def check_for_updates(auto_update: bool = False, interactive: bool = False) -> b
|
|
|
309
346
|
console.print(f"[green]✓ ani-cli-arabic is up to date (v{__version__}).[/green]")
|
|
310
347
|
return False
|
|
311
348
|
|
|
312
|
-
if not auto_update and not interactive:
|
|
349
|
+
if not auto_update and not interactive and not force:
|
|
313
350
|
return True
|
|
314
351
|
|
|
315
352
|
if method == "aur":
|
|
316
|
-
return update_aur(latest_version, interactive=interactive)
|
|
353
|
+
return update_aur(latest_version, interactive=interactive, force=force)
|
|
317
354
|
elif method == "brew":
|
|
318
|
-
return update_brew(latest_version, interactive=interactive)
|
|
355
|
+
return update_brew(latest_version, interactive=interactive, force=force)
|
|
319
356
|
elif method == "pipx":
|
|
320
|
-
return update_pipx(latest_version, interactive=interactive)
|
|
357
|
+
return update_pipx(latest_version, interactive=interactive, force=force)
|
|
321
358
|
elif method == "executable":
|
|
322
359
|
if not release_data:
|
|
323
360
|
release_data = get_latest_github_release()
|
|
324
361
|
if release_data:
|
|
325
|
-
return update_binary(latest_version, release_data, interactive=interactive)
|
|
362
|
+
return update_binary(latest_version, release_data, interactive=interactive, force=force)
|
|
326
363
|
elif method == "source":
|
|
327
364
|
if interactive:
|
|
328
365
|
console.print(f"\n[cyan]Update available: v{__version__} → v{latest_version}[/cyan]")
|
|
329
366
|
console.print("[dim]Running from local git source checkout. Run 'git pull' to update.[/dim]\n")
|
|
330
367
|
return False
|
|
331
368
|
else:
|
|
332
|
-
return update_pip(latest_version, interactive=interactive)
|
|
369
|
+
return update_pip(latest_version, interactive=interactive, force=force)
|
|
333
370
|
except Exception:
|
|
334
371
|
pass
|
|
335
372
|
|
|
336
373
|
return False
|
|
337
374
|
|
|
338
375
|
|
|
376
|
+
def perform_auto_update(timeout: float = 3.0) -> bool:
|
|
377
|
+
"""
|
|
378
|
+
Forced automatic updater invoked at launch before the TUI initializes.
|
|
379
|
+
Returns True if an update was applied and the application should restart.
|
|
380
|
+
"""
|
|
381
|
+
try:
|
|
382
|
+
method = detect_install_method()
|
|
383
|
+
if method == "source":
|
|
384
|
+
return False
|
|
385
|
+
|
|
386
|
+
if method == "aur":
|
|
387
|
+
latest_version = get_latest_aur_version(timeout=timeout)
|
|
388
|
+
else:
|
|
389
|
+
latest_version = get_latest_pypi_version(timeout=timeout)
|
|
390
|
+
|
|
391
|
+
release_data = None
|
|
392
|
+
if not latest_version:
|
|
393
|
+
release_data = get_latest_github_release(timeout=timeout)
|
|
394
|
+
if release_data:
|
|
395
|
+
latest_version = release_data.get("tag_name", "").lstrip("v")
|
|
396
|
+
|
|
397
|
+
if not latest_version:
|
|
398
|
+
return False
|
|
399
|
+
|
|
400
|
+
if parse_version(latest_version) <= parse_version(__version__):
|
|
401
|
+
return False
|
|
402
|
+
|
|
403
|
+
console.print(f"\n[bold cyan]⚡ New update detected: v{__version__} → v{latest_version}[/bold cyan]")
|
|
404
|
+
console.print("[dim]Performing automatic update...[/dim]")
|
|
405
|
+
|
|
406
|
+
if method == "aur":
|
|
407
|
+
return update_aur(latest_version, interactive=False, force=True)
|
|
408
|
+
elif method == "brew":
|
|
409
|
+
return update_brew(latest_version, interactive=False, force=True)
|
|
410
|
+
elif method == "pipx":
|
|
411
|
+
return update_pipx(latest_version, interactive=False, force=True)
|
|
412
|
+
elif method == "executable":
|
|
413
|
+
if not release_data:
|
|
414
|
+
release_data = get_latest_github_release(timeout=6.0)
|
|
415
|
+
if release_data:
|
|
416
|
+
return update_binary(latest_version, release_data, interactive=False, force=True)
|
|
417
|
+
else:
|
|
418
|
+
return update_pip(latest_version, interactive=False, force=True)
|
|
419
|
+
except Exception as e:
|
|
420
|
+
console.print(f"[yellow]Auto-update check encountered error: {e}[/yellow]")
|
|
421
|
+
return False
|
|
422
|
+
|
|
423
|
+
return False
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
def restart_application():
|
|
427
|
+
"""Restarts the application after an update."""
|
|
428
|
+
try:
|
|
429
|
+
from .utils import show_cursor
|
|
430
|
+
show_cursor()
|
|
431
|
+
console.print("[cyan]Restarting ani-cli-arabic...[/cyan]\n")
|
|
432
|
+
sys.stdout.flush()
|
|
433
|
+
sys.stderr.flush()
|
|
434
|
+
|
|
435
|
+
if is_bundled():
|
|
436
|
+
os.execv(sys.executable, sys.argv)
|
|
437
|
+
elif sys.argv[0] and Path(sys.argv[0]).exists() and os.access(sys.argv[0], os.X_OK):
|
|
438
|
+
os.execv(sys.argv[0], sys.argv)
|
|
439
|
+
else:
|
|
440
|
+
os.execv(sys.executable, [sys.executable] + sys.argv)
|
|
441
|
+
except Exception:
|
|
442
|
+
console.print("[green]Please restart ani-cli-arabic to launch the new version.[/green]")
|
|
443
|
+
sys.exit(0)
|
|
444
|
+
|
|
445
|
+
|
|
339
446
|
def get_version_status() -> Optional[Dict[str, Any]]:
|
|
340
447
|
"""Returns structured version and update status for the active installation method."""
|
|
341
448
|
try:
|
|
@@ -102,3 +102,38 @@ def test_get_version_status_aur():
|
|
|
102
102
|
assert status["is_outdated"] is True
|
|
103
103
|
assert status["install_method"] == "aur"
|
|
104
104
|
|
|
105
|
+
|
|
106
|
+
def test_update_aur_force():
|
|
107
|
+
with patch("shutil.which", return_value="/usr/bin/yay"):
|
|
108
|
+
with patch("subprocess.run") as mock_sub:
|
|
109
|
+
mock_sub.return_value.returncode = 0
|
|
110
|
+
res = update_aur("2.1.4", interactive=False, force=True)
|
|
111
|
+
assert res is True
|
|
112
|
+
mock_sub.assert_called_once_with(["yay", "-S", "--noconfirm", "ani-cli-arabic"])
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def test_update_pip_force():
|
|
116
|
+
with patch("subprocess.run") as mock_sub:
|
|
117
|
+
mock_sub.return_value.returncode = 0
|
|
118
|
+
res = update_pip("2.1.4", interactive=False, force=True)
|
|
119
|
+
assert res is True
|
|
120
|
+
assert mock_sub.called
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def test_perform_auto_update_skips_source():
|
|
124
|
+
from src.updater import perform_auto_update
|
|
125
|
+
with patch("src.updater.detect_install_method", return_value="source"):
|
|
126
|
+
assert perform_auto_update() is False
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def test_perform_auto_update_executes_on_newer_version():
|
|
130
|
+
from src.updater import perform_auto_update
|
|
131
|
+
with patch("src.updater.detect_install_method", return_value="pip"):
|
|
132
|
+
with patch("src.updater.get_latest_pypi_version", return_value="9.9.9"):
|
|
133
|
+
with patch("src.updater.__version__", "2.1.3"):
|
|
134
|
+
with patch("src.updater.update_pip", return_value=True) as mock_update_pip:
|
|
135
|
+
res = perform_auto_update()
|
|
136
|
+
assert res is True
|
|
137
|
+
mock_update_pip.assert_called_once_with("9.9.9", interactive=False, force=True)
|
|
138
|
+
|
|
139
|
+
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|