Compare commits

...

17 Commits

Author SHA1 Message Date
Neocky
3bcb3de4cf Fixed error when searching for plugins
Changes:
- fixed bug when searching for plugins where the name couldn't be sanitized
- fixed bug when searching for plugins with numbers in name
2021-08-26 19:24:17 +02:00
Neocky
9a70733421 Changed description for FTP Port support 2021-08-07 18:58:23 +02:00
Neocky
449232e2ca Merge pull request #38 from TheDudeFromCI/patch-1
Added custom port support for FTP access.
2021-08-07 18:50:18 +02:00
TheDudeFromCI
1c74d8501c Apply suggestions from code review
Co-authored-by: Neocky <Neocky@users.noreply.github.com>
2021-08-04 19:52:10 -07:00
TheDudeFromCI
9289872831 Removed warning in default config 2021-08-03 03:01:51 -07:00
TheDudeFromCI
0c3bace49e Added custom port support for ftp access 2021-08-03 03:00:23 -07:00
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
Neocky
abf07e8301 Fixed issues and fixed spelling
Changes:
- Fixed #33
- Fixed #34
- Fixed #35
- Input for update confirmation can also be uppercase now
- fixed spelling
- some code cleanup
2021-07-14 21:26:06 +02:00
Neocky
c551c6bd66 Fixed spelling 2021-07-14 21:11:36 +02:00
Neocky
572a7de68a Added different python badge 2021-07-09 20:36:17 +02:00
Neocky
2b00942749 Added new gif 2021-06-27 02:18:34 +02:00
Neocky
50038c4474 Fixed issue with seperate download path for sftp, ftp & local
Changes:
- fixed issue when updating with the activated option of a seperate download path
- removed leftover debug output
2021-06-27 01:46:15 +02:00
Neocky
2eb4940574 Changed formating 2021-06-22 00:26:00 +02:00
Neocky
496334a2fa Fixed check with seperatedownloadpath issue
Changes:
- fixed issue with seperate downloadpath and checking
2021-06-22 00:08:57 +02:00
Neocky
42be836928 Fixed wrong folder was used when trying to download plugin
Changes:
- fixed wrong folder use while downloading plugins
- made code a little bit cleaner
2021-06-21 10:18:52 +02:00
8 changed files with 208 additions and 181 deletions

View File

@@ -5,7 +5,7 @@
</p> </p>
<p align="center"> <p align="center">
<a href="https://www.python.org/"> <img src="https://forthebadge.com/images/badges/made-with-python.svg" alt="madewithpython" border="0"></a> <a href="https://www.python.org/"> <img src="https://img.shields.io/badge/made%20with-python%20%F0%9F%90%8D-brightgreen" alt="madewithpython" border="0"></a>
</p> </p>
<p align="center"> <p align="center">
@@ -13,15 +13,13 @@
<a href="https://github.com/Neocky/pluGET/releases"> <img src="https://img.shields.io/github/v/release/Neocky/pluGET?include_prereleases" alt"latestrelease"></a> <a href="https://github.com/Neocky/pluGET/releases"> <img src="https://img.shields.io/github/v/release/Neocky/pluGET?include_prereleases" alt"latestrelease"></a>
<a href="https://github.com/Neocky/pluGET/releases"> <img src="https://img.shields.io/github/downloads/Neocky/pluGET/total" alt="downloads" border="0"></a> <a href="https://github.com/Neocky/pluGET/releases"> <img src="https://img.shields.io/github/downloads/Neocky/pluGET/total" alt="downloads" border="0"></a>
<a href="https://hits.seeyoufarm.com"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FNeocky%2FpluGET&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false"/></a> <a href="https://hits.seeyoufarm.com"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FNeocky%2FpluGET&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false"/></a>
</p> </p>
# pluGET # pluGET
#### A powerful package manager which updates [Plugins](https://www.spigotmc.org/resources/) and Server Software for minecraft servers. #### A powerful package manager which updates [Plugins](https://www.spigotmc.org/resources/) and Server Software for minecraft servers.
<img src="https://www.bildhost.com/images/2021/03/23/pluGET.gif" alt="pluGET.gif" border="0" /> <img src="https://www.bildhost.com/images/2021/06/27/ezgif-1-28e102202188.gif" alt="pluGET.gif" border="0" />
<details> <details>
<summary>Screenshots</summary> <summary>Screenshots</summary>
@@ -51,7 +49,7 @@ The program works with a locally installed server or with a remote host through
It uses the [Spiget](https://spiget.org/) API to download and compare plugin versions and can download the latest version of plugins from the [Spigot](https://www.spigotmc.org/) site. It uses the [Spiget](https://spiget.org/) API to download and compare plugin versions and can download the latest version of plugins from the [Spigot](https://www.spigotmc.org/) site.
It can also compare and download the latest update of specific server software (e.g. [PaperMC](https://papermc.io/)). It can also compare and download the latest update of specific server software (e.g. [PaperMC](https://papermc.io/)).
Plugin management was the hard part of managing a minecraft server. The time it took to check the [Spigot ressource](https://www.spigotmc.org/resources/) page for updates for the installed plugins and updating all plugins manually which have available updates was too long and daunting. Plugin management was the hard part of managing a minecraft server. The time it took to check the [Spigot resource](https://www.spigotmc.org/resources/) page for updates for the installed plugins and updating all plugins manually which have available updates was too long and daunting.
So I built pluGET to automate and ease the plugin handling of a minecraft server and to turn the most time consuming part of managing a minecraft server to an easy one. So I built pluGET to automate and ease the plugin handling of a minecraft server and to turn the most time consuming part of managing a minecraft server to an easy one.
This program is suited for minecraft server owners who want to save time and stay on top of their plugin versions. This program is suited for minecraft server owners who want to save time and stay on top of their plugin versions.
@@ -103,7 +101,7 @@ Execute the `installer.bat` file to automaticcally install the needed packages f
> This is a normal behaviour from the windows defender because this is a unknown `.bat` file. > This is a normal behaviour from the windows defender because this is a unknown `.bat` file.
> To run the `installer.bat` anyway, click `More Info` and then `Run anyway` when the message pops up. > To run the `installer.bat` anyway, click `More Info` and then `Run anyway` when the message pops up.
##### Manually #### Manually
Execute this command in the `\plugGET` folder: Execute this command in the `\plugGET` folder:
```python ```python
py -m pip install -r requirements.txt py -m pip install -r requirements.txt

View File

@@ -20,12 +20,14 @@ class configurationValues:
self.sftp_user = config['SFTP - Remote Server']['Username'] self.sftp_user = config['SFTP - Remote Server']['Username']
self.sftp_password = config['SFTP - Remote Server']['Password'] self.sftp_password = config['SFTP - Remote Server']['Password']
sftp_port = config['SFTP - Remote Server']['SFTPPort'] sftp_port = config['SFTP - Remote Server']['SFTPPort']
ftp_port = config['SFTP - Remote Server']['FTPPort']
self.sftp_folderPath = config['SFTP - Remote Server']['PluginFolderOnServer'] self.sftp_folderPath = config['SFTP - Remote Server']['PluginFolderOnServer']
sftp_useSftp = config['SFTP - Remote Server']['USE_SFTP'] sftp_useSftp = config['SFTP - Remote Server']['USE_SFTP']
sftp_seperateDownloadPath = config['SFTP - Remote Server']['SeperateDownloadPath'] sftp_seperateDownloadPath = config['SFTP - Remote Server']['SeperateDownloadPath']
self.sftp_pathToSeperateDownloadPath = config['SFTP - Remote Server']['PathToSeperateDownloadPath'] self.sftp_pathToSeperateDownloadPath = config['SFTP - Remote Server']['PathToSeperateDownloadPath']
self.sftp_port = int(sftp_port) self.sftp_port = int(sftp_port)
self.ftp_port = int(ftp_port)
if localPluginFolder == 'True': if localPluginFolder == 'True':
self.localPluginFolder = True self.localPluginFolder = True
else: else:
@@ -72,13 +74,15 @@ def createConfig():
config['SFTP - Remote Server']['Server'] = '0.0.0.0' config['SFTP - Remote Server']['Server'] = '0.0.0.0'
config['SFTP - Remote Server']['Username'] = 'user' config['SFTP - Remote Server']['Username'] = 'user'
config['SFTP - Remote Server']['Password'] = 'password' config['SFTP - Remote Server']['Password'] = 'password'
config['SFTP - Remote Server'][';'] = 'If a different Port for SFTP needs to be used (Works only for SFTP)' config['SFTP - Remote Server'][';'] = 'If a different Port for SFTP needs to be used (Default: 22)'
config['SFTP - Remote Server']['SFTPPort'] = '22' config['SFTP - Remote Server']['SFTPPort'] = '22'
config['SFTP - Remote Server'][';_'] = 'Change the path below if the plugin folder path is different on the SFTP/FTP server (Change only if you know what you are doing)' config['SFTP - Remote Server'][';_'] = 'If a different Port for FTP needs to be used (Default: 21)'
config['SFTP - Remote Server']['FTPPort'] = '21'
config['SFTP - Remote Server'][';__'] = 'Change the path below if the plugin folder path is different on the SFTP/FTP server (Change only if you know what you are doing)'
config['SFTP - Remote Server']['PluginFolderOnServer'] = '/plugins' config['SFTP - Remote Server']['PluginFolderOnServer'] = '/plugins'
config['SFTP - Remote Server'][';__'] = 'If you want to use FTP instead of SFTP change to (False) else use (True)' config['SFTP - Remote Server'][';___'] = 'If you want to use FTP instead of SFTP change to (False) else use (True)'
config['SFTP - Remote Server']['USE_SFTP'] = 'True' config['SFTP - Remote Server']['USE_SFTP'] = 'True'
config['SFTP - Remote Server'][';___'] = 'For a different folder to store the updated plugins (Only with the update command!) change to (True/False) and the path below' config['SFTP - Remote Server'][';____'] = 'For a different folder to store the updated plugins (Only with the update command!) change to (True/False) and the path below'
config['SFTP - Remote Server']['SeperateDownloadPath'] = 'False' config['SFTP - Remote Server']['SeperateDownloadPath'] = 'False'
config['SFTP - Remote Server']['PathToSeperateDownloadPath'] = '/plugins' config['SFTP - Remote Server']['PathToSeperateDownloadPath'] = '/plugins'

View File

@@ -10,9 +10,10 @@ from handlers.handle_config import configurationValues
def createFTPConnection(): def createFTPConnection():
configValues = configurationValues() configValues = configurationValues()
ftp = ftplib.FTP(configValues.sftp_server, user=configValues.sftp_user, \
passwd=configValues.sftp_password)
try: try:
ftp = ftplib.FTP()
ftp.connect(configValues.sftp_server, configValues.ftp_port)
ftp.login(configValues.sftp_user, configValues.sftp_password)
return ftp return ftp
except UnboundLocalError: except UnboundLocalError:
print(oColors.brightRed + "[FTP]: Check your config.ini!" + oColors.standardWhite) print(oColors.brightRed + "[FTP]: Check your config.ini!" + oColors.standardWhite)
@@ -29,8 +30,12 @@ def ftp_showPlugins(ftp):
def ftp_upload_file(ftp, itemPath): def ftp_upload_file(ftp, itemPath):
configValues = configurationValues() configValues = configurationValues()
if configValues.sftp_seperateDownloadPath is True:
uploadFolderPath = configValues.sftp_pathToSeperateDownloadPath
else:
uploadFolderPath = configValues.sftp_folderPath
try: try:
ftp.cwd(configValues.sftp_folderPath) ftp.cwd(uploadFolderPath)
itemPath = os.path.relpath(itemPath, 'TempSFTPFolder/') itemPath = os.path.relpath(itemPath, 'TempSFTPFolder/')
itemPath = str(itemPath) itemPath = str(itemPath)
currentDirectory = os.getcwd() currentDirectory = os.getcwd()
@@ -46,7 +51,6 @@ def ftp_upload_file(ftp, itemPath):
def ftp_upload_server_jar(ftp, itemPath): def ftp_upload_server_jar(ftp, itemPath):
try: try:
print(f"itempath: {itemPath}")
ftp.cwd('.') ftp.cwd('.')
itemPath = os.path.relpath(itemPath, 'TempSFTPFolder/') itemPath = os.path.relpath(itemPath, 'TempSFTPFolder/')
itemPath = str(itemPath) itemPath = str(itemPath)
@@ -97,11 +101,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

@@ -37,8 +37,12 @@ def sftp_showPlugins(sftp):
def sftp_upload_file(sftp, itemPath): def sftp_upload_file(sftp, itemPath):
configValues = configurationValues() configValues = configurationValues()
if configValues.sftp_seperateDownloadPath is True:
uploadFolderPath = configValues.sftp_pathToSeperateDownloadPath
else:
uploadFolderPath = configValues.sftp_folderPath
try: try:
sftp.chdir(configValues.sftp_folderPath) sftp.chdir(uploadFolderPath)
sftp.put(itemPath) sftp.put(itemPath)
except FileNotFoundError: except FileNotFoundError:

View File

@@ -21,8 +21,11 @@ def handleRegexPackageName(packageNameFull):
packageNameFull2 = packageNameFull.replace(unwantedpackageNameString, '') packageNameFull2 = packageNameFull.replace(unwantedpackageNameString, '')
# gets the real packagename "word1 & word2" is not supported only gets word 1 # gets the real packagename "word1 & word2" is not supported only gets word 1
packageName = re.search(r'([a-zA-Z]\d*)+(\s?\-*\_*[a-zA-Z]\d*\+*\-*\'*)+', packageNameFull2) packageName = re.search(r'([a-zA-Z]\d*)+(\s?\-*\_*[a-zA-Z]\d*\+*\-*\'*)+', packageNameFull2)
packageNameFullString = packageName.group() try:
packageNameOnly = packageNameFullString.replace(' ', '') packageNameFullString = packageName.group()
packageNameOnly = packageNameFullString.replace(' ', '')
except AttributeError:
packageNameOnly = unwantedpackageNameString
return packageNameOnly return packageNameOnly
@@ -51,20 +54,20 @@ def getVersionName(packageId, versionId):
return versionName return versionName
def searchPackage(ressourceName): def searchPackage(resourceName):
configValues = configurationValues() 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/{resourceName}?field=name&sort=-downloads"
packageName = doAPIRequest(url) packageName = doAPIRequest(url)
i = 1 i = 1
print(oColors.brightBlack + f"Searching: {ressourceName}" + oColors.standardWhite) print(oColors.brightBlack + f"Searching: {resourceName}" + oColors.standardWhite)
print("┌─────┬─────────────────────────────┬───────────┬──────────────────────────────────────────────────────────────────────┐") print("┌─────┬─────────────────────────────┬───────────┬──────────────────────────────────────────────────────────────────────┐")
print("│ No. │ Name │ Downloads │ Description │") print("│ No. │ Name │ Downloads │ Description │")
print("└─────┴─────────────────────────────┴───────────┴──────────────────────────────────────────────────────────────────────┘") print("└─────┴─────────────────────────────┴───────────┴──────────────────────────────────────────────────────────────────────┘")
for ressource in packageName: for resource in packageName:
pName = ressource["name"] pName = resource["name"]
newName = handleRegexPackageName(pName) newName = handleRegexPackageName(pName)
pTag = ressource["tag"] pTag = resource["tag"]
pDownloads = ressource["downloads"] pDownloads = resource["downloads"]
print(f" [{i}]".rjust(6), end='') print(f" [{i}]".rjust(6), end='')
print(" ", end='') print(" ", end='')
print(f"{newName}".ljust(30), end='') print(f"{newName}".ljust(30), end='')
@@ -73,37 +76,35 @@ def searchPackage(ressourceName):
print(f"{pTag}".ljust(120)) print(f"{pTag}".ljust(120))
i = i + 1 i = i + 1
ressourceSelected = int(input("Select your wanted Ressource (No.)(0 to exit): ")) resourceSelected = int(input("Select your wanted resource (No.)(0 to exit): "))
if ressourceSelected != 0: if resourceSelected != 0:
ressourceSelected = ressourceSelected - 1 resourceSelected = resourceSelected - 1
ressourceId = packageName[ressourceSelected]["id"] resourceId = packageName[resourceSelected]["id"]
if not configValues.localPluginFolder: if not configValues.localPluginFolder:
try: if configValues.sftp_seperateDownloadPath is True:
if configValues.sftp_seperateDownloadPath is True: pluginDownloadPath = configValues.sftp_pathToSeperateDownloadPath
getSpecificPackage(ressourceId, configValues.sftp_pathToSeperateDownloadPath) else:
else: pluginDownloadPath = configValues.sftp_folderPath
getSpecificPackage(ressourceId, configValues.sftp_folderPath)
except HTTPError as err:
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
else: else:
try: if configValues.seperateDownloadPath is True:
if configValues.seperateDownloadPath is True: pluginDownloadPath = configValues.pathToSeperateDownloadPath
getSpecificPackage(ressourceId, configValues.pathToPluginFolder) else:
else: pluginDownloadPath = configValues.pathToPluginFolder
getSpecificPackage(ressourceId, configValues.pathToSeperateDownloadPath) try:
except HTTPError as err: getSpecificPackage(resourceId, pluginDownloadPath)
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite) except HTTPError as err:
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
def downloadSpecificVersion(ressourceId, downloadPath, versionID='latest'): def downloadSpecificVersion(resourceId, downloadPath, versionID='latest'):
configValues = configurationValues() configValues = configurationValues()
if versionID != 'latest': if versionID != 'latest':
#url = f"https://spigotmc.org/resources/{ressourceId}/download?version={versionID}" #url = f"https://spigotmc.org/resources/{resourceId}/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)
print(oColors.brightRed + "Reverting to latest version." + oColors.standardWhite) print(oColors.brightRed + "Reverting to latest version." + oColors.standardWhite)
url = f"https://api.spiget.org/v2/resources/{ressourceId}/download" url = f"https://api.spiget.org/v2/resources/{resourceId}/download"
#url = f"https://api.spiget.org/v2/resources/{ressourceId}/versions/latest/download" #throws 403 forbidden error...cloudflare :( #url = f"https://api.spiget.org/v2/resources/{resourceId}/versions/latest/download" #throws 403 forbidden error...cloudflare :(
urrlib_opener = urllib.request.build_opener() urrlib_opener = urllib.request.build_opener()
urrlib_opener.addheaders = [('User-agent', 'pluGET/1.0')] urrlib_opener.addheaders = [('User-agent', 'pluGET/1.0')]
@@ -129,22 +130,26 @@ def downloadSpecificVersion(ressourceId, downloadPath, versionID='latest'):
ftp_upload_file(ftpSession, downloadPath) ftp_upload_file(ftpSession, downloadPath)
def getSpecificPackage(ressourceId, downloadPath, inputPackageVersion='latest'): def getSpecificPackage(resourceId, downloadPath, inputPackageVersion='latest'):
configValues = configurationValues() configValues = configurationValues()
if configValues.localPluginFolder == False: 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/{resourceId}"
packageDetails = doAPIRequest(url) packageDetails = doAPIRequest(url)
packageName = packageDetails["name"] try:
packageName = packageDetails["name"]
except KeyError:
print(oColors.brightRed + "Error: Plugin ID couldn't be found" + oColors.standardWhite)
return None
packageNameNew = handleRegexPackageName(packageName) packageNameNew = handleRegexPackageName(packageName)
versionId = getVersionID(ressourceId, inputPackageVersion) versionId = getVersionID(resourceId, inputPackageVersion)
packageVersion = getVersionName(ressourceId, versionId) packageVersion = getVersionName(resourceId, versionId)
packageDownloadName = f"{packageNameNew}-{packageVersion}.jar" packageDownloadName = f"{packageNameNew}-{packageVersion}.jar"
downloadPackagePath = Path(f"{downloadPath}/{packageDownloadName}") downloadPackagePath = Path(f"{downloadPath}/{packageDownloadName}")
if inputPackageVersion is None or inputPackageVersion == 'latest': if inputPackageVersion is None or inputPackageVersion == 'latest':
downloadSpecificVersion(ressourceId=ressourceId, downloadPath=downloadPackagePath) downloadSpecificVersion(resourceId=resourceId, downloadPath=downloadPackagePath)
else: else:
downloadSpecificVersion(ressourceId, downloadPackagePath, versionId) downloadSpecificVersion(resourceId, downloadPackagePath, versionId)
if not configValues.localPluginFolder: if not configValues.localPluginFolder:
deleteTempPluginFolder(downloadPath) deleteTempPluginFolder(downloadPath)

View File

@@ -75,24 +75,35 @@ def getUpdateDescription(pluginId):
return stringnonEmptyLines return stringnonEmptyLines
def versionTuple(versionString):
return tuple(map(int, (versionString.split("."))))
def getVersionWithoutLetters(versionString):
return re.sub(r'([A-Za-z]*)', '', versionString)
def compareVersions(plugin_latest_version, pluginVersion): def compareVersions(plugin_latest_version, pluginVersion):
if pluginVersion < plugin_latest_version: try:
plugin_is_outdated = True pluginVersionTuple = versionTuple(getVersionWithoutLetters(pluginVersion))
plugin_latest_versionTuple = versionTuple(getVersionWithoutLetters(plugin_latest_version))
except ValueError:
return False
if pluginVersionTuple < plugin_latest_versionTuple:
return True
else: else:
plugin_is_outdated = False return False
return plugin_is_outdated
def eggCrackingJar(localJarFileName, searchMode): def eggCrackingJar(localJarFileName, searchMode):
configValues = configurationValues() configValues = configurationValues()
if not configValues.localPluginFolder: if not configValues.localPluginFolder:
tempPluginFolderPath = createTempPluginFolder()
if configValues.sftp_useSftp: if configValues.sftp_useSftp:
tempPluginFolderPath = createTempPluginFolder()
sftp = createSFTPConnection() sftp = createSFTPConnection()
pathToPluginJar = Path(f"{tempPluginFolderPath}/{localJarFileName}") pathToPluginJar = Path(f"{tempPluginFolderPath}/{localJarFileName}")
sftp_downloadFile(sftp, pathToPluginJar, localJarFileName) sftp_downloadFile(sftp, pathToPluginJar, localJarFileName)
else: else:
tempPluginFolderPath = createTempPluginFolder()
ftp = createFTPConnection() ftp = createFTPConnection()
pathToPluginJar = Path(f"{tempPluginFolderPath}/{localJarFileName}") pathToPluginJar = Path(f"{tempPluginFolderPath}/{localJarFileName}")
ftp_downloadFile(ftp, pathToPluginJar, localJarFileName) ftp_downloadFile(ftp, pathToPluginJar, localJarFileName)
@@ -122,6 +133,9 @@ def eggCrackingJar(localJarFileName, searchMode):
except FileNotFoundError: except FileNotFoundError:
pluginVersion = '' pluginVersion = ''
pluginName = '' pluginName = ''
except KeyError:
pluginVersion = ''
pluginName = ''
if not configValues.localPluginFolder: if not configValues.localPluginFolder:
deleteTempPluginFolder(tempPluginFolderPath) deleteTempPluginFolder(tempPluginFolderPath)
if searchMode == 'version': if searchMode == 'version':
@@ -155,11 +169,7 @@ def checkInstalledPackage(inputSelectedObject="all", inputOptionalParam=None):
try: try:
for plugin in track(pluginList, description="Checking for updates" ,transient=True, complete_style="bright_yellow"): for plugin in track(pluginList, description="Checking for updates" ,transient=True, complete_style="bright_yellow"):
if not configValues.localPluginFolder: if not configValues.localPluginFolder:
if configValues.sftp_seperateDownloadPath is True: pluginFile = f"{configValues.sftp_folderPath}/{plugin}"
pluginFile = f"{configValues.sftp_pathToSeperateDownloadPath}/{plugin}"
else:
pluginFile = f"{configValues.sftp_folderPath}/{plugin}"
if configValues.sftp_useSftp: if configValues.sftp_useSftp:
pluginAttributes = sftp_validateFileAttributes(connection, pluginFile) pluginAttributes = sftp_validateFileAttributes(connection, pluginFile)
if pluginAttributes == False: if pluginAttributes == False:
@@ -223,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='')
@@ -268,7 +278,7 @@ def updateInstalledPackage(inputSelectedObject='all'):
print() print()
updateConfirmation = input("Update these plugins [y/n] ? ") updateConfirmation = input("Update these plugins [y/n] ? ")
if updateConfirmation != "y": if str.lower(updateConfirmation) != "y":
print(oColors.brightRed + "Aborting the update process."+ oColors.standardWhite) print(oColors.brightRed + "Aborting the update process."+ oColors.standardWhite)
return False return False
@@ -290,11 +300,7 @@ def updateInstalledPackage(inputSelectedObject='all'):
for pluginArray in track(INSTALLEDPLUGINLIST, 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] plugin = INSTALLEDPLUGINLIST[i][0]
if not configValues.localPluginFolder: if not configValues.localPluginFolder:
if configValues.sftp_seperateDownloadPath is True: pluginFile = f"{configValues.sftp_folderPath}/{plugin}"
pluginFile = f"{configValues.sftp_pathToSeperateDownloadPath}/{plugin}"
else:
pluginFile = f"{configValues.sftp_folderPath}/{plugin}"
if configValues.sftp_useSftp: if configValues.sftp_useSftp:
pluginAttributes = sftp_validateFileAttributes(connection, pluginFile) pluginAttributes = sftp_validateFileAttributes(connection, pluginFile)
if pluginAttributes == False: if pluginAttributes == False:
@@ -331,77 +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_useSftp:
if configValues.sftp_seperateDownloadPath is True:
pluginPath = configValues.sftp_pathToSeperateDownloadPath
else:
pluginPath = configValues.sftp_folderPath
pluginPath = 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"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.sftp_seperateDownloadPath is True:
pluginPath = configValues.sftp_pathToSeperateDownloadPath
else:
pluginPath = configValues.sftp_folderPath
pluginPath = f"{pluginPath}/{plugin}"
ftp = createFTPConnection()
indexNumberUpdated += 1
pluginsUpdated += 1
try:
getSpecificPackage(pluginId, configValues.sftp_folderPath)
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 = 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"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:
@@ -439,10 +454,10 @@ def getInstalledPlugin(localFileName, localFileVersion, localPluginFullName):
localFileVersion = localFileVersionNew localFileVersion = localFileVersionNew
for ressource in packageName: for resource in packageName:
if plugin_match_found == True: if plugin_match_found == True:
continue continue
pID = ressource["id"] pID = resource["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)
@@ -461,10 +476,7 @@ def getInstalledPlugin(localFileName, localFileVersion, localPluginFullName):
else: else:
if plugin_match_found != True: if plugin_match_found != True:
pID = None pID = updateId = plugin_latest_version = plugin_is_outdated = None
updateId = None
plugin_latest_version = None
plugin_is_outdated = None
addToPluginList(localPluginFullName, pID, updateId, plugin_latest_version , plugin_is_outdated) addToPluginList(localPluginFullName, pID, updateId, plugin_latest_version , plugin_is_outdated)
return pluginID return pluginID

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)