mirror of
https://github.com/Neocky/pluGET.git
synced 2024-04-29 16:12:30 +00:00
commit
8344ed0afc
@ -101,8 +101,7 @@ def ftp_validateFileAttributes(ftp, pluginPath):
|
|||||||
pluginFTPAttribute = ftp.lstat(pluginPath)
|
pluginFTPAttribute = ftp.lstat(pluginPath)
|
||||||
if stat.S_ISDIR(pluginFTPAttribute.st_mode):
|
if stat.S_ISDIR(pluginFTPAttribute.st_mode):
|
||||||
return False
|
return False
|
||||||
if stat.S_ISDIR(pluginFTPAttribute.st_mode):
|
elif re.search(r'.jar$', pluginPath):
|
||||||
if re.search(r'.jar$', pluginFTPAttribute.filename):
|
return True
|
||||||
return True
|
else:
|
||||||
else:
|
return False
|
||||||
return False
|
|
||||||
|
@ -61,7 +61,7 @@ def handleInput(inputCommand, inputSelectedObject, inputParams):
|
|||||||
if inputSelectedObject == 'serverjar':
|
if inputSelectedObject == 'serverjar':
|
||||||
checkInstalledServerjar()
|
checkInstalledServerjar()
|
||||||
else:
|
else:
|
||||||
checkInstalledPackage(inputSelectedObject)
|
checkInstalledPackage(inputSelectedObject, inputParams)
|
||||||
break
|
break
|
||||||
if inputCommand == 'search':
|
if inputCommand == 'search':
|
||||||
searchPackage(inputSelectedObject)
|
searchPackage(inputSelectedObject)
|
||||||
|
@ -97,8 +97,7 @@ def sftp_validateFileAttributes(sftp, pluginPath):
|
|||||||
pluginSFTPAttribute = sftp.lstat(pluginPath)
|
pluginSFTPAttribute = sftp.lstat(pluginPath)
|
||||||
if stat.S_ISDIR(pluginSFTPAttribute.st_mode):
|
if stat.S_ISDIR(pluginSFTPAttribute.st_mode):
|
||||||
return False
|
return False
|
||||||
if stat.S_ISDIR(pluginSFTPAttribute.st_mode):
|
elif re.search(r'.jar$', pluginPath):
|
||||||
if re.search(r'.jar$', pluginSFTPAttribute.filename):
|
return True
|
||||||
return True
|
else:
|
||||||
else:
|
return False
|
||||||
return False
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import io
|
import io
|
||||||
import stat
|
import base64
|
||||||
import pysftp
|
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
from urllib.error import HTTPError
|
from urllib.error import HTTPError
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -23,8 +22,8 @@ def createPluginList():
|
|||||||
return INSTALLEDPLUGINLIST
|
return INSTALLEDPLUGINLIST
|
||||||
|
|
||||||
|
|
||||||
def addToPluginList(pluginId, versionId, plugin_latest_version, plugin_is_outdated):
|
def addToPluginList(localFileName, pluginId, versionId, plugin_latest_version, plugin_is_outdated):
|
||||||
INSTALLEDPLUGINLIST.append([pluginId, versionId, plugin_latest_version, plugin_is_outdated])
|
INSTALLEDPLUGINLIST.append([localFileName, pluginId, versionId, plugin_latest_version, plugin_is_outdated])
|
||||||
|
|
||||||
|
|
||||||
def getFileName(pluginName):
|
def getFileName(pluginName):
|
||||||
@ -59,6 +58,23 @@ def getLatestPluginVersion(pluginId):
|
|||||||
return versionLatestUpdate
|
return versionLatestUpdate
|
||||||
|
|
||||||
|
|
||||||
|
def getUpdateDescription(pluginId):
|
||||||
|
url = f"https://api.spiget.org/v2/resources/{pluginId}/updates?size=1&sort=-date"
|
||||||
|
latestDescriptionSearch = doAPIRequest(url)
|
||||||
|
versionLatestDescription = latestDescriptionSearch[0]["description"]
|
||||||
|
versionLatestDescription = base64.b64decode(versionLatestDescription)
|
||||||
|
versionLatestDescriptionText =versionLatestDescription.decode('utf-8')
|
||||||
|
htmlRegex = re.compile('<.*?>')
|
||||||
|
versionLatestDescriptionText = re.sub(htmlRegex, '', versionLatestDescriptionText)
|
||||||
|
linesChangelogDescription = versionLatestDescriptionText.split("\n")
|
||||||
|
nonEmptyLines = [line for line in linesChangelogDescription if line.strip() != ""]
|
||||||
|
stringnonEmptyLines = ""
|
||||||
|
for line in nonEmptyLines:
|
||||||
|
stringnonEmptyLines += line + "\n"
|
||||||
|
stringnonEmptyLines = stringnonEmptyLines[:-1]
|
||||||
|
return stringnonEmptyLines
|
||||||
|
|
||||||
|
|
||||||
def compareVersions(plugin_latest_version, pluginVersion):
|
def compareVersions(plugin_latest_version, pluginVersion):
|
||||||
if pluginVersion < plugin_latest_version:
|
if pluginVersion < plugin_latest_version:
|
||||||
plugin_is_outdated = True
|
plugin_is_outdated = True
|
||||||
@ -114,7 +130,7 @@ def eggCrackingJar(localJarFileName, searchMode):
|
|||||||
return pluginName
|
return pluginName
|
||||||
|
|
||||||
|
|
||||||
def checkInstalledPackage(inputSelectedObject="all"):
|
def checkInstalledPackage(inputSelectedObject="all", inputOptionalParam=None):
|
||||||
configValues = configurationValues()
|
configValues = configurationValues()
|
||||||
createPluginList()
|
createPluginList()
|
||||||
pluginFolderPath = configValues.pathToPluginFolder
|
pluginFolderPath = configValues.pathToPluginFolder
|
||||||
@ -127,9 +143,12 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
|||||||
pluginList = ftp_listAll(connection)
|
pluginList = ftp_listAll(connection)
|
||||||
else:
|
else:
|
||||||
pluginList = os.listdir(pluginFolderPath)
|
pluginList = os.listdir(pluginFolderPath)
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
oldPlugins = 0
|
oldPlugins = 0
|
||||||
print(oColors.brightBlack + f"Checking: {inputSelectedObject}" + oColors.standardWhite)
|
print(oColors.brightBlack + f"Checking: {inputSelectedObject}" + oColors.standardWhite)
|
||||||
|
if inputOptionalParam != "changelog":
|
||||||
|
print(oColors.brightBlack + f"Use 'check {inputSelectedObject} changelog' to get the latest changelog from plugins" + oColors.standardWhite)
|
||||||
print("┌─────┬────────────────────────────────┬──────────────┬──────────────┬───────────────────┐")
|
print("┌─────┬────────────────────────────────┬──────────────┬──────────────┬───────────────────┐")
|
||||||
print("│ No. │ Name │ Installed V. │ Latest V. │ Update available │")
|
print("│ No. │ Name │ Installed V. │ Latest V. │ Update available │")
|
||||||
print("└─────┴────────────────────────────────┴──────────────┴──────────────┴───────────────────┘")
|
print("└─────┴────────────────────────────────┴──────────────┴──────────────┴───────────────────┘")
|
||||||
@ -154,7 +173,6 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
|||||||
continue
|
continue
|
||||||
if not re.search(r'.jar$', plugin):
|
if not re.search(r'.jar$', plugin):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fileName = getFileName(plugin)
|
fileName = getFileName(plugin)
|
||||||
fileVersion = getFileVersion(plugin)
|
fileVersion = getFileVersion(plugin)
|
||||||
@ -166,7 +184,7 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
|||||||
if fileVersion == '':
|
if fileVersion == '':
|
||||||
fileVersion = 'N/A'
|
fileVersion = 'N/A'
|
||||||
try:
|
try:
|
||||||
pluginLatestVersion = INSTALLEDPLUGINLIST[i][2]
|
pluginLatestVersion = INSTALLEDPLUGINLIST[i][3]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pluginLatestVersion = 'N/A'
|
pluginLatestVersion = 'N/A'
|
||||||
|
|
||||||
@ -174,7 +192,7 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
|||||||
pluginLatestVersion = 'N/A'
|
pluginLatestVersion = 'N/A'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pluginIsOutdated = INSTALLEDPLUGINLIST[i][3]
|
pluginIsOutdated = INSTALLEDPLUGINLIST[i][4]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pluginIsOutdated = 'N/A'
|
pluginIsOutdated = 'N/A'
|
||||||
|
|
||||||
@ -187,28 +205,37 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
|||||||
if re.search(r'.jar$', fileName):
|
if re.search(r'.jar$', fileName):
|
||||||
fileName = eggCrackingJar(plugin, "name")
|
fileName = eggCrackingJar(plugin, "name")
|
||||||
|
|
||||||
if inputSelectedObject != "*" and inputSelectedObject != "all":
|
if inputSelectedObject != "all" and inputSelectedObject != "*":
|
||||||
|
if inputSelectedObject != pluginIdStr or not re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
if inputSelectedObject == "all" or inputSelectedObject != "*" or 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}]".rjust(6), end='')
|
print(oColors.brightBlack + f" [{1}]".rjust(6), end='')
|
||||||
else:
|
else:
|
||||||
print(f" [{1}]".rjust(6), end='')
|
print(f" [{1}]".rjust(6), end='')
|
||||||
print(" ", end='')
|
|
||||||
print(f"{fileName}".ljust(33), end='')
|
|
||||||
print(f"{fileVersion}".ljust(15), end='')
|
|
||||||
print(f"{pluginLatestVersion}".ljust(15), end='')
|
|
||||||
print(f"{pluginIsOutdated}".ljust(5) + oColors.standardWhite)
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
if pluginLatestVersion == 'N/A':
|
|
||||||
print(oColors.brightBlack + f" [{i+1}]".rjust(6), end='')
|
|
||||||
else:
|
else:
|
||||||
print(f" [{i+1}]".rjust(6), end='')
|
if pluginLatestVersion == 'N/A':
|
||||||
|
print(oColors.brightBlack + f" [{i+1}]".rjust(6), end='')
|
||||||
|
else:
|
||||||
|
print(f" [{i+1}]".rjust(6), end='')
|
||||||
print(" ", 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(15), end='')
|
print(f"{pluginLatestVersion}".ljust(15), end='')
|
||||||
print(f"{pluginIsOutdated}".ljust(5) + oColors.standardWhite)
|
print(f"{pluginIsOutdated}".ljust(5) + oColors.standardWhite)
|
||||||
|
if (inputOptionalParam == "changelog" and pluginLatestVersion != 'N/A'):
|
||||||
|
print(oColors.brightYellow + f"CHANGELOG {fileName}:" + oColors.standardWhite)
|
||||||
|
description = getUpdateDescription(pluginId)
|
||||||
|
print(description)
|
||||||
|
print()
|
||||||
|
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print(oColors.brightRed + "Wrong input! Use 'check all' to check every plugin for updates!" + oColors.standardWhite)
|
||||||
|
break
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
except TypeError:
|
except TypeError:
|
||||||
@ -218,17 +245,33 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
|||||||
|
|
||||||
def updateInstalledPackage(inputSelectedObject='all'):
|
def updateInstalledPackage(inputSelectedObject='all'):
|
||||||
configValues = configurationValues()
|
configValues = configurationValues()
|
||||||
createPluginList()
|
|
||||||
pluginFolderPath = configValues.pathToPluginFolder
|
|
||||||
if not configValues.localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
if configValues.sftp_useSftp:
|
if configValues.sftp_useSftp:
|
||||||
connection = createSFTPConnection()
|
connection = createSFTPConnection()
|
||||||
pluginList = sftp_listAll(connection)
|
|
||||||
else:
|
else:
|
||||||
connection = createFTPConnection()
|
connection = createFTPConnection()
|
||||||
pluginList = ftp_listAll(connection)
|
|
||||||
else:
|
try:
|
||||||
pluginList = os.listdir(pluginFolderPath)
|
print(oColors.brightBlack + "Selected plugins:" + oColors.standardWhite)
|
||||||
|
if inputSelectedObject == "all" or inputSelectedObject == "*":
|
||||||
|
for pluginIndex in range(len(INSTALLEDPLUGINLIST)):
|
||||||
|
fileName = getFileName(INSTALLEDPLUGINLIST[pluginIndex][0])
|
||||||
|
print(fileName, end=' ')
|
||||||
|
else:
|
||||||
|
print(inputSelectedObject, end=' ')
|
||||||
|
|
||||||
|
print()
|
||||||
|
updateConfirmation = input("Update these plugins [y/n] ? ")
|
||||||
|
if updateConfirmation != "y":
|
||||||
|
print(oColors.brightRed + "Aborting the update process."+ oColors.standardWhite)
|
||||||
|
return False
|
||||||
|
|
||||||
|
except NameError:
|
||||||
|
print(oColors.brightRed + "Check for updates before updating plugins with: 'check all'" + oColors.standardWhite)
|
||||||
|
print(oColors.brightRed + "Started checking for updates..." + oColors.standardWhite)
|
||||||
|
checkInstalledPackage()
|
||||||
|
print(oColors.brightRed + f"Please input 'update {inputSelectedObject}' again!" + oColors.standardWhite)
|
||||||
|
return False
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
pluginsUpdated = 0
|
pluginsUpdated = 0
|
||||||
@ -238,7 +281,8 @@ 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="bright_magenta"):
|
for pluginArray in track(INSTALLEDPLUGINLIST, description="Updating" ,transient=True, complete_style="bright_magenta", ):
|
||||||
|
plugin = INSTALLEDPLUGINLIST[i][0]
|
||||||
if not configValues.localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
if configValues.sftp_seperateDownloadPath is True:
|
if configValues.sftp_seperateDownloadPath is True:
|
||||||
pluginFile = f"{configValues.sftp_pathToSeperateDownloadPath}/{plugin}"
|
pluginFile = f"{configValues.sftp_pathToSeperateDownloadPath}/{plugin}"
|
||||||
@ -248,25 +292,29 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
if configValues.sftp_useSftp:
|
if configValues.sftp_useSftp:
|
||||||
pluginAttributes = sftp_validateFileAttributes(connection, pluginFile)
|
pluginAttributes = sftp_validateFileAttributes(connection, pluginFile)
|
||||||
if pluginAttributes == False:
|
if pluginAttributes == False:
|
||||||
|
i += 1
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
pluginAttributes = ftp_validateFileAttributes(connection, pluginFile)
|
pluginAttributes = ftp_validateFileAttributes(connection, pluginFile)
|
||||||
if pluginAttributes == False:
|
if pluginAttributes == False:
|
||||||
|
i += 1
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
pluginFolderPath = configValues.pathToPluginFolder
|
||||||
if not os.path.isfile(Path(f"{pluginFolderPath}/{plugin}")):
|
if not os.path.isfile(Path(f"{pluginFolderPath}/{plugin}")):
|
||||||
|
i += 1
|
||||||
continue
|
continue
|
||||||
if not re.search(r'.jar$', plugin):
|
if not re.search(r'.jar$', plugin):
|
||||||
|
i += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fileName = getFileName(plugin)
|
fileName = getFileName(plugin)
|
||||||
fileVersion = getFileVersion(plugin)
|
fileVersion = getFileVersion(plugin)
|
||||||
pluginId = getInstalledPlugin(fileName, fileVersion, plugin)
|
pluginId = INSTALLEDPLUGINLIST[i][1]
|
||||||
latestVersion = getLatestPluginVersion(pluginId)
|
latestVersion = INSTALLEDPLUGINLIST[i][3]
|
||||||
except TypeError:
|
except (TypeError, ValueError):
|
||||||
continue
|
i += 1
|
||||||
except ValueError:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if re.search(r'.jar$', fileName):
|
if re.search(r'.jar$', fileName):
|
||||||
@ -274,66 +322,16 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
|
|
||||||
pluginIdStr = str(pluginId)
|
pluginIdStr = str(pluginId)
|
||||||
if pluginId == None or pluginId == '':
|
if pluginId == None or pluginId == '':
|
||||||
print(oColors.brightRed + "Couldn't find plugin id. Sorry :(" + oColors.standardWhite)
|
i += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
if inputSelectedObject == 'all' or inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
||||||
if INSTALLEDPLUGINLIST[i][3] == True:
|
if INSTALLEDPLUGINLIST[i][4] == True:
|
||||||
print(f" [{indexNumberUpdated+1}]".rjust(6), end='')
|
print(f" [{indexNumberUpdated+1}]".rjust(6), end='')
|
||||||
print(" ", end='')
|
print(" ", end='')
|
||||||
print(f"{fileName}".ljust(33), end='')
|
print(f"{fileName}".ljust(33), end='')
|
||||||
print(f"{fileVersion}".ljust(13), end='')
|
print(f"{fileVersion}".ljust(13), end='')
|
||||||
print(f"{latestVersion}".ljust(13))
|
print(f"{latestVersion}".ljust(13))
|
||||||
|
|
||||||
if not configValues.localPluginFolder:
|
|
||||||
if configValues.sftp_seperateDownloadPath is True:
|
|
||||||
pluginPath = configValues.sftp_pathToSeperateDownloadPath
|
|
||||||
else:
|
|
||||||
pluginPath = configValues.sftp_folderPath
|
|
||||||
pluginPath = Path(f"{pluginPath}/{plugin}")
|
|
||||||
sftp = createSFTPConnection()
|
|
||||||
indexNumberUpdated += 1
|
|
||||||
pluginsUpdated += 1
|
|
||||||
try:
|
|
||||||
getSpecificPackage(pluginId, configValues.sftp_folderPath)
|
|
||||||
if configValues.sftp_seperateDownloadPath is False:
|
|
||||||
sftp.remove(pluginPath)
|
|
||||||
except HTTPError as err:
|
|
||||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
|
||||||
pluginsUpdated -= 1
|
|
||||||
except FileNotFoundError:
|
|
||||||
print(oColors.brightRed + "Error: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
|
||||||
else:
|
|
||||||
if configValues.seperateDownloadPath is True:
|
|
||||||
pluginPath = configValues.pathToSeperateDownloadPath
|
|
||||||
else:
|
|
||||||
pluginPath = pluginFolderPath
|
|
||||||
pluginPath = Path(f"{pluginPath}/{plugin}")
|
|
||||||
indexNumberUpdated += 1
|
|
||||||
pluginsUpdated += 1
|
|
||||||
try:
|
|
||||||
getSpecificPackage(pluginId, pluginFolderPath)
|
|
||||||
if configValues.seperateDownloadPath is False:
|
|
||||||
os.remove(pluginPath)
|
|
||||||
except HTTPError as err:
|
|
||||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
|
||||||
pluginsUpdated -= 1
|
|
||||||
except FileNotFoundError:
|
|
||||||
print(oColors.brightRed + f"Error: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
print(f"{fileName} is already on {latestVersion}")
|
|
||||||
print(oColors.brightRed + "Aborting the update process."+ oColors.standardWhite)
|
|
||||||
break
|
|
||||||
|
|
||||||
if inputSelectedObject == 'all':
|
|
||||||
if INSTALLEDPLUGINLIST[i][3] == True:
|
|
||||||
print(f" [{indexNumberUpdated+1}]".rjust(6), end='')
|
|
||||||
print(" ", end='')
|
|
||||||
print(f"{fileName}".ljust(33), end='')
|
|
||||||
print(f"{fileVersion}".ljust(13), end='')
|
|
||||||
print(f"{latestVersion}".ljust(13))
|
|
||||||
|
|
||||||
if not configValues.localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
if configValues.sftp_useSftp:
|
if configValues.sftp_useSftp:
|
||||||
if configValues.sftp_seperateDownloadPath is True:
|
if configValues.sftp_seperateDownloadPath is True:
|
||||||
@ -389,12 +387,27 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
pluginsUpdated -= 1
|
pluginsUpdated -= 1
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(oColors.brightRed + f"FileNotFoundError: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
print(oColors.brightRed + f"FileNotFoundError: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
||||||
|
if inputSelectedObject != 'all':
|
||||||
|
break
|
||||||
|
elif inputSelectedObject != 'all':
|
||||||
|
print(oColors.brightGreen + f"{fileName} is already on {latestVersion}" + oColors.standardWhite)
|
||||||
|
print(oColors.brightRed + "Aborting the update process."+ oColors.standardWhite)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print(oColors.brightRed + "Error occured: Aborted updating for plugins." + oColors.standardWhite)
|
print(oColors.brightRed + "Error occured: Aborted updating plugins." + oColors.standardWhite)
|
||||||
print(oColors.brightYellow + f"Plugins updated: [{pluginsUpdated}/{i}]" + oColors.standardWhite)
|
except NameError:
|
||||||
if inputSelectedObject =='all' and pluginsUpdated == 0:
|
print(oColors.brightRed + "Check for updates before updating plugins with: 'check all'" + oColors.standardWhite)
|
||||||
|
print(oColors.brightRed + "Started checking for updates..." + oColors.standardWhite)
|
||||||
|
checkInstalledPackage()
|
||||||
|
print(oColors.brightRed + f"Please input 'update {inputSelectedObject}' again!" + oColors.standardWhite)
|
||||||
|
if i != 0:
|
||||||
|
print(oColors.brightYellow + f"Plugins updated: [{pluginsUpdated}/{i}]" + oColors.standardWhite)
|
||||||
|
if inputSelectedObject =='all' and pluginsUpdated == 0 and i != 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)
|
||||||
|
|
||||||
|
|
||||||
@ -425,7 +438,6 @@ def getInstalledPlugin(localFileName, localFileVersion, localPluginFullName):
|
|||||||
continue
|
continue
|
||||||
pID = ressource["id"]
|
pID = ressource["id"]
|
||||||
url2 = f"https://api.spiget.org/v2/resources/{pID}/versions?size=100&sort=-name"
|
url2 = f"https://api.spiget.org/v2/resources/{pID}/versions?size=100&sort=-name"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
packageVersions = doAPIRequest(url2)
|
packageVersions = doAPIRequest(url2)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@ -438,7 +450,7 @@ def getInstalledPlugin(localFileName, localFileVersion, localPluginFullName):
|
|||||||
updateId = updates["id"]
|
updateId = updates["id"]
|
||||||
plugin_latest_version = getLatestPluginVersion(pID)
|
plugin_latest_version = getLatestPluginVersion(pID)
|
||||||
plugin_is_outdated = compareVersions(plugin_latest_version, updateVersion)
|
plugin_is_outdated = compareVersions(plugin_latest_version, updateVersion)
|
||||||
addToPluginList(pID, updateId, plugin_latest_version , plugin_is_outdated)
|
addToPluginList(localPluginFullName, pID, updateId, plugin_latest_version , plugin_is_outdated)
|
||||||
return pluginID
|
return pluginID
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -447,6 +459,6 @@ def getInstalledPlugin(localFileName, localFileVersion, localPluginFullName):
|
|||||||
updateId = None
|
updateId = None
|
||||||
plugin_latest_version = None
|
plugin_latest_version = None
|
||||||
plugin_is_outdated = None
|
plugin_is_outdated = None
|
||||||
addToPluginList(pID, updateId, plugin_latest_version , plugin_is_outdated)
|
addToPluginList(localPluginFullName, pID, updateId, plugin_latest_version , plugin_is_outdated)
|
||||||
|
|
||||||
return pluginID
|
return pluginID
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import os
|
|
||||||
import sys
|
|
||||||
import re
|
import re
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -13,7 +11,6 @@ from handlers.handle_config import configurationValues
|
|||||||
from utils.utilities import createTempPluginFolder, deleteTempPluginFolder, calculateFileSizeMb
|
from utils.utilities import createTempPluginFolder, deleteTempPluginFolder, calculateFileSizeMb
|
||||||
|
|
||||||
|
|
||||||
# = 1.16.5
|
|
||||||
def getInstalledPaperMinecraftVersion(localPaperName):
|
def getInstalledPaperMinecraftVersion(localPaperName):
|
||||||
if localPaperName is None:
|
if localPaperName is None:
|
||||||
return False
|
return False
|
||||||
@ -25,7 +22,6 @@ def getInstalledPaperMinecraftVersion(localPaperName):
|
|||||||
return mcVersion
|
return mcVersion
|
||||||
|
|
||||||
|
|
||||||
# = 550
|
|
||||||
def getInstalledPaperVersion(localPaperName):
|
def getInstalledPaperVersion(localPaperName):
|
||||||
if localPaperName is None:
|
if localPaperName is None:
|
||||||
return False
|
return False
|
||||||
@ -39,7 +35,7 @@ def getInstalledPaperVersion(localPaperName):
|
|||||||
|
|
||||||
|
|
||||||
def findVersionGroup(mcVersion):
|
def findVersionGroup(mcVersion):
|
||||||
versionGroups = ['1.16', '1.15']
|
versionGroups = ['1.17', '1.16', '1.15']
|
||||||
if mcVersion is None:
|
if mcVersion is None:
|
||||||
return False
|
return False
|
||||||
for versionGroup in versionGroups:
|
for versionGroup in versionGroups:
|
||||||
@ -57,7 +53,7 @@ def findVersionGroup(mcVersion):
|
|||||||
|
|
||||||
|
|
||||||
def findBuildVersion(wantedPaperBuild):
|
def findBuildVersion(wantedPaperBuild):
|
||||||
versionGroups = ['1.16', '1.15']
|
versionGroups = ['1.17', '1.16', '1.15']
|
||||||
if wantedPaperBuild is None:
|
if wantedPaperBuild is None:
|
||||||
return False
|
return False
|
||||||
for versionGroup in versionGroups:
|
for versionGroup in versionGroups:
|
||||||
@ -93,7 +89,7 @@ def findLatestBuildForVersion(mcVersion):
|
|||||||
|
|
||||||
|
|
||||||
def versionBehind(installedPaperBuild, latestPaperBuild):
|
def versionBehind(installedPaperBuild, latestPaperBuild):
|
||||||
if installedPaperBuild or latestPaperBuild is None:
|
if installedPaperBuild is None or latestPaperBuild is None:
|
||||||
return False
|
return False
|
||||||
installedPaperBuildint = int(installedPaperBuild)
|
installedPaperBuildint = int(installedPaperBuild)
|
||||||
latestPaperBuildint = int(latestPaperBuild)
|
latestPaperBuildint = int(latestPaperBuild)
|
||||||
@ -102,7 +98,7 @@ def versionBehind(installedPaperBuild, latestPaperBuild):
|
|||||||
|
|
||||||
|
|
||||||
def getDownloadFileName(paperMcVersion, paperBuild):
|
def getDownloadFileName(paperMcVersion, paperBuild):
|
||||||
if paperMcVersion or paperBuild is None:
|
if paperMcVersion is None or paperBuild is None:
|
||||||
return False
|
return False
|
||||||
url = f"https://papermc.io/api/v2/projects/paper/versions/{paperMcVersion}/builds/{paperBuild}"
|
url = f"https://papermc.io/api/v2/projects/paper/versions/{paperMcVersion}/builds/{paperBuild}"
|
||||||
buildDetails = doAPIRequest(url)
|
buildDetails = doAPIRequest(url)
|
||||||
@ -120,7 +116,6 @@ def paperCheckForUpdate(installedServerjarFullName):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
paperInstalledBuild = getInstalledPaperVersion(installedServerjarFullName)
|
paperInstalledBuild = getInstalledPaperVersion(installedServerjarFullName)
|
||||||
|
|
||||||
# Report an error if getInstalledPaperVersion encountered an issue.
|
# Report an error if getInstalledPaperVersion encountered an issue.
|
||||||
if not paperInstalledBuild:
|
if not paperInstalledBuild:
|
||||||
print(oColors.brightRed + f"ERR: An error was encountered while detecting the server's Paper version." +
|
print(oColors.brightRed + f"ERR: An error was encountered while detecting the server's Paper version." +
|
||||||
@ -128,7 +123,6 @@ def paperCheckForUpdate(installedServerjarFullName):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
versionGroup = findVersionGroup(mcVersion)
|
versionGroup = findVersionGroup(mcVersion)
|
||||||
|
|
||||||
# Report an error if findVersionGroup encountered an issue.
|
# Report an error if findVersionGroup encountered an issue.
|
||||||
if not versionGroup:
|
if not versionGroup:
|
||||||
print(oColors.brightRed + f"ERR: An error was encountered while fetching the server's version group." +
|
print(oColors.brightRed + f"ERR: An error was encountered while fetching the server's version group." +
|
||||||
@ -136,7 +130,6 @@ def paperCheckForUpdate(installedServerjarFullName):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
paperLatestBuild = findLatestBuild(versionGroup)
|
paperLatestBuild = findLatestBuild(versionGroup)
|
||||||
|
|
||||||
# Report an error if findLatestBuild encountered an issue.
|
# Report an error if findLatestBuild encountered an issue.
|
||||||
if not paperLatestBuild:
|
if not paperLatestBuild:
|
||||||
print(oColors.brightRed + f"ERR: An error was encountered while fetching the latest version of PaperMC." +
|
print(oColors.brightRed + f"ERR: An error was encountered while fetching the latest version of PaperMC." +
|
||||||
@ -145,17 +138,16 @@ def paperCheckForUpdate(installedServerjarFullName):
|
|||||||
# being printed.
|
# being printed.
|
||||||
|
|
||||||
paperVersionBehind = versionBehind(paperInstalledBuild, paperLatestBuild)
|
paperVersionBehind = versionBehind(paperInstalledBuild, paperLatestBuild)
|
||||||
|
|
||||||
# Report an error if getInstalledPaperVersion encountered an issue.
|
# Report an error if getInstalledPaperVersion encountered an issue.
|
||||||
if not paperVersionBehind:
|
if not paperVersionBehind:
|
||||||
print(oColors.brightRed + f"ERR: An error was encountered while detecting how many versions behind you are. "
|
print(oColors.brightRed + f"ERR: An error was encountered while detecting how many versions behind you are. "
|
||||||
f"Will display as 'N/A'." + oColors.standardWhite)
|
f"Will display as 'N/A'." + oColors.standardWhite)
|
||||||
|
print(paperVersionBehind)
|
||||||
paperVersionBehind = "N/A" # Sets paperVersionBehind to N/A while still letting the versionBehind check return
|
paperVersionBehind = "N/A" # Sets paperVersionBehind to N/A while still letting the versionBehind check return
|
||||||
# # False for error-handing reasons.
|
# False for error-handing reasons.
|
||||||
|
|
||||||
# Does not return false as versions behind doesn't break things. It is just helpful information.
|
# Does not return false as versions behind doesn't break things. It is just helpful information.
|
||||||
# paperVersionBehind will just display as "N/A"
|
# paperVersionBehind will just display as "N/A"
|
||||||
|
|
||||||
print("┌─────┬────────────────────────────────┬──────────────┬──────────────┬───────────────────┐")
|
print("┌─────┬────────────────────────────────┬──────────────┬──────────────┬───────────────────┐")
|
||||||
print("│ No. │ Name │ Installed V. │ Latest V. │ Versions behind │")
|
print("│ No. │ Name │ Installed V. │ Latest V. │ Versions behind │")
|
||||||
print("└─────┴────────────────────────────────┴──────────────┴──────────────┴───────────────────┘")
|
print("└─────┴────────────────────────────────┴──────────────┴──────────────┴───────────────────┘")
|
||||||
@ -181,7 +173,7 @@ def papermc_downloader(paperBuild='latest', installedServerjarName=None, mcVersi
|
|||||||
|
|
||||||
if mcVersion == None:
|
if mcVersion == None:
|
||||||
if paperBuild == 'latest':
|
if paperBuild == 'latest':
|
||||||
mcVersion = '1.16.5'
|
mcVersion = '1.17'
|
||||||
else:
|
else:
|
||||||
mcVersion = findBuildVersion(paperBuild)
|
mcVersion = findBuildVersion(paperBuild)
|
||||||
|
|
||||||
@ -199,11 +191,11 @@ def papermc_downloader(paperBuild='latest', installedServerjarName=None, mcVersi
|
|||||||
downloadFileName = getDownloadFileName(mcVersion, paperBuild)
|
downloadFileName = getDownloadFileName(mcVersion, paperBuild)
|
||||||
|
|
||||||
downloadPackagePath = Path(f"{downloadPath}/{downloadFileName}")
|
downloadPackagePath = Path(f"{downloadPath}/{downloadFileName}")
|
||||||
|
|
||||||
if configValues.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}"
|
||||||
|
print(url)
|
||||||
remotefile = urllib.request.urlopen(url)
|
remotefile = urllib.request.urlopen(url)
|
||||||
filesize = remotefile.info()['Content-Length']
|
filesize = remotefile.info()['Content-Length']
|
||||||
print(f"Getting Paper {paperBuild} for {mcVersion}")
|
print(f"Getting Paper {paperBuild} for {mcVersion}")
|
||||||
|
@ -35,7 +35,7 @@ def getCommandHelp(optionalParams):
|
|||||||
print(" help command all/command Get specific help to the commands of pluGET")
|
print(" help command all/command Get specific help to the commands of pluGET")
|
||||||
print(oColors.brightBlack + " PLUGIN MANAGEMENT:" + oColors.standardWhite)
|
print(oColors.brightBlack + " PLUGIN MANAGEMENT:" + oColors.standardWhite)
|
||||||
print(" get Name/ID Version Downloads the latest version of a plugin")
|
print(" get Name/ID Version Downloads the latest version of a plugin")
|
||||||
print(" check Name/ID/all Check for an update of an installed plugin")
|
print(" check Name/ID/all changelog Check for an update of an installed plugin")
|
||||||
print(" update Name/ID/all Update installed plugins to the latest version")
|
print(" update Name/ID/all Update installed plugins to the latest version")
|
||||||
print(" search Name Search for a plugin and download the latest version")
|
print(" search Name Search for a plugin and download the latest version")
|
||||||
print(" remove Name/ID Delete an installed plugin")
|
print(" remove Name/ID Delete an installed plugin")
|
||||||
@ -120,7 +120,7 @@ def apiTest():
|
|||||||
apiStatusUrl = 'https://api.spiget.org/v2/status'
|
apiStatusUrl = 'https://api.spiget.org/v2/status'
|
||||||
try:
|
try:
|
||||||
r = requests.get(apiStatusUrl)
|
r = requests.get(apiStatusUrl)
|
||||||
except requests.exceptions.HTTPError:
|
except (requests.exceptions.HTTPError, requests.exceptions.ConnectionError):
|
||||||
print(oColors.brightRed + "Couldn't make a connection to the API. Check you connection to the internet!" + oColors.standardWhite)
|
print(oColors.brightRed + "Couldn't make a connection to the API. Check you connection to the internet!" + oColors.standardWhite)
|
||||||
input("Press any key + enter to exit...")
|
input("Press any key + enter to exit...")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
Loading…
Reference in New Issue
Block a user