mirror of
https://github.com/Neocky/pluGET.git
synced 2024-04-29 16:12:30 +00:00
Added first serverjar handling
This commit is contained in:
parent
0b10a76a3b
commit
9e74d480dd
@ -31,7 +31,6 @@ if __name__ == "__main__":
|
||||
validate_config()
|
||||
api_test_spiget()
|
||||
check_requirements()
|
||||
print(args)
|
||||
|
||||
if args["mode"] is not None and args["object"] is not None:
|
||||
# arguments were used so call the handle_input function to get the right function call
|
||||
|
@ -5,6 +5,7 @@ Handles the input through the pluGET command line
|
||||
from src.utils.console_output import rich_print_error
|
||||
from src.plugin.plugin_downloader import get_specific_plugin_spiget, search_specific_plugin_spiget
|
||||
from src.plugin.plugin_updatechecker import check_installed_plugins, update_installed_plugins
|
||||
from src.serverjar.serverjar_updatechecker import check_update_available_installed_server_jar
|
||||
|
||||
|
||||
# check
|
||||
@ -27,6 +28,14 @@ def handle_input(
|
||||
) -> None:
|
||||
"""
|
||||
Manages the correct function calling from the given input
|
||||
|
||||
:param input_command: Command of main function
|
||||
:param input_selected_object: Name of plugin/serverjar
|
||||
:param: input_parameter: Optional parameters
|
||||
:param no_confirmation: If plugins should be updated without no confirmation message
|
||||
:param arguments_from_console: If arguments were given on script call
|
||||
|
||||
:returns None:
|
||||
"""
|
||||
while True:
|
||||
# when arguemnts were not passed from console ask for input
|
||||
@ -56,8 +65,7 @@ def handle_input(
|
||||
case "check":
|
||||
match input_selected_object:
|
||||
case "serverjar":
|
||||
print("check serverjar")
|
||||
#checkInstalledServerjar()
|
||||
check_update_available_installed_server_jar()
|
||||
case _:
|
||||
check_installed_plugins(input_selected_object, input_parameter)
|
||||
|
||||
@ -81,9 +89,13 @@ def handle_input(
|
||||
return None
|
||||
|
||||
|
||||
def get_input() -> None:
|
||||
def get_input() -> str:
|
||||
"""
|
||||
Gets command line input and calls the handle input function
|
||||
|
||||
:returns: Main command to execute
|
||||
:returns: Selected Object to work with
|
||||
:returns: Optional parameter
|
||||
"""
|
||||
input_command = None
|
||||
print("\n'STRG + C' to exit")
|
||||
|
@ -139,7 +139,7 @@ def download_specific_plugin_version_spiget(plugin_id, download_path, version_id
|
||||
file_size_data = convert_file_size_down(convert_file_size_down(file_size))
|
||||
console.print(" [not bold][bright_green]Downloaded[bright_magenta] " + (str(file_size_data)).rjust(9) + \
|
||||
f" MB [cyan]→ [white]{download_path}")
|
||||
elif file_size < 1000000:
|
||||
else:
|
||||
file_size_data = convert_file_size_down(file_size)
|
||||
console.print(" [not bold][bright_green]Downloaded[bright_magenta] " + (str(file_size_data)).rjust(9) + \
|
||||
f" KB [cyan]→ [white]{download_path}")
|
||||
|
0
src/serverjar/__init__.py
Normal file
0
src/serverjar/__init__.py
Normal file
70
src/serverjar/serverjar_updatechecker.py
Normal file
70
src/serverjar/serverjar_updatechecker.py
Normal file
@ -0,0 +1,70 @@
|
||||
"""
|
||||
Checks the installed serverjar for updates
|
||||
"""
|
||||
|
||||
import os
|
||||
from rich.console import Console
|
||||
|
||||
from src.utils.console_output import rich_print_error
|
||||
from src.handlers.handle_config import config_value
|
||||
from src.handlers.handle_sftp import sftp_create_connection, sftp_list_files_in_server_root
|
||||
from src.handlers.handle_ftp import ftp_create_connection, ftp_list_files_in_server_root
|
||||
|
||||
|
||||
def get_installed_server_jar_file(config_values) -> str:
|
||||
"""
|
||||
Gets the file name of the installed server jar
|
||||
|
||||
:param config_values: Configuration values from pluGET config
|
||||
|
||||
:returns: Full file name of installed server jar
|
||||
"""
|
||||
match config_values.connection:
|
||||
case "sftp":
|
||||
connection = sftp_create_connection()
|
||||
file_list_server_root = sftp_list_files_in_server_root(connection)
|
||||
case "ftp":
|
||||
connection = ftp_create_connection()
|
||||
file_list_server_root = ftp_list_files_in_server_root(connection)
|
||||
case _:
|
||||
file_list_server_root = os.path.dirname(config_values.path_to_plugin_folder)
|
||||
file_list_server_root = os.listdir(file_list_server_root)
|
||||
|
||||
file_server_jar_full_name = None
|
||||
try:
|
||||
for file in file_list_server_root:
|
||||
try:
|
||||
if ".jar" in file:
|
||||
file_server_jar_full_name = file
|
||||
break
|
||||
except TypeError:
|
||||
continue
|
||||
except TypeError:
|
||||
rich_print_error("Error: Serverjar couldn't be found")
|
||||
return None
|
||||
return file_server_jar_full_name
|
||||
|
||||
|
||||
def check_update_available_installed_server_jar() -> None:
|
||||
"""
|
||||
Handles the checking of available updates of the installed server jar
|
||||
|
||||
:params: None
|
||||
"""
|
||||
config_values = config_value()
|
||||
rich_console = Console()
|
||||
file_server_jar_full_name = get_installed_server_jar_file(config_values)
|
||||
if file_server_jar_full_name == None:
|
||||
# print error and exit function
|
||||
rich_print_error("Error: Serverjar couldn't be found")
|
||||
return None
|
||||
|
||||
rich_console.print(f"[not bold][cyan]Checking: [bright_magenta]{file_server_jar_full_name}")
|
||||
|
||||
# TODO: Add other serverjars here
|
||||
if "paper" in file_server_jar_full_name:
|
||||
print("paper check update")
|
||||
print(file_server_jar_full_name)
|
||||
|
||||
else:
|
||||
rich_print_error(f"{file_server_jar_full_name} isn't supported")
|
@ -5,4 +5,4 @@ PLUGETVERSION = current version of pluGET
|
||||
"""
|
||||
|
||||
# constant values
|
||||
PLUGETVERSION = "1.6.8"
|
||||
PLUGETVERSION = "1.7.0"
|
||||
|
Loading…
Reference in New Issue
Block a user