mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-12 15:50:01 -08:00
fix(update-command): use viu-media when updating
This commit is contained in:
@@ -6,7 +6,7 @@ import click
|
||||
from click.core import ParameterSource
|
||||
|
||||
from ..core.config import AppConfig
|
||||
from ..core.constants import PROJECT_NAME, USER_CONFIG, __version__
|
||||
from ..core.constants import CLI_NAME, USER_CONFIG, __version__
|
||||
from .config import ConfigLoader
|
||||
from .options import options_from_model
|
||||
from .utils.exception import setup_exceptions_handler
|
||||
@@ -47,7 +47,7 @@ commands = {
|
||||
root="viu_media.cli.commands",
|
||||
invoke_without_command=True,
|
||||
lazy_subcommands=commands,
|
||||
context_settings=dict(auto_envvar_prefix=PROJECT_NAME),
|
||||
context_settings=dict(auto_envvar_prefix=CLI_NAME),
|
||||
)
|
||||
@click.version_option(__version__, "--version")
|
||||
@click.option("--no-config", is_flag=True, help="Don't load the user config file.")
|
||||
|
||||
@@ -123,9 +123,9 @@ def _generate_desktop_entry():
|
||||
from rich.prompt import Confirm
|
||||
|
||||
from ...core.constants import (
|
||||
CLI_NAME,
|
||||
ICON_PATH,
|
||||
PLATFORM,
|
||||
PROJECT_NAME,
|
||||
USER_APPLICATIONS,
|
||||
__version__,
|
||||
)
|
||||
@@ -149,7 +149,7 @@ def _generate_desktop_entry():
|
||||
desktop_entry = dedent(
|
||||
f"""
|
||||
[Desktop Entry]
|
||||
Name={PROJECT_NAME.title()}
|
||||
Name={CLI_NAME.title()}
|
||||
Type=Application
|
||||
version={__version__}
|
||||
Path={Path().home()}
|
||||
@@ -160,7 +160,7 @@ def _generate_desktop_entry():
|
||||
Categories=Entertainment
|
||||
"""
|
||||
)
|
||||
desktop_entry_path = USER_APPLICATIONS / f"{PROJECT_NAME}.desktop"
|
||||
desktop_entry_path = USER_APPLICATIONS / f"{CLI_NAME}.desktop"
|
||||
if desktop_entry_path.exists():
|
||||
if not Confirm.ask(
|
||||
f"The file already exists {desktop_entry_path}; or would you like to rewrite it",
|
||||
|
||||
@@ -8,7 +8,7 @@ from pydantic.fields import ComputedFieldInfo, FieldInfo
|
||||
from pydantic_core import PydanticUndefined
|
||||
|
||||
from ...core.config import AppConfig
|
||||
from ...core.constants import APP_ASCII_ART, DISCORD_INVITE, PROJECT_NAME, REPO_HOME
|
||||
from ...core.constants import APP_ASCII_ART, CLI_NAME, DISCORD_INVITE, REPO_HOME
|
||||
|
||||
# The header for the config file.
|
||||
config_asci = "\n".join(
|
||||
@@ -28,7 +28,7 @@ CONFIG_HEADER = f"""
|
||||
CONFIG_FOOTER = f"""
|
||||
# ==============================================================================
|
||||
#
|
||||
# HOPE YOU ENJOY {PROJECT_NAME} AND BE SURE TO STAR THE PROJECT ON GITHUB
|
||||
# HOPE YOU ENJOY {CLI_NAME} AND BE SURE TO STAR THE PROJECT ON GITHUB
|
||||
# {REPO_HOME}
|
||||
#
|
||||
# Also join the discord server
|
||||
|
||||
@@ -34,12 +34,12 @@ class FeedbackService:
|
||||
try:
|
||||
from plyer import notification
|
||||
|
||||
from ....core.constants import ICON_PATH, PROJECT_NAME
|
||||
from ....core.constants import CLI_NAME, ICON_PATH
|
||||
|
||||
notification.notify( # type: ignore
|
||||
title=f"{PROJECT_NAME} notification".title(),
|
||||
title=f"{CLI_NAME} notification".title(),
|
||||
message=message,
|
||||
app_name=PROJECT_NAME,
|
||||
app_name=CLI_NAME,
|
||||
app_icon=str(ICON_PATH),
|
||||
timeout=self.app_config.general.desktop_notification_duration * 60,
|
||||
)
|
||||
@@ -60,12 +60,12 @@ class FeedbackService:
|
||||
try:
|
||||
from plyer import notification
|
||||
|
||||
from ....core.constants import ICON_PATH, PROJECT_NAME
|
||||
from ....core.constants import CLI_NAME, ICON_PATH
|
||||
|
||||
notification.notify( # type: ignore
|
||||
title=f"{PROJECT_NAME} notification".title(),
|
||||
title=f"{CLI_NAME} notification".title(),
|
||||
message=message,
|
||||
app_name=PROJECT_NAME,
|
||||
app_name=CLI_NAME,
|
||||
app_icon=str(ICON_PATH),
|
||||
timeout=self.app_config.general.desktop_notification_duration * 60,
|
||||
)
|
||||
@@ -87,12 +87,12 @@ class FeedbackService:
|
||||
try:
|
||||
from plyer import notification
|
||||
|
||||
from ....core.constants import ICON_PATH, PROJECT_NAME
|
||||
from ....core.constants import CLI_NAME, ICON_PATH
|
||||
|
||||
notification.notify( # type: ignore
|
||||
title=f"{PROJECT_NAME} notification".title(),
|
||||
title=f"{CLI_NAME} notification".title(),
|
||||
message=message,
|
||||
app_name=PROJECT_NAME,
|
||||
app_name=CLI_NAME,
|
||||
app_icon=str(ICON_PATH),
|
||||
timeout=self.app_config.general.desktop_notification_duration * 60,
|
||||
)
|
||||
@@ -113,12 +113,12 @@ class FeedbackService:
|
||||
try:
|
||||
from plyer import notification
|
||||
|
||||
from ....core.constants import ICON_PATH, PROJECT_NAME
|
||||
from ....core.constants import CLI_NAME, ICON_PATH
|
||||
|
||||
notification.notify( # type: ignore
|
||||
title=f"{PROJECT_NAME} notification".title(),
|
||||
title=f"{CLI_NAME} notification".title(),
|
||||
message=message,
|
||||
app_name=PROJECT_NAME,
|
||||
app_name=CLI_NAME,
|
||||
app_icon=str(ICON_PATH),
|
||||
timeout=self.app_config.general.desktop_notification_duration * 60,
|
||||
)
|
||||
@@ -169,12 +169,12 @@ class FeedbackService:
|
||||
try:
|
||||
from plyer import notification
|
||||
|
||||
from ....core.constants import ICON_PATH, PROJECT_NAME
|
||||
from ....core.constants import CLI_NAME, ICON_PATH
|
||||
|
||||
notification.notify( # type: ignore
|
||||
title=f"{PROJECT_NAME} notification".title(),
|
||||
title=f"{CLI_NAME} notification".title(),
|
||||
message="No current way to display info in rofi, use fzf and the terminal instead",
|
||||
app_name=PROJECT_NAME,
|
||||
app_name=CLI_NAME,
|
||||
app_icon=str(ICON_PATH),
|
||||
timeout=self.app_config.general.desktop_notification_duration * 60,
|
||||
)
|
||||
|
||||
@@ -9,13 +9,19 @@ import sys
|
||||
from httpx import get
|
||||
from rich import print
|
||||
|
||||
from ...core.constants import AUTHOR, GIT_REPO, PROJECT_NAME_LOWER, __version__
|
||||
from ...core.constants import (
|
||||
AUTHOR,
|
||||
CLI_NAME_LOWER,
|
||||
GIT_REPO,
|
||||
PROJECT_NAME,
|
||||
__version__,
|
||||
)
|
||||
|
||||
API_URL = f"https://api.{GIT_REPO}/repos/{AUTHOR}/{PROJECT_NAME_LOWER}/releases/latest"
|
||||
API_URL = f"https://api.{GIT_REPO}/repos/{AUTHOR}/{CLI_NAME_LOWER}/releases/latest"
|
||||
|
||||
|
||||
def check_for_updates():
|
||||
USER_AGENT = f"{PROJECT_NAME_LOWER} user"
|
||||
USER_AGENT = f"{CLI_NAME_LOWER} user"
|
||||
try:
|
||||
response = get(
|
||||
API_URL,
|
||||
@@ -96,9 +102,9 @@ def update_app(force=False):
|
||||
return False, release_json
|
||||
|
||||
process = subprocess.run(
|
||||
[NIX, "profile", "upgrade", PROJECT_NAME_LOWER], check=False
|
||||
[NIX, "profile", "upgrade", CLI_NAME_LOWER], check=False
|
||||
)
|
||||
elif is_git_repo(AUTHOR, PROJECT_NAME_LOWER):
|
||||
elif is_git_repo(AUTHOR, CLI_NAME_LOWER):
|
||||
GIT_EXECUTABLE = shutil.which("git")
|
||||
args = [
|
||||
GIT_EXECUTABLE,
|
||||
@@ -117,11 +123,9 @@ def update_app(force=False):
|
||||
)
|
||||
|
||||
elif UV := shutil.which("uv"):
|
||||
process = subprocess.run(
|
||||
[UV, "tool", "upgrade", PROJECT_NAME_LOWER], check=False
|
||||
)
|
||||
process = subprocess.run([UV, "tool", "upgrade", PROJECT_NAME], check=False)
|
||||
elif PIPX := shutil.which("pipx"):
|
||||
process = subprocess.run([PIPX, "upgrade", PROJECT_NAME_LOWER], check=False)
|
||||
process = subprocess.run([PIPX, "upgrade", PROJECT_NAME], check=False)
|
||||
else:
|
||||
PYTHON_EXECUTABLE = sys.executable
|
||||
|
||||
@@ -130,7 +134,7 @@ def update_app(force=False):
|
||||
"-m",
|
||||
"pip",
|
||||
"install",
|
||||
PROJECT_NAME_LOWER,
|
||||
PROJECT_NAME,
|
||||
"-U",
|
||||
"--no-warn-script-location",
|
||||
]
|
||||
|
||||
@@ -4,9 +4,10 @@ from importlib import metadata, resources
|
||||
from pathlib import Path
|
||||
|
||||
PLATFORM = sys.platform
|
||||
PROJECT_NAME = "VIU"
|
||||
PROJECT_NAME_LOWER = "viu"
|
||||
APP_NAME = os.environ.get(f"{PROJECT_NAME}_APP_NAME", PROJECT_NAME_LOWER)
|
||||
CLI_NAME = "VIU"
|
||||
CLI_NAME_LOWER = "viu"
|
||||
PROJECT_NAME = "viu-media"
|
||||
APP_NAME = os.environ.get(f"{CLI_NAME}_APP_NAME", CLI_NAME_LOWER)
|
||||
|
||||
USER_NAME = os.environ.get("USERNAME", "User")
|
||||
|
||||
@@ -24,7 +25,7 @@ ANILIST_AUTH = (
|
||||
)
|
||||
|
||||
try:
|
||||
APP_DIR = Path(str(resources.files(PROJECT_NAME.lower())))
|
||||
APP_DIR = Path(str(resources.files(CLI_NAME.lower())))
|
||||
|
||||
except ModuleNotFoundError:
|
||||
from pathlib import Path
|
||||
|
||||
@@ -54,15 +54,15 @@ class RofiSelector(BaseSelector):
|
||||
from plyer import notification
|
||||
|
||||
from ....core.constants import (
|
||||
CLI_NAME,
|
||||
CLI_NAME_LOWER,
|
||||
ICON_PATH,
|
||||
PROJECT_NAME,
|
||||
PROJECT_NAME_LOWER,
|
||||
)
|
||||
|
||||
notification.notify( # type: ignore
|
||||
title=f"{PROJECT_NAME} notification".title(),
|
||||
message=f"Nothing was selected {PROJECT_NAME_LOWER} is shutting down",
|
||||
app_name=PROJECT_NAME,
|
||||
title=f"{CLI_NAME} notification".title(),
|
||||
message=f"Nothing was selected {CLI_NAME_LOWER} is shutting down",
|
||||
app_name=CLI_NAME,
|
||||
app_icon=str(ICON_PATH),
|
||||
timeout=2 * 60,
|
||||
)
|
||||
@@ -120,15 +120,15 @@ class RofiSelector(BaseSelector):
|
||||
from plyer import notification
|
||||
|
||||
from ....core.constants import (
|
||||
CLI_NAME,
|
||||
CLI_NAME_LOWER,
|
||||
ICON_PATH,
|
||||
PROJECT_NAME,
|
||||
PROJECT_NAME_LOWER,
|
||||
)
|
||||
|
||||
notification.notify( # type: ignore
|
||||
title=f"{PROJECT_NAME} notification".title(),
|
||||
message=f"Nothing was selected {PROJECT_NAME_LOWER} is shutting down",
|
||||
app_name=PROJECT_NAME,
|
||||
title=f"{CLI_NAME} notification".title(),
|
||||
message=f"Nothing was selected {CLI_NAME_LOWER} is shutting down",
|
||||
app_name=CLI_NAME,
|
||||
app_icon=str(ICON_PATH),
|
||||
timeout=2 * 60,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user