2021-03-13 21:09:32 +00:00
|
|
|
import os
|
2021-03-08 21:13:57 +00:00
|
|
|
import sys
|
|
|
|
import configparser
|
2021-03-16 00:04:13 +00:00
|
|
|
from pathlib import Path
|
2021-03-08 21:13:57 +00:00
|
|
|
|
2021-03-12 00:39:39 +00:00
|
|
|
from utils.consoleoutput import oColors
|
2021-03-08 21:13:57 +00:00
|
|
|
|
|
|
|
|
2021-03-26 19:24:15 +00:00
|
|
|
class configurationValues:
|
|
|
|
def __init__(self):
|
2021-03-08 21:13:57 +00:00
|
|
|
config = configparser.ConfigParser()
|
|
|
|
config.sections()
|
|
|
|
config.read("config.ini")
|
2021-03-10 01:05:56 +00:00
|
|
|
localPluginFolder = config['General']['LocalPluginFolder']
|
2021-03-26 19:24:15 +00:00
|
|
|
self.pathToPluginFolder = Path(config['General']['PathToPluginFolder'])
|
2021-03-14 12:25:13 +00:00
|
|
|
seperateDownloadPath = config['General']['SeperateDownloadPath']
|
2021-03-26 19:24:15 +00:00
|
|
|
self.pathToSeperateDownloadPath = Path(config['General']['PathToSeperateDownloadPath'])
|
2021-03-10 01:05:56 +00:00
|
|
|
|
2021-03-26 19:24:15 +00:00
|
|
|
self.sftp_server = config['SFTP - Remote Server']['Server']
|
|
|
|
self.sftp_user = config['SFTP - Remote Server']['Username']
|
|
|
|
self.sftp_password = config['SFTP - Remote Server']['Password']
|
2021-03-12 00:39:39 +00:00
|
|
|
sftp_port = config['SFTP - Remote Server']['Port']
|
2021-03-26 19:24:15 +00:00
|
|
|
self.sftp_folderPath = config['SFTP - Remote Server']['PluginFolderOnServer']
|
2021-03-14 12:25:13 +00:00
|
|
|
sftp_seperateDownloadPath = config['SFTP - Remote Server']['SeperateDownloadPath']
|
2021-03-26 19:24:15 +00:00
|
|
|
self.sftp_pathToSeperateDownloadPath = config['SFTP - Remote Server']['PathToSeperateDownloadPath']
|
2021-03-10 01:05:56 +00:00
|
|
|
|
2021-03-26 19:24:15 +00:00
|
|
|
self.sftp_port = int(sftp_port)
|
2021-03-10 01:05:56 +00:00
|
|
|
if localPluginFolder == 'True':
|
2021-03-26 19:24:15 +00:00
|
|
|
self.localPluginFolder = True
|
2021-03-10 01:05:56 +00:00
|
|
|
else:
|
2021-03-26 19:24:15 +00:00
|
|
|
self.localPluginFolder = False
|
2021-03-14 12:25:13 +00:00
|
|
|
|
|
|
|
if seperateDownloadPath == 'True':
|
2021-03-26 19:24:15 +00:00
|
|
|
self.seperateDownloadPath = True
|
2021-03-14 12:25:13 +00:00
|
|
|
else:
|
2021-03-26 19:24:15 +00:00
|
|
|
self.seperateDownloadPath = False
|
2021-03-14 12:25:13 +00:00
|
|
|
|
|
|
|
if sftp_seperateDownloadPath == 'True':
|
2021-03-26 19:24:15 +00:00
|
|
|
self.sftp_seperateDownloadPath = True
|
2021-03-14 12:25:13 +00:00
|
|
|
else:
|
2021-03-26 19:24:15 +00:00
|
|
|
self.sftp_seperateDownloadPath = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def checkConfig():
|
|
|
|
currentFolder = os.getcwd()
|
|
|
|
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 = 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
|
2021-03-10 01:05:56 +00:00
|
|
|
|
2021-03-13 21:09:32 +00:00
|
|
|
os.chdir(currentFolder)
|
2021-03-26 19:24:15 +00:00
|
|
|
#return configValues
|
2021-03-08 21:13:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
def createConfig():
|
|
|
|
config = configparser.ConfigParser(allow_no_value=True)
|
|
|
|
config['General'] = {}
|
2021-03-13 21:09:32 +00:00
|
|
|
config['General'][';'] = 'If a local plugin folder exists (True/False): (If False SFTP will be used)'
|
2021-03-08 21:13:57 +00:00
|
|
|
config['General']['LocalPluginFolder'] = 'True'
|
2021-03-17 23:03:07 +00:00
|
|
|
config['General']['PathToPluginFolder'] = 'C:/Users/USER/Desktop/plugins'
|
2021-03-14 12:25:13 +00:00
|
|
|
config['General'][';_'] = 'If you want a different folder to store the updated plugins change to (True/False) and the path below'
|
|
|
|
config['General']['SeperateDownloadPath'] = 'False'
|
2021-03-17 23:03:07 +00:00
|
|
|
config['General']['PathToSeperateDownloadPath'] = 'C:/Users/USER/Desktop/plugins'
|
2021-03-14 12:25:13 +00:00
|
|
|
|
2021-03-12 00:39:39 +00:00
|
|
|
config['SFTP - Remote Server'] = {}
|
|
|
|
config['SFTP - Remote Server']['Server'] = '0.0.0.0'
|
|
|
|
config['SFTP - Remote Server']['Username'] = 'user'
|
2021-03-13 21:09:32 +00:00
|
|
|
config['SFTP - Remote Server']['Password'] = 'password'
|
2021-03-12 00:39:39 +00:00
|
|
|
config['SFTP - Remote Server'][';'] = 'Normally you won*t need to change anything below this line'
|
|
|
|
config['SFTP - Remote Server']['Port'] = '22'
|
2021-03-14 12:25:13 +00:00
|
|
|
config['SFTP - Remote Server']['PluginFolderOnServer'] = '.\\plugins'
|
|
|
|
config['SFTP - Remote Server'][';_'] = 'If you want a different folder to store the updated plugins change to (True/False) and the path below'
|
|
|
|
config['SFTP - Remote Server']['SeperateDownloadPath'] = 'False'
|
|
|
|
config['SFTP - Remote Server']['PathToSeperateDownloadPath'] = '.\\plugins'
|
|
|
|
|
2021-03-08 21:13:57 +00:00
|
|
|
|
2021-03-16 00:04:13 +00:00
|
|
|
with open('config.ini', 'w') as configfile:
|
2021-03-08 21:13:57 +00:00
|
|
|
config.write(configfile)
|