Better config handling & better output for serverjar

Changes:
- better config handling
- better output for serverjar checking
This commit is contained in:
Neocky
2021-03-27 12:07:19 +01:00
parent 17611c741e
commit fddc0c252c
9 changed files with 100 additions and 127 deletions

View File

@@ -7,43 +7,41 @@ from utils.consoleoutput import oColors
class configurationValues:
def __init__(self):
config = configparser.ConfigParser()
config.sections()
config.read("config.ini")
localPluginFolder = config['General']['LocalPluginFolder']
self.pathToPluginFolder = Path(config['General']['PathToPluginFolder'])
seperateDownloadPath = config['General']['SeperateDownloadPath']
self.pathToSeperateDownloadPath = Path(config['General']['PathToSeperateDownloadPath'])
config = configparser.ConfigParser()
config.sections()
config.read("config.ini")
localPluginFolder = config['General']['LocalPluginFolder']
pathToPluginFolder = Path(config['General']['PathToPluginFolder'])
seperateDownloadPath = config['General']['SeperateDownloadPath']
pathToSeperateDownloadPath = Path(config['General']['PathToSeperateDownloadPath'])
self.sftp_server = config['SFTP - Remote Server']['Server']
self.sftp_user = config['SFTP - Remote Server']['Username']
self.sftp_password = config['SFTP - Remote Server']['Password']
sftp_port = config['SFTP - Remote Server']['Port']
self.sftp_folderPath = config['SFTP - Remote Server']['PluginFolderOnServer']
sftp_seperateDownloadPath = config['SFTP - Remote Server']['SeperateDownloadPath']
self.sftp_pathToSeperateDownloadPath = config['SFTP - Remote Server']['PathToSeperateDownloadPath']
sftp_server = config['SFTP - Remote Server']['Server']
sftp_user = config['SFTP - Remote Server']['Username']
sftp_password = config['SFTP - Remote Server']['Password']
sftp_port = config['SFTP - Remote Server']['Port']
sftp_folderPath = config['SFTP - Remote Server']['PluginFolderOnServer']
sftp_seperateDownloadPath = config['SFTP - Remote Server']['SeperateDownloadPath']
sftp_pathToSeperateDownloadPath = config['SFTP - Remote Server']['PathToSeperateDownloadPath']
self.sftp_port = int(sftp_port)
if localPluginFolder == 'True':
self.localPluginFolder = True
else:
self.localPluginFolder = False
sftp_port = int(sftp_port)
if localPluginFolder == 'True':
localPluginFolder = True
else:
localPluginFolder = False
if seperateDownloadPath == 'True':
self.seperateDownloadPath = True
else:
self.seperateDownloadPath = False
if sftp_seperateDownloadPath == 'True':
self.sftp_seperateDownloadPath = True
else:
self.sftp_seperateDownloadPath = False
if seperateDownloadPath == 'True':
seperateDownloadPath = True
else:
seperateDownloadPath = False
if sftp_seperateDownloadPath == 'True':
sftp_seperateDownloadPath = True
else:
sftp_seperateDownloadPath = False
def checkConfig():
currentFolder = os.getcwd()
#currentFolder = os.getcwd()
configAvailable = os.path.isfile("config.ini")
if not configAvailable:
@@ -51,42 +49,7 @@ def checkConfig():
print(oColors.brightRed + "Config created. Edit config before executing again!" + oColors.standardWhite)
input("Press any key + enter to exit...")
sys.exit()
#class configValues:
# config = configparser.ConfigParser()
# config.sections()
# config.read("config.ini")
# localPluginFolder = config['General']['LocalPluginFolder']
# pathToPluginFolder = Path(config['General']['PathToPluginFolder'])
# seperateDownloadPath = config['General']['SeperateDownloadPath']
# pathToSeperateDownloadPath = Path(config['General']['PathToSeperateDownloadPath'])
# sftp_server = config['SFTP - Remote Server']['Server']
# sftp_user = config['SFTP - Remote Server']['Username']
# sftp_password = config['SFTP - Remote Server']['Password']
# sftp_port = config['SFTP - Remote Server']['Port']
# sftp_folderPath = config['SFTP - Remote Server']['PluginFolderOnServer']
# sftp_seperateDownloadPath = config['SFTP - Remote Server']['SeperateDownloadPath']
# sftp_pathToSeperateDownloadPath = config['SFTP - Remote Server']['PathToSeperateDownloadPath']
# sftp_port = int(sftp_port)
# if localPluginFolder == 'True':
# localPluginFolder = True
# else:
# localPluginFolder = False
# if seperateDownloadPath == 'True':
# seperateDownloadPath = True
# else:
# seperateDownloadPath = False
# if sftp_seperateDownloadPath == 'True':
# sftp_seperateDownloadPath = True
# else:
# sftp_seperateDownloadPath = False
os.chdir(currentFolder)
#return configValues
#os.chdir(currentFolder)
def createConfig():

View File

@@ -2,7 +2,7 @@ import sys
from utils.consoleoutput import oColors
from utils.utilities import getHelp, getCommandHelp
from handlers.handle_config import checkConfig
from handlers.handle_config import configurationValues
from plugin.plugin_downloader import searchPackage, getSpecificPackage
from plugin.plugin_updatechecker import updateInstalledPackage, checkInstalledPackage
from plugin.plugin_remover import removePlugin
@@ -30,21 +30,22 @@ def createInputLists():
def handleInput(inputCommand, inputSelectedObject, inputParams):
configValues = configurationValues()
while True:
if inputCommand == 'get':
if inputSelectedObject.isdigit():
if not checkConfig().localPluginFolder:
if checkConfig().sftp_seperateDownloadPath is True:
pluginPath = checkConfig().sftp_pathToSeperateDownloadPath
if not configValues.localPluginFolder:
if configValues.sftp_seperateDownloadPath is True:
pluginPath = configValues.sftp_pathToSeperateDownloadPath
else:
pluginPath = checkConfig().sftp_folderPath
pluginPath = configValues.sftp_folderPath
getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
break
else:
if checkConfig().seperateDownloadPath is True:
pluginPath = checkConfig().pathToSeperateDownloadPath
if configValues.seperateDownloadPath is True:
pluginPath = configValues.pathToSeperateDownloadPath
else:
pluginPath = checkConfig().pathToPluginFolder
pluginPath = configValues.pathToPluginFolder
getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
break
else: