Compare commits

..

8 Commits

Author SHA1 Message Date
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
5 changed files with 86 additions and 86 deletions

View File

@@ -5,7 +5,7 @@
</p>
<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 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/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>
</p>
# pluGET
#### 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>
<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 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.
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.
> 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:
```python
py -m pip install -r requirements.txt

View File

@@ -29,8 +29,12 @@ def ftp_showPlugins(ftp):
def ftp_upload_file(ftp, itemPath):
configValues = configurationValues()
if configValues.sftp_seperateDownloadPath is True:
uploadFolderPath = configValues.sftp_pathToSeperateDownloadPath
else:
uploadFolderPath = configValues.sftp_folderPath
try:
ftp.cwd(configValues.sftp_folderPath)
ftp.cwd(uploadFolderPath)
itemPath = os.path.relpath(itemPath, 'TempSFTPFolder/')
itemPath = str(itemPath)
currentDirectory = os.getcwd()
@@ -46,7 +50,6 @@ def ftp_upload_file(ftp, itemPath):
def ftp_upload_server_jar(ftp, itemPath):
try:
print(f"itempath: {itemPath}")
ftp.cwd('.')
itemPath = os.path.relpath(itemPath, 'TempSFTPFolder/')
itemPath = str(itemPath)

View File

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

View File

@@ -51,20 +51,20 @@ def getVersionName(packageId, versionId):
return versionName
def searchPackage(ressourceName):
def searchPackage(resourceName):
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)
i = 1
print(oColors.brightBlack + f"Searching: {ressourceName}" + oColors.standardWhite)
print(oColors.brightBlack + f"Searching: {resourceName}" + oColors.standardWhite)
print("┌─────┬─────────────────────────────┬───────────┬──────────────────────────────────────────────────────────────────────┐")
print("│ No. │ Name │ Downloads │ Description │")
print("└─────┴─────────────────────────────┴───────────┴──────────────────────────────────────────────────────────────────────┘")
for ressource in packageName:
pName = ressource["name"]
for resource in packageName:
pName = resource["name"]
newName = handleRegexPackageName(pName)
pTag = ressource["tag"]
pDownloads = ressource["downloads"]
pTag = resource["tag"]
pDownloads = resource["downloads"]
print(f" [{i}]".rjust(6), end='')
print(" ", end='')
print(f"{newName}".ljust(30), end='')
@@ -73,37 +73,35 @@ def searchPackage(ressourceName):
print(f"{pTag}".ljust(120))
i = i + 1
ressourceSelected = int(input("Select your wanted Ressource (No.)(0 to exit): "))
if ressourceSelected != 0:
ressourceSelected = ressourceSelected - 1
ressourceId = packageName[ressourceSelected]["id"]
resourceSelected = int(input("Select your wanted resource (No.)(0 to exit): "))
if resourceSelected != 0:
resourceSelected = resourceSelected - 1
resourceId = packageName[resourceSelected]["id"]
if not configValues.localPluginFolder:
try:
if configValues.sftp_seperateDownloadPath is True:
getSpecificPackage(ressourceId, configValues.sftp_pathToSeperateDownloadPath)
else:
getSpecificPackage(ressourceId, configValues.sftp_folderPath)
except HTTPError as err:
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
if configValues.sftp_seperateDownloadPath is True:
pluginDownloadPath = configValues.sftp_pathToSeperateDownloadPath
else:
pluginDownloadPath = configValues.sftp_folderPath
else:
try:
if configValues.seperateDownloadPath is True:
getSpecificPackage(ressourceId, configValues.pathToPluginFolder)
else:
getSpecificPackage(ressourceId, configValues.pathToSeperateDownloadPath)
except HTTPError as err:
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
if configValues.seperateDownloadPath is True:
pluginDownloadPath = configValues.pathToSeperateDownloadPath
else:
pluginDownloadPath = configValues.pathToPluginFolder
try:
getSpecificPackage(resourceId, pluginDownloadPath)
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()
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 + "Reverting to latest version." + oColors.standardWhite)
url = f"https://api.spiget.org/v2/resources/{ressourceId}/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}/download"
#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.addheaders = [('User-agent', 'pluGET/1.0')]
@@ -129,22 +127,22 @@ def downloadSpecificVersion(ressourceId, downloadPath, versionID='latest'):
ftp_upload_file(ftpSession, downloadPath)
def getSpecificPackage(ressourceId, downloadPath, inputPackageVersion='latest'):
def getSpecificPackage(resourceId, downloadPath, inputPackageVersion='latest'):
configValues = configurationValues()
if configValues.localPluginFolder == False:
downloadPath = createTempPluginFolder()
url = f"https://api.spiget.org/v2/resources/{ressourceId}"
url = f"https://api.spiget.org/v2/resources/{resourceId}"
packageDetails = doAPIRequest(url)
packageName = packageDetails["name"]
packageNameNew = handleRegexPackageName(packageName)
versionId = getVersionID(ressourceId, inputPackageVersion)
packageVersion = getVersionName(ressourceId, versionId)
versionId = getVersionID(resourceId, inputPackageVersion)
packageVersion = getVersionName(resourceId, versionId)
packageDownloadName = f"{packageNameNew}-{packageVersion}.jar"
downloadPackagePath = Path(f"{downloadPath}/{packageDownloadName}")
if inputPackageVersion is None or inputPackageVersion == 'latest':
downloadSpecificVersion(ressourceId=ressourceId, downloadPath=downloadPackagePath)
downloadSpecificVersion(resourceId=resourceId, downloadPath=downloadPackagePath)
else:
downloadSpecificVersion(ressourceId, downloadPackagePath, versionId)
downloadSpecificVersion(resourceId, downloadPackagePath, versionId)
if not configValues.localPluginFolder:
deleteTempPluginFolder(downloadPath)

View File

@@ -75,24 +75,35 @@ def getUpdateDescription(pluginId):
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):
if pluginVersion < plugin_latest_version:
plugin_is_outdated = True
try:
pluginVersionTuple = versionTuple(getVersionWithoutLetters(pluginVersion))
plugin_latest_versionTuple = versionTuple(getVersionWithoutLetters(plugin_latest_version))
except ValueError:
return False
if pluginVersionTuple < plugin_latest_versionTuple:
return True
else:
plugin_is_outdated = False
return plugin_is_outdated
return False
def eggCrackingJar(localJarFileName, searchMode):
configValues = configurationValues()
if not configValues.localPluginFolder:
tempPluginFolderPath = createTempPluginFolder()
if configValues.sftp_useSftp:
tempPluginFolderPath = createTempPluginFolder()
sftp = createSFTPConnection()
pathToPluginJar = Path(f"{tempPluginFolderPath}/{localJarFileName}")
sftp_downloadFile(sftp, pathToPluginJar, localJarFileName)
else:
tempPluginFolderPath = createTempPluginFolder()
ftp = createFTPConnection()
pathToPluginJar = Path(f"{tempPluginFolderPath}/{localJarFileName}")
ftp_downloadFile(ftp, pathToPluginJar, localJarFileName)
@@ -122,6 +133,9 @@ def eggCrackingJar(localJarFileName, searchMode):
except FileNotFoundError:
pluginVersion = ''
pluginName = ''
except KeyError:
pluginVersion = ''
pluginName = ''
if not configValues.localPluginFolder:
deleteTempPluginFolder(tempPluginFolderPath)
if searchMode == 'version':
@@ -155,11 +169,7 @@ def checkInstalledPackage(inputSelectedObject="all", inputOptionalParam=None):
try:
for plugin in track(pluginList, description="Checking for updates" ,transient=True, complete_style="bright_yellow"):
if not configValues.localPluginFolder:
if configValues.sftp_seperateDownloadPath is True:
pluginFile = f"{configValues.sftp_pathToSeperateDownloadPath}/{plugin}"
else:
pluginFile = f"{configValues.sftp_folderPath}/{plugin}"
pluginFile = f"{configValues.sftp_folderPath}/{plugin}"
if configValues.sftp_useSftp:
pluginAttributes = sftp_validateFileAttributes(connection, pluginFile)
if pluginAttributes == False:
@@ -268,7 +278,7 @@ def updateInstalledPackage(inputSelectedObject='all'):
print()
updateConfirmation = input("Update these plugins [y/n] ? ")
if updateConfirmation != "y":
if str.lower(updateConfirmation) != "y":
print(oColors.brightRed + "Aborting the update process."+ oColors.standardWhite)
return False
@@ -290,11 +300,7 @@ def updateInstalledPackage(inputSelectedObject='all'):
for pluginArray in track(INSTALLEDPLUGINLIST, description="Updating" ,transient=True, complete_style="bright_magenta", ):
plugin = INSTALLEDPLUGINLIST[i][0]
if not configValues.localPluginFolder:
if configValues.sftp_seperateDownloadPath is True:
pluginFile = f"{configValues.sftp_pathToSeperateDownloadPath}/{plugin}"
else:
pluginFile = f"{configValues.sftp_folderPath}/{plugin}"
pluginFile = f"{configValues.sftp_folderPath}/{plugin}"
if configValues.sftp_useSftp:
pluginAttributes = sftp_validateFileAttributes(connection, pluginFile)
if pluginAttributes == False:
@@ -339,17 +345,17 @@ def updateInstalledPackage(inputSelectedObject='all'):
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:
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)
getSpecificPackage(pluginId, pluginPath)
if configValues.sftp_seperateDownloadPath is False:
sftp.remove(pluginPath)
except HTTPError as err:
@@ -357,17 +363,11 @@ def updateInstalledPackage(inputSelectedObject='all'):
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)
getSpecificPackage(pluginId, pluginPath)
if configValues.sftp_seperateDownloadPath is False:
ftp.delete(pluginPath)
except HTTPError as err:
@@ -380,13 +380,13 @@ def updateInstalledPackage(inputSelectedObject='all'):
if configValues.seperateDownloadPath is True:
pluginPath = configValues.pathToSeperateDownloadPath
else:
pluginPath = pluginFolderPath
pluginPath = Path(f"{pluginPath}/{plugin}")
pluginPath = configValues.pathToPluginFolder
indexNumberUpdated += 1
pluginsUpdated += 1
try:
getSpecificPackage(pluginId, pluginFolderPath)
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)
@@ -439,10 +439,10 @@ def getInstalledPlugin(localFileName, localFileVersion, localPluginFullName):
localFileVersion = localFileVersionNew
for ressource in packageName:
for resource in packageName:
if plugin_match_found == True:
continue
pID = ressource["id"]
pID = resource["id"]
url2 = f"https://api.spiget.org/v2/resources/{pID}/versions?size=100&sort=-name"
try:
packageVersions = doAPIRequest(url2)
@@ -461,10 +461,7 @@ def getInstalledPlugin(localFileName, localFileVersion, localPluginFullName):
else:
if plugin_match_found != True:
pID = None
updateId = None
plugin_latest_version = None
plugin_is_outdated = None
pID = updateId = plugin_latest_version = plugin_is_outdated = None
addToPluginList(localPluginFullName, pID, updateId, plugin_latest_version , plugin_is_outdated)
return pluginID