Compare commits

..

3 Commits

Author SHA1 Message Date
Neocky
2e459cafe2 Fixed spelling
Changes:
- fixed uppercase variable name
2021-08-01 15:10:36 +02:00
Neocky
1ff34a7372 Fixed ftp file or folder check
Changes:
- fixed issue where it couldn't detect if it would be a file or folder with ftp
2021-08-01 15:06:55 +02:00
Neocky
367ee5be42 Fixed that update all could fail and changed output colors and fixed get-paper command
Changes:
- fixed update all could fail and stop program when the file couldn't be downloaded
- changed colors from `check all` so that green means on latest version and red outdated
- fixed get-paper command
- changed latet version from paper to 1.17.1
- code cleanup
2021-07-18 14:51:02 +02:00
4 changed files with 114 additions and 99 deletions

View File

@@ -100,11 +100,17 @@ def ftp_downloadFile(ftp, downloadPath, fileToDownload):
ftp.quit() ftp.quit()
def ftp_validateFileAttributes(ftp, pluginPath): def ftp_is_file(ftp, pluginPath):
pluginFTPAttribute = ftp.lstat(pluginPath) if ftp.nlst(pluginPath) == [pluginPath]:
if stat.S_ISDIR(pluginFTPAttribute.st_mode): return True
return False else:
elif re.search(r'.jar$', pluginPath): return False
def ftp_validateFileAttributes(ftp, pluginPath):
if ftp_is_file(ftp, pluginPath) is False:
return False
if re.search(r'.jar$', pluginPath):
return True return True
else: else:
return False return False

View File

