Merge pull request #54 from smcclennon/dev/1.7.1

Handle Spiget api errors, use best-practice, disable incompatible code
This commit is contained in:
Neocky 2022-07-19 10:22:37 +02:00 committed by GitHub
commit 653dac6c2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 47 deletions

View File

@ -6,8 +6,8 @@ import os
try: try:
print("Installing Python packages and dependencies from requirements.txt...\n") print("Installing Python packages and dependencies from requirements.txt...\n")
os.system('py -m pip install -r requirements.txt' if os.name=='nt' else 'pip install -r requirements.txt') os.system('py -m pip install -r requirements.txt' if os.name=='nt' else 'python3 -m pip install -r requirements.txt')
print("\nStart pluGET by launching the 'pluGET.py' file!") print("\nStart pluGET by launching the 'pluGET.py' file!")
except: except Exception as e:
print("Requirements couldn't be installed. Check if file 'requirements.txt' is in the same folder and that Python3\ print(f"Requirements couldn't be installed.\nError message: {e}\n\nCommon solution: Check if file 'requirements.txt' is in the same folder and that Python3\
and pip is installed!") and pip is installed!")

View File

@ -520,6 +520,18 @@ def search_plugin_spiget(plugin_file: str, plugin_file_name: str, plugin_file_ve
""" """
url = f"https://api.spiget.org/v2/search/resources/{plugin_file_name}?field=name&sort=-downloads" url = f"https://api.spiget.org/v2/search/resources/{plugin_file_name}?field=name&sort=-downloads"
plugin_list = api_do_request(url) plugin_list = api_do_request(url)
# Handle failed api request
"""
{'error': 'Unexpected Exception', 'msg': 'Unexpected Exception. Please report this to
https://github.com/SpiGetOrg/api.spiget.org/issues'}
"""
if "error" in plugin_list:
rich_print_error(
f"[not bold]Error: Spiget error occurred whilst searching for plugin '{plugin_file}': {plugin_list['msg']}"
)
return plugin_list['msg']
else:
plugin_file_version2 = plugin_file_version plugin_file_version2 = plugin_file_version
for i in range(4): for i in range(4):
if i == 1: if i == 1:

View File

@ -21,6 +21,7 @@ def rename_console_title() -> None:
""" """
Renames the console title on first startup Renames the console title on first startup
""" """
if os.name == "nt":
os.system("title " + "pluGET │ By Neocky") os.system("title " + "pluGET │ By Neocky")
return None return None