mirror of
https://github.com/Neocky/pluGET.git
synced 2024-04-29 16:12:30 +00:00
finished config handling and started new console output
Finished the yaml config handling and started console handling output
This commit is contained in:
parent
993d438ff7
commit
4920689f0e
22
pluGET.py
22
pluGET.py
@ -1,7 +1,17 @@
|
|||||||
# Main function for pluGET
|
"""
|
||||||
import argparse
|
Handles the main function and the argument passing for the whole pluGET program
|
||||||
|
"""
|
||||||
|
|
||||||
from src.handlers.handle_config import check_config, config_value
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# check if folder 'src' is accessible with all modules needed and if not exit
|
||||||
|
try:
|
||||||
|
from src.handlers.handle_config import check_config, validate_config, config_value
|
||||||
|
from src.utils.console_output import rename_console_title, clear_console, print_logo
|
||||||
|
except:
|
||||||
|
print("Folder 'src' not found in the directory or missing files detected! Please redownload the files from here: https://www.github.com/Neocky/pluGET")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
@ -25,9 +35,13 @@ if __name__ == "__main__":
|
|||||||
#createInputLists()
|
#createInputLists()
|
||||||
#printMainMenu()
|
#printMainMenu()
|
||||||
#getInput()
|
#getInput()
|
||||||
|
rename_console_title()
|
||||||
|
clear_console()
|
||||||
|
print_logo()
|
||||||
config = config_value()
|
config = config_value()
|
||||||
|
validate_config()
|
||||||
print(config.connection)
|
print(config.connection)
|
||||||
print(config.path_to_plugin_folder)
|
print(config.path_to_plugin_folder)
|
||||||
print(config.sftp_port)
|
print(config.sftp_port)
|
||||||
print(config.local_seperate_download_path)
|
print(config.local_seperate_download_path)
|
||||||
|
input()
|
||||||
|
@ -6,13 +6,14 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import ruamel.yaml
|
import ruamel.yaml
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from rich.console import Console
|
||||||
|
|
||||||
|
|
||||||
class config_value():
|
class config_value():
|
||||||
"""
|
"""
|
||||||
Class which holds all the available configuration values from the config file and which will be used later in
|
Class which holds all the available configuration values from the config file and which will be used later in
|
||||||
the process of updating plugins
|
the process of updating plugins
|
||||||
|
If bool in config can't be read it will default to 'False'
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
yaml = ruamel.yaml.YAML()
|
yaml = ruamel.yaml.YAML()
|
||||||
@ -21,15 +22,21 @@ class config_value():
|
|||||||
self.connection = data["Connection"]
|
self.connection = data["Connection"]
|
||||||
self.path_to_plugin_folder = Path(data["Local"]["PathToPluginFolder"])
|
self.path_to_plugin_folder = Path(data["Local"]["PathToPluginFolder"])
|
||||||
self.local_seperate_download_path = True if data["Local"]["SeperateDownloadPath"] == True else False
|
self.local_seperate_download_path = True if data["Local"]["SeperateDownloadPath"] == True else False
|
||||||
self.path_to_seperate_download_path = Path(data["Local"]["PathToSeperateDownloadPath"])
|
self.local_path_to_seperate_download_path = Path(data["Local"]["PathToSeperateDownloadPath"])
|
||||||
|
self.server = data["Remote"]["Server"]
|
||||||
|
self.username = data["Remote"]["Server"]
|
||||||
|
self.password = data["Remote"]["Password"]
|
||||||
self.sftp_port = int(data["Remote"]["SFTP_Port"])
|
self.sftp_port = int(data["Remote"]["SFTP_Port"])
|
||||||
|
self.ftp_port = int(data["Remote"]["FTP_Port"])
|
||||||
|
self.remote_seperate_download_path = True if data["Remote"]["SeperateDownloadPath"] == True else False
|
||||||
|
self.remote_path_to_seperate_download_path = data["Remote"]["PathToSeperateDownloadPath"]
|
||||||
|
self.remote_plugin_folder_on_server = data["Remote"]["PluginFolderOnServer"]
|
||||||
|
|
||||||
|
|
||||||
def check_config() -> None:
|
def check_config() -> None:
|
||||||
"""
|
"""
|
||||||
Check if there is a pluget_config.yml file in the same folder as pluget.py and if not create a new config
|
Check if there is a pluget_config.yml file in the same folder as pluget.py and if not create a new config
|
||||||
and exit the programm.
|
and exit the programm
|
||||||
"""
|
"""
|
||||||
if not os.path.isfile("pluget_config.yaml"):
|
if not os.path.isfile("pluget_config.yaml"):
|
||||||
create_config()
|
create_config()
|
||||||
@ -82,11 +89,21 @@ def create_config() -> None:
|
|||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
def validate_config() -> bool:
|
def validate_config() -> None:
|
||||||
"""
|
"""
|
||||||
Validates the config variables after config class is loaded
|
Validates the config variables after config class is loaded and exit if error is detected and print error
|
||||||
"""
|
"""
|
||||||
accepted_values = [
|
accepted_values = [
|
||||||
("local", "sftp", "ftp"),
|
("local", "sftp", "ftp")
|
||||||
("true", "false")
|
|
||||||
]
|
]
|
||||||
|
# exit afterwards if there is an error in config
|
||||||
|
exit_afterwards = False
|
||||||
|
config = config_value()
|
||||||
|
# rich console for nice colors
|
||||||
|
console = Console()
|
||||||
|
if (config.connection).lower() not in accepted_values[0]:
|
||||||
|
console.print(f"Error in Config! Accepted values for key 'Connection' are {accepted_values[0]}",
|
||||||
|
style="bright_red")
|
||||||
|
exit_afterwards = True
|
||||||
|
if exit_afterwards:
|
||||||
|
sys.exit()
|
||||||
|
73
src/utils/console_output.py
Normal file
73
src/utils/console_output.py
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
"""
|
||||||
|
Handles the console on first startup of pluGET and prints logo and sets title
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
from rich.console import Console
|
||||||
|
|
||||||
|
|
||||||
|
def rename_console_title() -> None:
|
||||||
|
"""
|
||||||
|
Renames the console title on first startup
|
||||||
|
"""
|
||||||
|
os.system("title " + "pluGET │ By Neocky")
|
||||||
|
|
||||||
|
|
||||||
|
def clear_console() -> None:
|
||||||
|
"""
|
||||||
|
Clears the console on first startup
|
||||||
|
"""
|
||||||
|
os.system('cls' if os.name=='nt' else 'clear')
|
||||||
|
|
||||||
|
def print_logo() -> None:
|
||||||
|
console = Console()
|
||||||
|
# line 1
|
||||||
|
console.print()
|
||||||
|
# line 2
|
||||||
|
console.print(" ██████",style="bright_magenta", end='')
|
||||||
|
console.print("╗ ", style="bright_yellow", end='')
|
||||||
|
console.print("██", style="bright_magenta", end='')
|
||||||
|
console.print("╗ ", style="bright_yellow", end='')
|
||||||
|
console.print("██", style="bright_magenta", end='')
|
||||||
|
console.print("╗ ", style="bright_yellow", end='')
|
||||||
|
console.print("██", style="bright_magenta", end='')
|
||||||
|
console.print("╗ ", style="bright_yellow", end='')
|
||||||
|
console.print("██████", style="bright_magenta", end='')
|
||||||
|
console.print("╗ ", style="bright_yellow", end='')
|
||||||
|
console.print("███████", style="bright_magenta", end='')
|
||||||
|
console.print("╗", style="bright_yellow", end='')
|
||||||
|
console.print("████████", style="bright_magenta", end='')
|
||||||
|
console.print("╗", style="bright_yellow")
|
||||||
|
# line 3
|
||||||
|
console.print(" ██", style="bright_magenta", end='')
|
||||||
|
console.print("╔══", style="bright_yellow", end='')
|
||||||
|
console.print("██", style="bright_magenta", end='')
|
||||||
|
console.print("╗", style="bright_yellow", end='')
|
||||||
|
console.print("██", style="bright_magenta", end='')
|
||||||
|
console.print("║ ", style="bright_yellow", end='')
|
||||||
|
console.print("██", style="bright_magenta", end='')
|
||||||
|
console.print("║ ", style="bright_yellow", end='')
|
||||||
|
console.print("██", style="bright_magenta", end='')
|
||||||
|
console.print("║", style="bright_yellow", end='')
|
||||||
|
console.print("██", style="bright_magenta", end='')
|
||||||
|
console.print("╔════╝ ", style="bright_yellow", end='')
|
||||||
|
console.print("██", style="bright_magenta", end='')
|
||||||
|
console.print("╔════╝╚══", style="bright_yellow", end='')
|
||||||
|
console.print("██", style="bright_magenta", end='')
|
||||||
|
console.print("╔══╝", style="bright_yellow")
|
||||||
|
# line 4
|
||||||
|
console.print(" ██████╔╝██║ ██║ ██║██║ ███╗█████╗ ██║ ")
|
||||||
|
# line 5
|
||||||
|
console.print(" ██╔═══╝ ██║ ██║ ██║██║ ██║██╔══╝ ██║ ")
|
||||||
|
# line 6
|
||||||
|
console.print(" ██║ ███████╗╚██████╔╝╚██████╔╝███████╗ ██║ ")
|
||||||
|
# line 7
|
||||||
|
console.print(" ╚═╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ", style="bright_yellow")
|
||||||
|
|
||||||
|
|
||||||
|
console.print(" ┌────────────────────────────────────┐", style="bright_black")
|
||||||
|
#print(" │ [" + oColors.brightMagenta + "By Neocky" +oColors.brightBlack +
|
||||||
|
# "] │ " + oColors.standardWhite)
|
||||||
|
#print(oColors.brightBlack + " │ " + oColors.brightMagenta + "https://github.com/Neocky/pluGET" + oColors.brightBlack +
|
||||||
|
# " │ " + oColors.standardWhite)
|
||||||
|
#print(oColors.brightBlack + " └────────────────────────────────────┘" + oColors.standardWhite)
|
Loading…
Reference in New Issue
Block a user