mirror of
https://github.com/Neocky/pluGET.git
synced 2024-04-29 16:12:30 +00:00
Split everything in sub packages; Created main function; Added many exception handlers for SFTP
Added: - Split everything into sub packages - created a main file: __main__.py - added many exception handlings with SFTP Edited: - launcher.bat calls now the __main__.py file
This commit is contained in:
53
src/handlers/handle_config.py
Normal file
53
src/handlers/handle_config.py
Normal file
@@ -0,0 +1,53 @@
|
||||
import os.path
|
||||
import sys
|
||||
import configparser
|
||||
|
||||
from utils.consoleoutput import oColors
|
||||
|
||||
|
||||
def checkConfig():
|
||||
configAvailable = os.path.isfile("./config.ini")
|
||||
if not configAvailable:
|
||||
createConfig()
|
||||
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 = config['General']['PathToPluginFolder']
|
||||
|
||||
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']['PluginFolderForUpload']
|
||||
|
||||
sftp_port = int(sftp_port)
|
||||
if localPluginFolder == 'True':
|
||||
localPluginFolder = True
|
||||
else:
|
||||
localPluginFolder = False
|
||||
|
||||
return configValues
|
||||
|
||||
|
||||
def createConfig():
|
||||
config = configparser.ConfigParser(allow_no_value=True)
|
||||
config['General'] = {}
|
||||
config['General'][';'] = 'If a local plugin folder exists (True/False): (If False use SFTP)'
|
||||
config['General']['LocalPluginFolder'] = 'True'
|
||||
config['General']['PathToPluginFolder'] = 'C:\\Users\\USER\\Desktop\\plugins'
|
||||
config['SFTP - Remote Server'] = {}
|
||||
config['SFTP - Remote Server']['Server'] = '0.0.0.0'
|
||||
config['SFTP - Remote Server']['Username'] = 'user'
|
||||
config['SFTP - Remote Server']['Password'] = 'longpassword'
|
||||
config['SFTP - Remote Server'][';'] = 'Normally you won*t need to change anything below this line'
|
||||
config['SFTP - Remote Server']['Port'] = '22'
|
||||
config['SFTP - Remote Server']['PluginFolderForUpload'] = '.\\plugins'
|
||||
|
||||
with open('./config.ini', 'w') as configfile:
|
||||
config.write(configfile)
|
||||
Reference in New Issue
Block a user