@@ -233,9 +233,9 @@ def checkInstalledPackage(inputSelectedObject="all", inputOptionalParam=None):
print(f" [{i+1}]".rjust(6), end='') print(f" [{i+1}]".rjust(6), end='')
print(" ", end='') print(" ", end='')
if pluginIsOutdated == True: if pluginIsOutdated == True:
print(oColors.brightGreen + f"{fileName}".ljust(33) + oColors.standardWhite, end='')
elif pluginIsOutdated == False:
print(oColors.brightRed + f"{fileName}".ljust(33) + oColors.standardWhite, end='') print(oColors.brightRed + f"{fileName}".ljust(33) + oColors.standardWhite, end='')
elif pluginIsOutdated == False:
print(oColors.brightGreen + f"{fileName}".ljust(33) + oColors.standardWhite, end='')
else: else:
print(f"{fileName}".ljust(33), end='') print(f"{fileName}".ljust(33), end='')
@@ -337,71 +337,86 @@ def updateInstalledPackage(inputSelectedObject='all'):
i += 1 i += 1
continue continue
if inputSelectedObject == 'all' or inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE): if inputSelectedObject != 'all' and inputSelectedObject != pluginIdStr and not re.search(inputSelectedObject, fileName, re.IGNORECASE):
if INSTALLEDPLUGINLIST[i][4] == 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 configValues.sftp_seperateDownloadPath is True:
pluginPath = configValues.sftp_pathToSeperateDownloadPath
else:
pluginPath = configValues.sftp_folderPath
pluginPath = f"{pluginPath}/{plugin}"
indexNumberUpdated += 1
pluginsUpdated += 1
if configValues.sftp_useSftp:
sftp = createSFTPConnection()
try:
getSpecificPackage(pluginId, pluginPath)
if configValues.sftp_seperateDownloadPath is False:
sftp.remove(pluginPath)
except HTTPError as err:
print(oColors.brightRed + f"HTTPError: {err.code} - {err.reason}" + oColors.standardWhite)
pluginsUpdated -= 1
except FileNotFoundError:
print(oColors.brightRed + f"FileNotFoundError: Old plugin file coulnd't be deleted" + oColors.standardWhite)
else:
ftp = createFTPConnection()
try:
getSpecificPackage(pluginId, pluginPath)
if configValues.sftp_seperateDownloadPath is False:
ftp.delete(pluginPath)
except HTTPError as err:
print(oColors.brightRed + f"HTTPError: {err.code} - {err.reason}" + oColors.standardWhite)
pluginsUpdated -= 1
except FileNotFoundError:
print(oColors.brightRed + f"FileNotFoundError: Old plugin file coulnd't be deleted" + oColors.standardWhite)
else:
if configValues.seperateDownloadPath is True:
pluginPath = configValues.pathToSeperateDownloadPath
else:
pluginPath = configValues.pathToPluginFolder
indexNumberUpdated += 1
pluginsUpdated += 1
try:
getSpecificPackage(pluginId, pluginPath)
if configValues.seperateDownloadPath is False:
pluginPath = f"{pluginPath}/{plugin}"
os.remove(pluginPath)
except HTTPError as err:
print(oColors.brightRed + f"HTTPError: {err.code} - {err.reason}" + oColors.standardWhite)
pluginsUpdated -= 1
except FileNotFoundError:
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 i += 1
continue continue
if INSTALLEDPLUGINLIST[i][4] != True:
i += 1
continue
if INSTALLEDPLUGINLIST[i][4] == False and inputSelectedObject != 'all':
print(oColors.brightGreen + f"{fileName} is already on {latestVersion}" + oColors.standardWhite)
print(oColors.brightRed + "Aborting the update process."+ oColors.standardWhite)
break
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 configValues.sftp_seperateDownloadPath is True:
pluginPath = configValues.sftp_pathToSeperateDownloadPath
else:
pluginPath = configValues.sftp_folderPath
pluginPath = f"{pluginPath}/{plugin}"
indexNumberUpdated += 1
pluginsUpdated += 1
if configValues.sftp_useSftp:
sftp = createSFTPConnection()
try:
getSpecificPackage(pluginId, pluginPath)
if configValues.sftp_seperateDownloadPath is False:
sftp.remove(pluginPath)
except HTTPError as err:
print(oColors.brightRed + f"HTTPError: {err.code} - {err.reason}" + oColors.standardWhite)
pluginsUpdated -= 1
except TypeError:
print(oColors.brightRed + f"TypeError: Couldn't download new version. Is the file available on spigotmc?" + oColors.standardWhite)
pluginsUpdated -= 1
except FileNotFoundError:
print(oColors.brightRed + f"FileNotFoundError: Old plugin file coulnd't be deleted" + oColors.standardWhite)
else:
ftp = createFTPConnection()
try:
getSpecificPackage(pluginId, pluginPath)
if configValues.sftp_seperateDownloadPath is False:
ftp.delete(pluginPath)
except HTTPError as err:
print(oColors.brightRed + f"HTTPError: {err.code} - {err.reason}" + oColors.standardWhite)
pluginsUpdated -= 1
except TypeError:
print(oColors.brightRed + f"TypeError: Couldn't download new version. Is the file available on spigotmc?" + oColors.standardWhite)
pluginsUpdated -= 1
except FileNotFoundError:
print(oColors.brightRed + f"FileNotFoundError: Old plugin file coulnd't be deleted" + oColors.standardWhite)
else:
if configValues.seperateDownloadPath is True:
pluginPath = configValues.pathToSeperateDownloadPath
else:
pluginPath = configValues.pathToPluginFolder
indexNumberUpdated += 1
pluginsUpdated += 1
try:
getSpecificPackage(pluginId, pluginPath)
if configValues.seperateDownloadPath is False:
pluginPath = f"{pluginPath}/{plugin}"
os.remove(pluginPath)
except HTTPError as err:
print(oColors.brightRed + f"HTTPError: {err.code} - {err.reason}" + oColors.standardWhite)
pluginsUpdated -= 1
except TypeError:
print(oColors.brightRed + f"TypeError: Couldn't download new version. Is the file available on spigotmc?" + oColors.standardWhite)
pluginsUpdated -= 1
except FileNotFoundError:
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
i += 1 i += 1
except TypeError: except TypeError:

View File

@@ -98,24 +98,16 @@ def updateServerjar(serverJarBuild='latest'):
if 'paper' in installedServerjarFullName: if 'paper' in installedServerjarFullName:
print(oColors.brightBlack + f"Updating Paper to build: {serverJarBuild}" + oColors.standardWhite) print(oColors.brightBlack + f"Updating Paper to build: {serverJarBuild}" + oColors.standardWhite)
if not configValues.localPluginFolder: try:
try: papermc_downloader(serverJarBuild, None, installedServerjarFullName)
papermc_downloader(serverJarBuild, installedServerjarFullName) if not configValues.localPluginFolder:
sftp.remove(serverJarPath) sftp.remove(serverJarPath)
except HTTPError as err: else:
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
except FileNotFoundError:
print(oColors.brightRed + "Error: Old serverjar file coulnd't be deleted" + oColors.standardWhite)
else:
try:
papermc_downloader(serverJarBuild, installedServerjarFullName)
os.remove(serverJarPath) os.remove(serverJarPath)
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)
except FileNotFoundError: except FileNotFoundError:
print(oColors.brightRed + "Error: Old serverjar file coulnd't be deleted" + oColors.standardWhite) print(oColors.brightRed + "Error: Old serverjar file coulnd't be deleted" + oColors.standardWhite)
else: else:
print(oColors.brightRed + f"{installedServerjarFullName} isn't supported.") print(oColors.brightRed + f"{installedServerjarFullName} isn't supported.")
print(oColors.brightRed + "Aborting the process." + oColors.standardWhite) print(oColors.brightRed + "Aborting the process." + oColors.standardWhite)

View File

@@ -111,28 +111,28 @@ def paperCheckForUpdate(installedServerjarFullName):
# Report an error if getInstalledPaperMinecraftVersion encountered an issue. # Report an error if getInstalledPaperMinecraftVersion encountered an issue.
if not mcVersion: if not mcVersion:
print(oColors.brightRed + f"ERR: An error was encountered while detecting the server's Minecraft version." + print(oColors.brightRed + "ERR: An error was encountered while detecting the server's Minecraft version." +
oColors.standardWhite) oColors.standardWhite)
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 + "ERR: An error was encountered while detecting the server's Paper version." +
oColors.standardWhite) oColors.standardWhite)
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 + "ERR: An error was encountered while fetching the server's version group." +
oColors.standardWhite) oColors.standardWhite)
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 + "ERR: An error was encountered while fetching the latest version of PaperMC." +
oColors.standardWhite) oColors.standardWhite)
return False # Not currently handled, but can be at a later date. Currently just stops the following from return False # Not currently handled, but can be at a later date. Currently just stops the following from
# being printed. # being printed.
@@ -140,27 +140,29 @@ def paperCheckForUpdate(installedServerjarFullName):
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 + "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)
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. │")
print("└─────┴────────────────────────────────┴──────────────┴──────────────┴───────────────────") print("└─────┴────────────────────────────────┴──────────────┴──────────────┘")
print(" [1]".rjust(6), end='') print(" [1]".rjust(6), end='')
print(" ", end='') print(" ", end='')
print("paper".ljust(33), end='') if paperVersionBehind != 0:
print(oColors.brightRed + "paper".ljust(33) + oColors.standardWhite, end='')
else:
print(oColors.brightGreen + "paper".ljust(33) + oColors.standardWhite, end='')
print(f"{paperInstalledBuild}".ljust(15), end='') print(f"{paperInstalledBuild}".ljust(15), end='')
print(f"{paperLatestBuild}".ljust(15), end='') print(f"{paperLatestBuild}".ljust(15))
print(f"{paperVersionBehind}".ljust(8))
print(oColors.brightYellow + f"Versions behind: [{paperVersionBehind}]" + oColors.standardWhite) 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', mcVersion=None, installedServerjarName=None):
configValues = configurationValues() configValues = configurationValues()
if configValues.localPluginFolder == False: if configValues.localPluginFolder == False:
downloadPath = createTempPluginFolder() downloadPath = createTempPluginFolder()
@@ -172,7 +174,7 @@ def papermc_downloader(paperBuild='latest', installedServerjarName=None, mcVersi
if mcVersion == None: if mcVersion == None:
if paperBuild == 'latest': if paperBuild == 'latest':
mcVersion = '1.17' mcVersion = '1.17.1'
else: else:
mcVersion = findBuildVersion(paperBuild) mcVersion = findBuildVersion(paperBuild)