Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/fttb/cmds/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import requests

from ..utils import get_code, parse_version, download_file, VersionError
from ..utils import get_code, parse_version, download_file, VersionError, IdeNotFoundError


def set_download_parser(parser: ArgumentParser):
Expand Down Expand Up @@ -49,7 +49,12 @@ def download_cmd(args, config_fttb):
if args.ide == "all":
print("invalid IDE code")
return
ide_code = get_code(args.ide, config_fttb)
try:
ide_code = get_code(args.ide, config_fttb)
except IdeNotFoundError:
print(f"{args.ide} not found")
return

try:
version = parse_version(ide_code, args.version, args.type)
except VersionError:
Expand Down
9 changes: 7 additions & 2 deletions src/fttb/cmds/infos.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@

import requests

from ..utils import get_code
from ..utils import get_code, IdeNotFoundError


def set_infos_parser(parser: ArgumentParser):
parser.add_argument("ide", nargs="?", default="all")


def infos_cmd(args, config_fttb):
ide = get_code(args.ide, config_fttb)
try:
ide = get_code(args.ide, config_fttb)
except IdeNotFoundError:
print(f"{args.ide} not found")
return

res = requests.get(
f"https://data.services.jetbrains.com/products?"
f"fields=name,intellijProductCode,description,categories&"
Expand Down
8 changes: 6 additions & 2 deletions src/fttb/cmds/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import requests

from ..utils import get_code
from ..utils import get_code, IdeNotFoundError


def set_list_parser(parser: ArgumentParser):
Expand All @@ -32,7 +32,11 @@ def list_cmd(args, config_fttb):
if "IDE" in ide['categories']:
print(f"{ide['name']}\n{ide['description']}\n")
else:
ide_code = get_code(args.ide, config_fttb)
try:
ide_code = get_code(args.ide, config_fttb)
except IdeNotFoundError:
print(f"{args.ide} not found")
return
res = requests.get(
f"https://data.services.jetbrains.com/products?code={ide_code}&fields=releases")
if not res.ok:
Expand Down
16 changes: 12 additions & 4 deletions src/fttb/cmds/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import requests

from ..utils import get_code, parse_version
from ..utils import get_code, parse_version, IdeNotFoundError


def set_remove_parser(parser: ArgumentParser):
Expand All @@ -16,7 +16,11 @@ def set_remove_parser(parser: ArgumentParser):


def remove_all_versions(args, config_fttb):
ide_code = get_code(args.ide, config_fttb)
try:
ide_code = get_code(args.ide, config_fttb)
except IdeNotFoundError:
print(f"{args.ide} not found")
return
for f in glob.glob(f"{config_fttb['install_path']}/{ide_code}-*"):
shutil.rmtree(f)

Expand All @@ -27,8 +31,12 @@ def remove_cmd(args, config_fttb):
return
if args.version == "all":
return remove_all_versions(args, config_fttb)
ide_code = get_code(args.ide, config_fttb)

try:
ide_code = get_code(args.ide, config_fttb)
except IdeNotFoundError:
print(f"{args.ide} not found")
return

res = requests.get(
f"https://data.services.jetbrains.com/products?code={ide_code}&fields=releases")
if not res.ok:
Expand Down
9 changes: 7 additions & 2 deletions src/fttb/cmds/use.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import requests

from ..cmds.download import download_ide
from ..utils import get_code, parse_version, VersionError
from ..utils import get_code, parse_version, VersionError, IdeNotFoundError


def set_use_parser(parser: ArgumentParser):
Expand Down Expand Up @@ -67,7 +67,12 @@ def generate_entry(ide, ide_code, version, config_fttb):


def use_cmd(args, config_fttb):
ide_code = get_code(args.ide, config_fttb)
try:
ide_code = get_code(args.ide, config_fttb)
except IdeNotFoundError:
print(f"{args.ide} not found")
return

try:
version = parse_version(ide_code, args.version, args.type)
except VersionError:
Expand Down
6 changes: 5 additions & 1 deletion src/fttb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class VersionError(Exception):
pass


class IdeNotFoundError(Exception):
pass


def get_versions_list() -> list[str]:
with open("/tmp/ft_tb/versions.list", "r") as list_file:
return list_file.read().splitlines()
Expand Down Expand Up @@ -75,7 +79,7 @@ def get_code(name, config_fttp: dict):
return name
if name in config_fttp['aliases'].keys():
return config_fttp['aliases'][name]
return name
raise IdeNotFoundError


def download_file(url, dst):
Expand Down