mirror of
https://github.com/Neocky/pluGET.git
synced 2024-04-29 16:12:30 +00:00
commit
aceca0dec3
@ -6,52 +6,49 @@ from pathlib import Path
|
|||||||
from utils.consoleoutput import oColors
|
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'])
|
||||||
|
|
||||||
|
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']
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
def checkConfig():
|
def checkConfig():
|
||||||
currentFolder = os.getcwd()
|
|
||||||
configAvailable = os.path.isfile("config.ini")
|
configAvailable = os.path.isfile("config.ini")
|
||||||
|
|
||||||
if not configAvailable:
|
if not configAvailable:
|
||||||
createConfig()
|
createConfig()
|
||||||
print(oColors.brightRed + "Config created. Edit config before executing again!" + oColors.standardWhite)
|
print(oColors.brightRed + "Config created. Edit config before executing again!" + oColors.standardWhite)
|
||||||
input("Press any key + enter to exit...")
|
input("Press any key + enter to exit...")
|
||||||
sys.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
|
|
||||||
|
|
||||||
|
|
||||||
def createConfig():
|
def createConfig():
|
||||||
config = configparser.ConfigParser(allow_no_value=True)
|
config = configparser.ConfigParser(allow_no_value=True)
|
||||||
|
@ -2,7 +2,7 @@ import sys
|
|||||||
|
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from utils.utilities import getHelp, getCommandHelp
|
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_downloader import searchPackage, getSpecificPackage
|
||||||
from plugin.plugin_updatechecker import updateInstalledPackage, checkInstalledPackage
|
from plugin.plugin_updatechecker import updateInstalledPackage, checkInstalledPackage
|
||||||
from plugin.plugin_remover import removePlugin
|
from plugin.plugin_remover import removePlugin
|
||||||
@ -30,21 +30,22 @@ def createInputLists():
|
|||||||
|
|
||||||
|
|
||||||
def handleInput(inputCommand, inputSelectedObject, inputParams):
|
def handleInput(inputCommand, inputSelectedObject, inputParams):
|
||||||
|
configValues = configurationValues()
|
||||||
while True:
|
while True:
|
||||||
if inputCommand == 'get':
|
if inputCommand == 'get':
|
||||||
if inputSelectedObject.isdigit():
|
if inputSelectedObject.isdigit():
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
if checkConfig().sftp_seperateDownloadPath is True:
|
if configValues.sftp_seperateDownloadPath is True:
|
||||||
pluginPath = checkConfig().sftp_pathToSeperateDownloadPath
|
pluginPath = configValues.sftp_pathToSeperateDownloadPath
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().sftp_folderPath
|
pluginPath = configValues.sftp_folderPath
|
||||||
getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
|
getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if checkConfig().seperateDownloadPath is True:
|
if configValues.seperateDownloadPath is True:
|
||||||
pluginPath = checkConfig().pathToSeperateDownloadPath
|
pluginPath = configValues.pathToSeperateDownloadPath
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().pathToPluginFolder
|
pluginPath = configValues.pathToPluginFolder
|
||||||
getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
|
getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -5,18 +5,11 @@ from pathlib import Path
|
|||||||
|
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from utils.web_request import doAPIRequest
|
from utils.web_request import doAPIRequest
|
||||||
from utils.utilities import createTempPluginFolder, deleteTempPluginFolder
|
from utils.utilities import createTempPluginFolder, deleteTempPluginFolder, calculateFileSizeKb, calculateFileSizeMb
|
||||||
from handlers.handle_config import checkConfig
|
from handlers.handle_config import configurationValues
|
||||||
from handlers.handle_sftp import sftp_upload_file, sftp_cdPluginDir, createSFTPConnection
|
from handlers.handle_sftp import sftp_upload_file, sftp_cdPluginDir, createSFTPConnection
|
||||||
|
|
||||||
|
|
||||||
def calculateFileSize(downloadFileSize):
|
|
||||||
fileSizeDownload = int(downloadFileSize)
|
|
||||||
fileSizeKb = fileSizeDownload / 1024
|
|
||||||
roundedFileSize = round(fileSizeKb, 2)
|
|
||||||
return roundedFileSize
|
|
||||||
|
|
||||||
|
|
||||||
def handleRegexPackageName(packageNameFull):
|
def handleRegexPackageName(packageNameFull):
|
||||||
packageNameFull2 = packageNameFull
|
packageNameFull2 = packageNameFull
|
||||||
# trims the part of the package that has for example "[1.1 Off]" in it
|
# trims the part of the package that has for example "[1.1 Off]" in it
|
||||||
@ -58,6 +51,7 @@ def getVersionName(packageId, versionId):
|
|||||||
|
|
||||||
|
|
||||||
def searchPackage(ressourceName):
|
def searchPackage(ressourceName):
|
||||||
|
configValues = configurationValues()
|
||||||
url = f"https://api.spiget.org/v2/search/resources/{ressourceName}?field=name&sort=-downloads"
|
url = f"https://api.spiget.org/v2/search/resources/{ressourceName}?field=name&sort=-downloads"
|
||||||
packageName = doAPIRequest(url)
|
packageName = doAPIRequest(url)
|
||||||
i = 1
|
i = 1
|
||||||
@ -78,19 +72,20 @@ def searchPackage(ressourceName):
|
|||||||
if ressourceSelected != 0:
|
if ressourceSelected != 0:
|
||||||
ressourceSelected = ressourceSelected - 1
|
ressourceSelected = ressourceSelected - 1
|
||||||
ressourceId = packageName[ressourceSelected]["id"]
|
ressourceId = packageName[ressourceSelected]["id"]
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
try:
|
try:
|
||||||
getSpecificPackage(ressourceId, checkConfig().sftp_folderPath)
|
getSpecificPackage(ressourceId, configValues.sftp_folderPath)
|
||||||
except HTTPError as err:
|
except HTTPError as err:
|
||||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
getSpecificPackage(ressourceId, checkConfig().pathToPluginFolder)
|
getSpecificPackage(ressourceId, configValues.pathToPluginFolder)
|
||||||
except HTTPError as err:
|
except HTTPError as err:
|
||||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||||
|
|
||||||
|
|
||||||
def downloadSpecificVersion(ressourceId, downloadPath, versionID='latest'):
|
def downloadSpecificVersion(ressourceId, downloadPath, versionID='latest'):
|
||||||
|
configValues = configurationValues()
|
||||||
if versionID != 'latest':
|
if versionID != 'latest':
|
||||||
#url = f"https://spigotmc.org/resources/{ressourceId}/download?version={versionID}"
|
#url = f"https://spigotmc.org/resources/{ressourceId}/download?version={versionID}"
|
||||||
print(oColors.brightRed + "Sorry but specific version downloads aren't supported because of cloudflare protection. :(" + oColors.standardWhite)
|
print(oColors.brightRed + "Sorry but specific version downloads aren't supported because of cloudflare protection. :(" + oColors.standardWhite)
|
||||||
@ -102,16 +97,22 @@ def downloadSpecificVersion(ressourceId, downloadPath, versionID='latest'):
|
|||||||
remotefile = urllib.request.urlopen(url)
|
remotefile = urllib.request.urlopen(url)
|
||||||
filesize = remotefile.info()['Content-Length']
|
filesize = remotefile.info()['Content-Length']
|
||||||
urllib.request.urlretrieve(url, downloadPath)
|
urllib.request.urlretrieve(url, downloadPath)
|
||||||
filesizeData = calculateFileSize(filesize)
|
filesize = int(filesize)
|
||||||
print(f"Downloadsize: {filesizeData} KB")
|
print(" ", end='')
|
||||||
print(f"File downloaded here: {downloadPath}")
|
if filesize >= 1000000:
|
||||||
if not checkConfig().localPluginFolder:
|
filesizeData = calculateFileSizeMb(filesize)
|
||||||
|
print("Downloaded " + (str(filesizeData)).rjust(9) + f" MB here {downloadPath}")
|
||||||
|
else:
|
||||||
|
filesizeData = calculateFileSizeKb(filesize)
|
||||||
|
print("Downloaded " + (str(filesizeData)).rjust(9) + f" KB here {downloadPath}")
|
||||||
|
if not configValues.localPluginFolder:
|
||||||
sftpSession = createSFTPConnection()
|
sftpSession = createSFTPConnection()
|
||||||
sftp_upload_file(sftpSession, downloadPath)
|
sftp_upload_file(sftpSession, downloadPath)
|
||||||
|
|
||||||
|
|
||||||
def getSpecificPackage(ressourceId, downloadPath, inputPackageVersion='latest'):
|
def getSpecificPackage(ressourceId, downloadPath, inputPackageVersion='latest'):
|
||||||
if checkConfig().localPluginFolder == False:
|
configValues = configurationValues()
|
||||||
|
if configValues.localPluginFolder == False:
|
||||||
downloadPath = createTempPluginFolder()
|
downloadPath = createTempPluginFolder()
|
||||||
url = f"https://api.spiget.org/v2/resources/{ressourceId}"
|
url = f"https://api.spiget.org/v2/resources/{ressourceId}"
|
||||||
packageDetails = doAPIRequest(url)
|
packageDetails = doAPIRequest(url)
|
||||||
@ -121,13 +122,13 @@ def getSpecificPackage(ressourceId, downloadPath, inputPackageVersion='latest'):
|
|||||||
packageVersion = getVersionName(ressourceId, versionId)
|
packageVersion = getVersionName(ressourceId, versionId)
|
||||||
packageDownloadName = f"{packageNameNew}-{packageVersion}.jar"
|
packageDownloadName = f"{packageNameNew}-{packageVersion}.jar"
|
||||||
downloadPackagePath = Path(f"{downloadPath}/{packageDownloadName}")
|
downloadPackagePath = Path(f"{downloadPath}/{packageDownloadName}")
|
||||||
if checkConfig().localPluginFolder:
|
if configValues.localPluginFolder:
|
||||||
if inputPackageVersion is None or inputPackageVersion == 'latest':
|
if inputPackageVersion is None or inputPackageVersion == 'latest':
|
||||||
downloadSpecificVersion(ressourceId=ressourceId, downloadPath=downloadPackagePath)
|
downloadSpecificVersion(ressourceId=ressourceId, downloadPath=downloadPackagePath)
|
||||||
else:
|
else:
|
||||||
downloadSpecificVersion(ressourceId, downloadPackagePath, versionId)
|
downloadSpecificVersion(ressourceId, downloadPackagePath, versionId)
|
||||||
|
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
if inputPackageVersion is None or inputPackageVersion == 'latest':
|
if inputPackageVersion is None or inputPackageVersion == 'latest':
|
||||||
downloadSpecificVersion(ressourceId=ressourceId, downloadPath=downloadPackagePath)
|
downloadSpecificVersion(ressourceId=ressourceId, downloadPath=downloadPackagePath)
|
||||||
deleteTempPluginFolder(downloadPath)
|
deleteTempPluginFolder(downloadPath)
|
||||||
|
@ -3,18 +3,19 @@ import re
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from handlers.handle_config import checkConfig
|
from handlers.handle_config import configurationValues
|
||||||
from handlers.handle_sftp import createSFTPConnection, sftp_listAll
|
from handlers.handle_sftp import createSFTPConnection, sftp_listAll
|
||||||
from plugin.plugin_updatechecker import getFileName, getFileVersion, getInstalledPlugin, createPluginList
|
from plugin.plugin_updatechecker import getFileName, getFileVersion, getInstalledPlugin, createPluginList
|
||||||
|
|
||||||
|
|
||||||
def removePlugin(pluginToRemove):
|
def removePlugin(pluginToRemove):
|
||||||
|
configValues = configurationValues()
|
||||||
createPluginList()
|
createPluginList()
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
sftp = createSFTPConnection()
|
sftp = createSFTPConnection()
|
||||||
pluginList = sftp_listAll(sftp)
|
pluginList = sftp_listAll(sftp)
|
||||||
else:
|
else:
|
||||||
pluginList = os.listdir(checkConfig().pathToPluginFolder)
|
pluginList = os.listdir(configValues.pathToPluginFolder)
|
||||||
i = 0
|
i = 0
|
||||||
try:
|
try:
|
||||||
for plugin in pluginList:
|
for plugin in pluginList:
|
||||||
@ -28,8 +29,8 @@ def removePlugin(pluginToRemove):
|
|||||||
|
|
||||||
if pluginToRemove == pluginIdStr or re.search(pluginToRemove, fileName, re.IGNORECASE):
|
if pluginToRemove == pluginIdStr or re.search(pluginToRemove, fileName, re.IGNORECASE):
|
||||||
print(f"Removing: {fileName}")
|
print(f"Removing: {fileName}")
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
pluginPath = checkConfig().sftp_folderPath
|
pluginPath = configValues.sftp_folderPath
|
||||||
pluginPath = f"{pluginPath}/{plugin}"
|
pluginPath = f"{pluginPath}/{plugin}"
|
||||||
sftp = createSFTPConnection()
|
sftp = createSFTPConnection()
|
||||||
sftp.remove(pluginPath)
|
sftp.remove(pluginPath)
|
||||||
@ -37,7 +38,7 @@ def removePlugin(pluginToRemove):
|
|||||||
i += 1
|
i += 1
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().pathToPluginFolder
|
pluginPath = configValues.pathToPluginFolder
|
||||||
pluginPath = Path(f"{pluginPath}/{plugin}")
|
pluginPath = Path(f"{pluginPath}/{plugin}")
|
||||||
os.remove(pluginPath)
|
os.remove(pluginPath)
|
||||||
print(f"Removed: {fileName}")
|
print(f"Removed: {fileName}")
|
||||||
|
@ -8,7 +8,7 @@ from rich.progress import track
|
|||||||
|
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from utils.web_request import doAPIRequest
|
from utils.web_request import doAPIRequest
|
||||||
from handlers.handle_config import checkConfig
|
from handlers.handle_config import configurationValues
|
||||||
from handlers.handle_sftp import createSFTPConnection, sftp_listAll
|
from handlers.handle_sftp import createSFTPConnection, sftp_listAll
|
||||||
from plugin.plugin_downloader import getSpecificPackage
|
from plugin.plugin_downloader import getSpecificPackage
|
||||||
|
|
||||||
@ -64,10 +64,11 @@ def compareVersions(plugin_latest_version, pluginVersion):
|
|||||||
|
|
||||||
|
|
||||||
def eggCrackingJar(localJarFileName):
|
def eggCrackingJar(localJarFileName):
|
||||||
if not checkConfig().localPluginFolder:
|
configValues = configurationValues()
|
||||||
pluginPath = checkConfig().sftp_folderPath
|
if not configValues.localPluginFolder:
|
||||||
|
pluginPath = configValues.sftp_folderPath
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().pathToPluginFolder
|
pluginPath = configValues.pathToPluginFolder
|
||||||
pathToPluginJar = Path(f"{pluginPath}/{localJarFileName}")
|
pathToPluginJar = Path(f"{pluginPath}/{localJarFileName}")
|
||||||
pluginVersion = ''
|
pluginVersion = ''
|
||||||
with ZipFile(pathToPluginJar, 'r') as pluginJar:
|
with ZipFile(pathToPluginJar, 'r') as pluginJar:
|
||||||
@ -86,20 +87,21 @@ def eggCrackingJar(localJarFileName):
|
|||||||
|
|
||||||
|
|
||||||
def checkInstalledPackage(inputSelectedObject="all"):
|
def checkInstalledPackage(inputSelectedObject="all"):
|
||||||
|
configValues = configurationValues()
|
||||||
createPluginList()
|
createPluginList()
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
sftp = createSFTPConnection()
|
sftp = createSFTPConnection()
|
||||||
pluginList = sftp_listAll(sftp)
|
pluginList = sftp_listAll(sftp)
|
||||||
else:
|
else:
|
||||||
pluginList = os.listdir(checkConfig().pathToPluginFolder)
|
pluginList = os.listdir(configValues.pathToPluginFolder)
|
||||||
i = 0
|
i = 0
|
||||||
oldPackages = 0
|
oldPlugins = 0
|
||||||
print(oColors.brightBlack + f"Checking: {inputSelectedObject}" + oColors.standardWhite)
|
print(oColors.brightBlack + f"Checking: {inputSelectedObject}" + oColors.standardWhite)
|
||||||
print("┌─────┬────────────────────────────────┬──────────────┬───────────┬───────────────────┐")
|
print("┌─────┬────────────────────────────────┬──────────────┬──────────────┬───────────────────┐")
|
||||||
print("│ No. │ Name │ Installed V. │ Latest V. │ Update available │")
|
print("│ No. │ Name │ Installed V. │ Latest V. │ Update available │")
|
||||||
print("└─────┴────────────────────────────────┴──────────────┴───────────┴───────────────────┘")
|
print("└─────┴────────────────────────────────┴──────────────┴──────────────┴───────────────────┘")
|
||||||
try:
|
try:
|
||||||
for plugin in track(pluginList, description="Checking for updates" ,transient=True, complete_style="cyan"):
|
for plugin in track(pluginList, description="Checking for updates" ,transient=True, complete_style="bright_yellow"):
|
||||||
try:
|
try:
|
||||||
fileName = getFileName(plugin)
|
fileName = getFileName(plugin)
|
||||||
fileVersion = getFileVersion(plugin)
|
fileVersion = getFileVersion(plugin)
|
||||||
@ -127,42 +129,45 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
|||||||
pluginIsOutdated = 'N/A'
|
pluginIsOutdated = 'N/A'
|
||||||
|
|
||||||
if pluginIsOutdated == True:
|
if pluginIsOutdated == True:
|
||||||
oldPackages = oldPackages + 1
|
oldPlugins = oldPlugins + 1
|
||||||
|
|
||||||
if inputSelectedObject != "*" and inputSelectedObject != "all":
|
if inputSelectedObject != "*" and inputSelectedObject != "all":
|
||||||
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
||||||
if pluginLatestVersion == 'N/A':
|
if pluginLatestVersion == 'N/A':
|
||||||
print(oColors.brightBlack + f" [{1}]".ljust(8), end='')
|
print(oColors.brightBlack + f" [{1}]".rjust(6), end='')
|
||||||
else:
|
else:
|
||||||
print(f" [{1}]".ljust(8), end='')
|
print(f" [{1}]".rjust(6), end='')
|
||||||
|
print(" ", end='')
|
||||||
print(f"{fileName}".ljust(33), end='')
|
print(f"{fileName}".ljust(33), end='')
|
||||||
print(f"{fileVersion}".ljust(15), end='')
|
print(f"{fileVersion}".ljust(15), end='')
|
||||||
print(f"{pluginLatestVersion}".ljust(12), end='')
|
print(f"{pluginLatestVersion}".ljust(15), end='')
|
||||||
print(f" {pluginIsOutdated}".ljust(5) + oColors.standardWhite)
|
print(f"{pluginIsOutdated}".ljust(5) + oColors.standardWhite)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if pluginLatestVersion == 'N/A':
|
if pluginLatestVersion == 'N/A':
|
||||||
print(oColors.brightBlack + f" [{i+1}]".ljust(8), end='')
|
print(oColors.brightBlack + f" [{i+1}]".rjust(6), end='')
|
||||||
else:
|
else:
|
||||||
print(f" [{i+1}]".ljust(8), end='')
|
print(f" [{i+1}]".rjust(6), end='')
|
||||||
|
print(" ", end='')
|
||||||
print(f"{fileName}".ljust(33), end='')
|
print(f"{fileName}".ljust(33), end='')
|
||||||
print(f"{fileVersion}".ljust(15), end='')
|
print(f"{fileVersion}".ljust(15), end='')
|
||||||
print(f"{pluginLatestVersion}".ljust(12), end='')
|
print(f"{pluginLatestVersion}".ljust(15), end='')
|
||||||
print(f" {pluginIsOutdated}".ljust(5) + oColors.standardWhite)
|
print(f"{pluginIsOutdated}".ljust(5) + oColors.standardWhite)
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print(oColors.brightRed + "Error occured: Aborted checking for updates." + oColors.standardWhite)
|
print(oColors.brightRed + "Error occured: Aborted checking for updates." + oColors.standardWhite)
|
||||||
print(oColors.brightYellow + f"Old packages: [{oldPackages}/{i}]" + oColors.standardWhite)
|
print(oColors.brightYellow + f"Outdated plugins: [{oldPlugins}/{i}]" + oColors.standardWhite)
|
||||||
|
|
||||||
|
|
||||||
def updateInstalledPackage(inputSelectedObject='all'):
|
def updateInstalledPackage(inputSelectedObject='all'):
|
||||||
|
configValues = configurationValues()
|
||||||
createPluginList()
|
createPluginList()
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
sftp = createSFTPConnection()
|
sftp = createSFTPConnection()
|
||||||
pluginList = sftp_listAll(sftp)
|
pluginList = sftp_listAll(sftp)
|
||||||
else:
|
else:
|
||||||
pluginList = os.listdir(checkConfig().pathToPluginFolder)
|
pluginList = os.listdir(configValues.pathToPluginFolder)
|
||||||
i = 0
|
i = 0
|
||||||
pluginsUpdated = 0
|
pluginsUpdated = 0
|
||||||
indexNumberUpdated = 0
|
indexNumberUpdated = 0
|
||||||
@ -171,7 +176,7 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
print("│ No. │ Name │ Old V. │ New V. │")
|
print("│ No. │ Name │ Old V. │ New V. │")
|
||||||
print("└─────┴────────────────────────────────┴────────────┴──────────┘")
|
print("└─────┴────────────────────────────────┴────────────┴──────────┘")
|
||||||
try:
|
try:
|
||||||
for plugin in track(pluginList, description="Updating" ,transient=True, complete_style="red"):
|
for plugin in track(pluginList, description="Updating" ,transient=True, complete_style="bright_magenta"):
|
||||||
try:
|
try:
|
||||||
fileName = getFileName(plugin)
|
fileName = getFileName(plugin)
|
||||||
fileVersion = getFileVersion(plugin)
|
fileVersion = getFileVersion(plugin)
|
||||||
@ -189,24 +194,25 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
continue
|
continue
|
||||||
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
||||||
if INSTALLEDPLUGINLIST[i][3] == True:
|
if INSTALLEDPLUGINLIST[i][3] == True:
|
||||||
print(f" [{indexNumberUpdated+1}]".ljust(8), end='')
|
print(f" [{indexNumberUpdated+1}]".rjust(6), end='')
|
||||||
|
print(" ", end='')
|
||||||
print(f"{fileName}".ljust(33), end='')
|
print(f"{fileName}".ljust(33), end='')
|
||||||
print(f"{fileVersion}".ljust(8), end='')
|
print(f"{fileVersion}".ljust(13), end='')
|
||||||
print(" ", end='')
|
#print(" ", end='')
|
||||||
print(f"{latestVersion}".ljust(8))
|
print(f"{latestVersion}".ljust(13))
|
||||||
|
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
if checkConfig().sftp_seperateDownloadPath is True:
|
if configValues.sftp_seperateDownloadPath is True:
|
||||||
pluginPath = checkConfig().sftp_pathToSeperateDownloadPath
|
pluginPath = configValues.sftp_pathToSeperateDownloadPath
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().sftp_folderPath
|
pluginPath = configValues.sftp_folderPath
|
||||||
pluginPath = Path(f"{pluginPath}/{plugin}")
|
pluginPath = Path(f"{pluginPath}/{plugin}")
|
||||||
sftp = createSFTPConnection()
|
sftp = createSFTPConnection()
|
||||||
indexNumberUpdated += 1
|
indexNumberUpdated += 1
|
||||||
pluginsUpdated += 1
|
pluginsUpdated += 1
|
||||||
try:
|
try:
|
||||||
getSpecificPackage(pluginId, checkConfig().sftp_folderPath)
|
getSpecificPackage(pluginId, configValues.sftp_folderPath)
|
||||||
if checkConfig().sftp_seperateDownloadPath is False:
|
if configValues.sftp_seperateDownloadPath is False:
|
||||||
sftp.remove(pluginPath)
|
sftp.remove(pluginPath)
|
||||||
except HTTPError as err:
|
except HTTPError as err:
|
||||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||||
@ -214,16 +220,16 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(oColors.brightRed + "Error: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
print(oColors.brightRed + "Error: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
||||||
else:
|
else:
|
||||||
if checkConfig().seperateDownloadPath is True:
|
if configValues.seperateDownloadPath is True:
|
||||||
pluginPath = checkConfig().pathToSeperateDownloadPath
|
pluginPath = configValues.pathToSeperateDownloadPath
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().pathToPluginFolder
|
pluginPath = configValues.pathToPluginFolder
|
||||||
pluginPath = Path(f"{pluginPath}/{plugin}")
|
pluginPath = Path(f"{pluginPath}/{plugin}")
|
||||||
indexNumberUpdated += 1
|
indexNumberUpdated += 1
|
||||||
pluginsUpdated += 1
|
pluginsUpdated += 1
|
||||||
try:
|
try:
|
||||||
getSpecificPackage(pluginId, checkConfig().pathToPluginFolder)
|
getSpecificPackage(pluginId, configValues.pathToPluginFolder)
|
||||||
if checkConfig().seperateDownloadPath is False:
|
if configValues.seperateDownloadPath is False:
|
||||||
os.remove(pluginPath)
|
os.remove(pluginPath)
|
||||||
except HTTPError as err:
|
except HTTPError as err:
|
||||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||||
@ -238,24 +244,25 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
|
|
||||||
if inputSelectedObject == 'all':
|
if inputSelectedObject == 'all':
|
||||||
if INSTALLEDPLUGINLIST[i][3] == True:
|
if INSTALLEDPLUGINLIST[i][3] == True:
|
||||||
print(f" [{indexNumberUpdated+1}]".ljust(8), end='')
|
print(f" [{indexNumberUpdated+1}]".rjust(6), end='')
|
||||||
|
print(" ", end='')
|
||||||
print(f"{fileName}".ljust(33), end='')
|
print(f"{fileName}".ljust(33), end='')
|
||||||
print(f"{fileVersion}".ljust(8), end='')
|
print(f"{fileVersion}".ljust(13), end='')
|
||||||
print(" ", end='')
|
#print(" ", end='')
|
||||||
print(f"{latestVersion}".ljust(8))
|
print(f"{latestVersion}".ljust(13))
|
||||||
|
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
if checkConfig().sftp_seperateDownloadPath is True:
|
if configValues.sftp_seperateDownloadPath is True:
|
||||||
pluginPath = checkConfig().sftp_pathToSeperateDownloadPath
|
pluginPath = configValues.sftp_pathToSeperateDownloadPath
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().sftp_folderPath
|
pluginPath = configValues.sftp_folderPath
|
||||||
pluginPath = f"{pluginPath}/{plugin}"
|
pluginPath = f"{pluginPath}/{plugin}"
|
||||||
sftp = createSFTPConnection()
|
sftp = createSFTPConnection()
|
||||||
indexNumberUpdated += 1
|
indexNumberUpdated += 1
|
||||||
pluginsUpdated += 1
|
pluginsUpdated += 1
|
||||||
try:
|
try:
|
||||||
getSpecificPackage(pluginId, checkConfig().sftp_folderPath)
|
getSpecificPackage(pluginId, configValues.sftp_folderPath)
|
||||||
if checkConfig().sftp_seperateDownloadPath is False:
|
if configValues.sftp_seperateDownloadPath is False:
|
||||||
sftp.remove(pluginPath)
|
sftp.remove(pluginPath)
|
||||||
except HTTPError as err:
|
except HTTPError as err:
|
||||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||||
@ -264,16 +271,16 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
print(oColors.brightRed + f"Error: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
print(oColors.brightRed + f"Error: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if checkConfig().seperateDownloadPath is True:
|
if configValues.seperateDownloadPath is True:
|
||||||
pluginPath = checkConfig().pathToSeperateDownloadPath
|
pluginPath = configValues.pathToSeperateDownloadPath
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().pathToPluginFolder
|
pluginPath = configValues.pathToPluginFolder
|
||||||
pluginPath = Path(f"{pluginPath}/{plugin}")
|
pluginPath = Path(f"{pluginPath}/{plugin}")
|
||||||
indexNumberUpdated += 1
|
indexNumberUpdated += 1
|
||||||
pluginsUpdated += 1
|
pluginsUpdated += 1
|
||||||
try:
|
try:
|
||||||
getSpecificPackage(pluginId, checkConfig().pathToPluginFolder)
|
getSpecificPackage(pluginId, configValues.pathToPluginFolder)
|
||||||
if checkConfig().seperateDownloadPath is False:
|
if configValues.seperateDownloadPath is False:
|
||||||
os.remove(pluginPath)
|
os.remove(pluginPath)
|
||||||
except HTTPError as err:
|
except HTTPError as err:
|
||||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||||
@ -284,7 +291,7 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
i = i + 1
|
i = i + 1
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print(oColors.brightRed + "Error occured: Aborted updating for plugins." + oColors.standardWhite)
|
print(oColors.brightRed + "Error occured: Aborted updating for plugins." + oColors.standardWhite)
|
||||||
print(oColors.brightYellow + f"[{pluginsUpdated}/{i}] Plugins updated" + oColors.standardWhite)
|
print(oColors.brightYellow + f"Plugins updated: [{pluginsUpdated}/{i}]" + oColors.standardWhite)
|
||||||
if inputSelectedObject =='all' and pluginsUpdated == 0:
|
if inputSelectedObject =='all' and pluginsUpdated == 0:
|
||||||
print(oColors.brightGreen + "All found plugins are on the latest version!" + oColors.standardWhite)
|
print(oColors.brightGreen + "All found plugins are on the latest version!" + oColors.standardWhite)
|
||||||
|
|
||||||
|
@ -4,17 +4,18 @@ from urllib.error import HTTPError
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from handlers.handle_sftp import createSFTPConnection, sftp_listFilesInServerRoot
|
from handlers.handle_sftp import createSFTPConnection, sftp_listFilesInServerRoot
|
||||||
from handlers.handle_config import checkConfig
|
from handlers.handle_config import configurationValues
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from serverjar.serverjar_paper import paperCheckForUpdate, papermc_downloader
|
from serverjar.serverjar_paper import paperCheckForUpdate, papermc_downloader
|
||||||
|
|
||||||
|
|
||||||
def checkInstalledServerjar():
|
def checkInstalledServerjar():
|
||||||
if not checkConfig().localPluginFolder:
|
configValues = configurationValues()
|
||||||
|
if not configValues.localPluginFolder:
|
||||||
sftp = createSFTPConnection()
|
sftp = createSFTPConnection()
|
||||||
serverRootList = sftp_listFilesInServerRoot(sftp)
|
serverRootList = sftp_listFilesInServerRoot(sftp)
|
||||||
else:
|
else:
|
||||||
serverRootList = os.path.dirname(checkConfig().pathToPluginFolder)
|
serverRootList = os.path.dirname(configValues.pathToPluginFolder)
|
||||||
serverRootList = os.listdir(serverRootList)
|
serverRootList = os.listdir(serverRootList)
|
||||||
installedServerjarFullName = None
|
installedServerjarFullName = None
|
||||||
try:
|
try:
|
||||||
@ -34,7 +35,7 @@ def checkInstalledServerjar():
|
|||||||
print(oColors.brightRed + "Aborting the process." + oColors.standardWhite)
|
print(oColors.brightRed + "Aborting the process." + oColors.standardWhite)
|
||||||
input("Press any key + enter to exit...")
|
input("Press any key + enter to exit...")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
print(oColors.brightBlack + f"Checking: {installedServerjarFullName}" + oColors.standardWhite)
|
||||||
if 'paper' in installedServerjarFullName:
|
if 'paper' in installedServerjarFullName:
|
||||||
paperCheckForUpdate(installedServerjarFullName)
|
paperCheckForUpdate(installedServerjarFullName)
|
||||||
|
|
||||||
@ -44,19 +45,20 @@ def checkInstalledServerjar():
|
|||||||
|
|
||||||
|
|
||||||
def updateServerjar(serverJarBuild='latest'):
|
def updateServerjar(serverJarBuild='latest'):
|
||||||
|
configValues = configurationValues()
|
||||||
try:
|
try:
|
||||||
if serverJarBuild == None:
|
if serverJarBuild == None:
|
||||||
serverJarBuild = 'latest'
|
serverJarBuild = 'latest'
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
sftp = createSFTPConnection()
|
sftp = createSFTPConnection()
|
||||||
serverRootPath = checkConfig().sftp_folderPath
|
serverRootPath = configValues.sftp_folderPath
|
||||||
serverRootPath = Path(str(serverRootPath).replace(r'/plugins', ''))
|
serverRootPath = Path(str(serverRootPath).replace(r'/plugins', ''))
|
||||||
serverRootList = sftp_listFilesInServerRoot(sftp)
|
serverRootList = sftp_listFilesInServerRoot(sftp)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
serverRoot = os.path.dirname(checkConfig().pathToPluginFolder)
|
serverRoot = os.path.dirname(configValues.pathToPluginFolder)
|
||||||
serverRootList = os.listdir(serverRoot)
|
serverRootList = os.listdir(serverRoot)
|
||||||
serverRootPath = checkConfig().pathToPluginFolder
|
serverRootPath = configValues.pathToPluginFolder
|
||||||
helpPath = Path('/plugins')
|
helpPath = Path('/plugins')
|
||||||
helpPathstr = str(helpPath)
|
helpPathstr = str(helpPath)
|
||||||
serverRootPath = Path(str(serverRootPath).replace(helpPathstr, ''))
|
serverRootPath = Path(str(serverRootPath).replace(helpPathstr, ''))
|
||||||
@ -90,8 +92,8 @@ def updateServerjar(serverJarBuild='latest'):
|
|||||||
serverJarPath = Path(f"{serverRootPath}/{installedServerjarFullName}")
|
serverJarPath = Path(f"{serverRootPath}/{installedServerjarFullName}")
|
||||||
|
|
||||||
if 'paper' in installedServerjarFullName:
|
if 'paper' in installedServerjarFullName:
|
||||||
print(f"Updating Paper to build: {serverJarBuild}")
|
print(oColors.brightBlack + f"Updating Paper to build: {serverJarBuild}" + oColors.standardWhite)
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
try:
|
try:
|
||||||
papermc_downloader(serverJarBuild, installedServerjarFullName)
|
papermc_downloader(serverJarBuild, installedServerjarFullName)
|
||||||
sftp.remove(serverJarPath)
|
sftp.remove(serverJarPath)
|
||||||
|
@ -3,11 +3,12 @@ import sys
|
|||||||
import re
|
import re
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from rich.console import Console
|
||||||
|
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from utils.web_request import doAPIRequest
|
from utils.web_request import doAPIRequest
|
||||||
from handlers.handle_sftp import sftp_upload_server_jar, sftp_cdPluginDir, createSFTPConnection
|
from handlers.handle_sftp import sftp_upload_server_jar, sftp_cdPluginDir, createSFTPConnection
|
||||||
from handlers.handle_config import checkConfig
|
from handlers.handle_config import configurationValues
|
||||||
from utils.utilities import createTempPluginFolder, deleteTempPluginFolder, calculateFileSizeMb
|
from utils.utilities import createTempPluginFolder, deleteTempPluginFolder, calculateFileSizeMb
|
||||||
|
|
||||||
|
|
||||||
@ -107,23 +108,25 @@ def paperCheckForUpdate(installedServerjarFullName):
|
|||||||
paperLatestBuild = findLatestBuild(versionGroup)
|
paperLatestBuild = findLatestBuild(versionGroup)
|
||||||
paperVersionBehind = versionBehind(paperInstalledBuild, paperLatestBuild)
|
paperVersionBehind = versionBehind(paperInstalledBuild, paperLatestBuild)
|
||||||
|
|
||||||
print(f"Paper for {mcVersion}")
|
print("┌─────┬────────────────────────────────┬──────────────┬──────────────┬───────────────────┐")
|
||||||
print("Index | Name | Installed V. | Latest V. | Versions behind ")
|
print("│ No. │ Name │ Installed V. │ Latest V. │ Versions behind │")
|
||||||
print(f" [1]".ljust(8), end='')
|
print("└─────┴────────────────────────────────┴──────────────┴──────────────┴───────────────────┘")
|
||||||
print(f"paper".ljust(21), end='')
|
print(" [1]".rjust(6), end='')
|
||||||
print(f"{paperInstalledBuild}".ljust(8), end='')
|
print(" ", end='')
|
||||||
print(" ", end='')
|
print("paper".ljust(33), end='')
|
||||||
print(f"{paperLatestBuild}".ljust(8), end='')
|
print(f"{paperInstalledBuild}".ljust(15), end='')
|
||||||
print(" ", end='')
|
print(f"{paperLatestBuild}".ljust(15), end='')
|
||||||
print(f"{paperVersionBehind}".ljust(8))
|
print(f"{paperVersionBehind}".ljust(8))
|
||||||
|
print(oColors.brightYellow + f"Versions behind: [{paperVersionBehind}]" + oColors.standardWhite)
|
||||||
|
|
||||||
|
|
||||||
# https://papermc.io/api/docs/swagger-ui/index.html?configUrl=/api/openapi/swagger-config#/
|
# https://papermc.io/api/docs/swagger-ui/index.html?configUrl=/api/openapi/swagger-config#/
|
||||||
def papermc_downloader(paperBuild='latest', installedServerjarName=None, mcVersion=None):
|
def papermc_downloader(paperBuild='latest', installedServerjarName=None, mcVersion=None):
|
||||||
if checkConfig().localPluginFolder == False:
|
configValues = configurationValues()
|
||||||
|
if configValues.localPluginFolder == False:
|
||||||
downloadPath = createTempPluginFolder()
|
downloadPath = createTempPluginFolder()
|
||||||
else:
|
else:
|
||||||
downloadPath = checkConfig().pathToPluginFolder
|
downloadPath = configValues.pathToPluginFolder
|
||||||
helpPath = Path('/plugins')
|
helpPath = Path('/plugins')
|
||||||
helpPathstr = str(helpPath)
|
helpPathstr = str(helpPath)
|
||||||
downloadPath = Path(str(downloadPath).replace(helpPathstr, ''))
|
downloadPath = Path(str(downloadPath).replace(helpPathstr, ''))
|
||||||
@ -149,22 +152,22 @@ def papermc_downloader(paperBuild='latest', installedServerjarName=None, mcVersi
|
|||||||
|
|
||||||
downloadPackagePath = Path(f"{downloadPath}/{downloadFileName}")
|
downloadPackagePath = Path(f"{downloadPath}/{downloadFileName}")
|
||||||
|
|
||||||
if checkConfig().localPluginFolder == False:
|
if configValues.localPluginFolder == False:
|
||||||
downloadPath = createTempPluginFolder()
|
downloadPath = createTempPluginFolder()
|
||||||
|
|
||||||
url = f"https://papermc.io/api/v2/projects/paper/versions/{mcVersion}/builds/{paperBuild}/downloads/{downloadFileName}"
|
url = f"https://papermc.io/api/v2/projects/paper/versions/{mcVersion}/builds/{paperBuild}/downloads/{downloadFileName}"
|
||||||
remotefile = urllib.request.urlopen(url)
|
remotefile = urllib.request.urlopen(url)
|
||||||
filesize = remotefile.info()['Content-Length']
|
filesize = remotefile.info()['Content-Length']
|
||||||
print(f"Starting Paper-{paperBuild} download for {mcVersion}...")
|
print(f"Getting Paper {paperBuild} for {mcVersion}")
|
||||||
urllib.request.urlretrieve(url, downloadPackagePath)
|
console = Console()
|
||||||
|
with console.status("Downloading...", spinner='line', spinner_style='bright_magenta') as status:
|
||||||
|
urllib.request.urlretrieve(url, downloadPackagePath)
|
||||||
filesizeData = calculateFileSizeMb(filesize)
|
filesizeData = calculateFileSizeMb(filesize)
|
||||||
|
print("Downloaded " + (str(filesizeData)).rjust(9) + f" MB here {downloadPackagePath}")
|
||||||
print(f"Downloadsize: {filesizeData} MB")
|
if not configValues.localPluginFolder:
|
||||||
print(f"File downloaded here: {downloadPackagePath}")
|
|
||||||
if not checkConfig().localPluginFolder:
|
|
||||||
sftpSession = createSFTPConnection()
|
sftpSession = createSFTPConnection()
|
||||||
sftp_upload_server_jar(sftpSession, downloadPackagePath)
|
sftp_upload_server_jar(sftpSession, downloadPackagePath)
|
||||||
deleteTempPluginFolder(downloadPath)
|
deleteTempPluginFolder(downloadPath)
|
||||||
|
|
||||||
print(oColors.brightGreen + "Downloaded successfully " + oColors.standardWhite + f"Paper-{paperBuild}" + \
|
print(oColors.brightGreen + "Downloaded successfully " + oColors.standardWhite + f"Paper {paperBuild}" + \
|
||||||
oColors.brightGreen + " for " + oColors.standardWhite + f"{mcVersion}" + oColors.standardWhite)
|
oColors.brightGreen + " for " + oColors.standardWhite + f"{mcVersion}" + oColors.standardWhite)
|
||||||
|
@ -6,7 +6,7 @@ import requests
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from handlers.handle_config import checkConfig
|
from handlers.handle_config import configurationValues
|
||||||
from handlers.handle_sftp import createSFTPConnection
|
from handlers.handle_sftp import createSFTPConnection
|
||||||
|
|
||||||
|
|
||||||
@ -95,11 +95,12 @@ def getCommandHelp(optionalParams):
|
|||||||
|
|
||||||
|
|
||||||
def check_local_plugin_folder():
|
def check_local_plugin_folder():
|
||||||
if checkConfig().localPluginFolder:
|
configValues = configurationValues()
|
||||||
if checkConfig().seperateDownloadPath:
|
if configValues.localPluginFolder:
|
||||||
pluginFolderPath = checkConfig().pathToSeperateDownloadPath
|
if configValues.seperateDownloadPath:
|
||||||
|
pluginFolderPath = configValues.pathToSeperateDownloadPath
|
||||||
else:
|
else:
|
||||||
pluginFolderPath = checkConfig().pathToPluginFolder
|
pluginFolderPath = configValues.pathToPluginFolder
|
||||||
|
|
||||||
if not os.path.isdir(pluginFolderPath):
|
if not os.path.isdir(pluginFolderPath):
|
||||||
print(oColors.brightRed + "Plugin folder coulnd*t be found. Creating one..." + oColors.standardWhite)
|
print(oColors.brightRed + "Plugin folder coulnd*t be found. Creating one..." + oColors.standardWhite)
|
||||||
@ -129,9 +130,10 @@ def apiTest():
|
|||||||
|
|
||||||
|
|
||||||
def check_requirements():
|
def check_requirements():
|
||||||
|
configValues = configurationValues()
|
||||||
apiTest()
|
apiTest()
|
||||||
check_local_plugin_folder()
|
check_local_plugin_folder()
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
createSFTPConnection()
|
createSFTPConnection()
|
||||||
|
|
||||||
|
|
||||||
@ -160,3 +162,9 @@ def calculateFileSizeMb(downloadFileSize):
|
|||||||
fileSizeMb = fileSizeDownload / 1024 / 1024
|
fileSizeMb = fileSizeDownload / 1024 / 1024
|
||||||
roundedFileSize = round(fileSizeMb, 2)
|
roundedFileSize = round(fileSizeMb, 2)
|
||||||
return roundedFileSize
|
return roundedFileSize
|
||||||
|
|
||||||
|
def calculateFileSizeKb(downloadFileSize):
|
||||||
|
fileSizeDownload = int(downloadFileSize)
|
||||||
|
fileSizeKb = fileSizeDownload / 1024
|
||||||
|
roundedFileSize = round(fileSizeKb, 2)
|
||||||
|
return roundedFileSize
|
Loading…
Reference in New Issue
Block a user