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 :
2021-03-27 17:58:16 +00:00
def __init__ ( self ) :
config = configparser . ConfigParser ( )
config . sections ( )
config . read ( " config.ini " )
2021-03-30 21:55:04 +00:00
localPluginFolder = config [ ' General ' ] [ ' UseLocalPluginFolder ' ]
self . pathToPluginFolder = Path ( config [ ' Local - This Machine ' ] [ ' PathToPluginFolder ' ] )
seperateDownloadPath = config [ ' Local - This Machine ' ] [ ' SeperateDownloadPath ' ]
self . pathToSeperateDownloadPath = Path ( config [ ' Local - This Machine ' ] [ ' PathToSeperateDownloadPath ' ] )
2021-03-27 17:58:16 +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-30 21:55:04 +00:00
sftp_port = config [ ' SFTP - Remote Server ' ] [ ' SFTPPort ' ]
2021-03-27 17:58:16 +00:00
self . sftp_folderPath = config [ ' SFTP - Remote Server ' ] [ ' PluginFolderOnServer ' ]
2021-03-30 21:55:04 +00:00
sftp_useSftp = config [ ' SFTP - Remote Server ' ] [ ' USE_SFTP ' ]
2021-03-27 17:58:16 +00:00
sftp_seperateDownloadPath = config [ ' SFTP - Remote Server ' ] [ ' SeperateDownloadPath ' ]
self . sftp_pathToSeperateDownloadPath = config [ ' SFTP - Remote Server ' ] [ ' PathToSeperateDownloadPath ' ]
self . sftp_port = int ( sftp_port )
if localPluginFolder == ' True ' :
self . localPluginFolder = True
else :
self . 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
2021-03-26 19:24:15 +00:00
2021-03-30 21:55:04 +00:00
if sftp_useSftp == ' True ' :
self . sftp_useSftp = True
else :
self . sftp_useSftp = False
2021-03-26 19:24:15 +00:00
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 ( )
2021-03-08 21:13:57 +00:00
def createConfig ( ) :
config = configparser . ConfigParser ( allow_no_value = True )
config [ ' General ' ] = { }
2021-03-30 21:55:04 +00:00
config [ ' General ' ] [ ' ; ' ] = ' If a local plugin folder exists (True/False) (If False SFTP/FTP will be used): '
config [ ' General ' ] [ ' UseLocalPluginFolder ' ] = ' True '
config [ ' Local - This Machine ' ] = { }
config [ ' Local - This Machine ' ] [ ' PathToPluginFolder ' ] = ' C:/Users/USER/Desktop/plugins '
config [ ' Local - This Machine ' ] [ ' ; ' ] = ' For a different folder to store the updated plugins change to (True/False) and the path below '
config [ ' Local - This Machine ' ] [ ' SeperateDownloadPath ' ] = ' False '
config [ ' Local - This Machine ' ] [ ' 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-30 21:55:04 +00:00
config [ ' SFTP - Remote Server ' ] [ ' ; ' ] = ' If a different Port for SFTP needs to be used (Works only for SFTP) '
config [ ' SFTP - Remote Server ' ] [ ' SFTPPort ' ] = ' 22 '
config [ ' SFTP - Remote Server ' ] [ ' ;_ ' ] = ' Change the path below if the plugin folder path is different on the SFTP/FTP server (Change only if you know what you are doing) '
config [ ' SFTP - Remote Server ' ] [ ' PluginFolderOnServer ' ] = ' ./plugins '
config [ ' SFTP - Remote Server ' ] [ ' ;__ ' ] = ' If you want to use FTP instead of SFTP change to (False) else use (True) '
config [ ' SFTP - Remote Server ' ] [ ' USE_SFTP ' ] = ' True '
config [ ' SFTP - Remote Server ' ] [ ' ;___ ' ] = ' For a different folder to store the updated plugins (Only with the update command!) change to (True/False) and the path below '
2021-03-14 12:25:13 +00:00
config [ ' SFTP - Remote Server ' ] [ ' SeperateDownloadPath ' ] = ' False '
2021-03-30 21:55:04 +00:00
config [ ' SFTP - Remote Server ' ] [ ' PathToSeperateDownloadPath ' ] = ' ./plugins '
2021-03-14 12:25:13 +00:00
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 )