mirror of
https://github.com/Neocky/pluGET.git
synced 2024-04-29 16:12:30 +00:00
Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9b628498f1 | ||
![]() |
d40ee52da1 | ||
![]() |
e66985054c | ||
![]() |
e1efcc4fc7 | ||
![]() |
1147d4f29c | ||
![]() |
ebb04085d3 | ||
![]() |
e161d2c2f9 | ||
![]() |
01465eb769 | ||
![]() |
d478432396 | ||
![]() |
d7fc68195b | ||
![]() |
e87729f700 | ||
![]() |
01b9a52b40 | ||
![]() |
76e1d7f5fd | ||
![]() |
430dbcd8d2 | ||
![]() |
5e296e858f | ||
![]() |
20261d110e | ||
![]() |
932ae66827 | ||
![]() |
1e7de3ac5a | ||
![]() |
662f303935 | ||
![]() |
053a67e2d8 | ||
![]() |
e37840e665 | ||
![]() |
ac9b89de4f | ||
![]() |
f704b29ff9 | ||
![]() |
12f28107de | ||
![]() |
b7e9673c80 | ||
![]() |
0e4abad762 | ||
![]() |
972daf5687 | ||
![]() |
540a355d3d |
116
README.md
116
README.md
@@ -1,4 +1,5 @@
|
||||
|
||||
|
||||
<p align="center">
|
||||
<img src="https://i.ibb.co/JyCxnQn/logoreal.png" alt="pluGET" border="0"></a>
|
||||
</p>
|
||||
@@ -8,15 +9,20 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/Neocky/pluGET/blob/main/LICENSE"> <img src="https://img.shields.io/badge/license-Apache--2.0-blue" alt="Apache-2.0" border="0"></a>
|
||||
<a href="https://github.com/Neocky/pluGET/stargazers"> <img src="https://img.shields.io/github/stars/Neocky/pluGET?color=yellow" alt="stars" border="0"></a>
|
||||
<a href="https://github.com/Neocky/pluGET/blob/main/LICENSE"> <img src="https://img.shields.io/github/license/Neocky/pluGET" alt="Apache-2.0" border="0"></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://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 powerfull package manager which handles [Plugins](https://www.spigotmc.org/resources/) for minecraft servers.
|
||||
# pluGET
|
||||
#### A powerfull package manager which handles [Plugins](https://www.spigotmc.org/resources/) and Server Software for minecraft servers.
|
||||
|
||||
<img src="https://i.ibb.co/82dnyrK/image.png" alt="meme" border="0" height="350" width="350"></a>
|
||||
|
||||
|
||||
|
||||
## Issues? Found a bug?
|
||||
@@ -28,6 +34,7 @@ This is a package manager for minecraft [Spigot](https://www.spigotmc.org/) serv
|
||||
This is a standalone program written in python.
|
||||
The program works with a locally installed server or with a remote host through SFTP, when configured in the config.
|
||||
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 specifif server software (e.g. [PaperMC](https://papermc.io/)).
|
||||
|
||||
Plugin management was the hard part of mangaging 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 shocking.
|
||||
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.
|
||||
@@ -42,10 +49,16 @@ If you still have questions [here](https://github.com/Neocky/pluGET#need-help) i
|
||||
So what can it do exactly?
|
||||
pluGET can:
|
||||
- work locally or through sftp
|
||||
- download the latest version of a plugin
|
||||
- update every installed/one specific plugin
|
||||
- check for an update of every installed/one specific plugin
|
||||
- remove a plugin from the plugin folder
|
||||
- manage plugins:
|
||||
- download the latest version of a plugin
|
||||
- update every installed/one specific plugin
|
||||
- check for an update of every installed/one specific plugin
|
||||
- remove a plugin from the plugin folder
|
||||
- manager server software:
|
||||
- download a specific server software version
|
||||
- check instlalled server software for update
|
||||
- update installed server software to a specific version
|
||||
- supported server software: [PaperMc](https://papermc.io/)
|
||||
|
||||
There are more features in the work. Check [Projects](https://github.com/Neocky/pluGET/projects) for a complete list.
|
||||
|
||||
@@ -82,10 +95,27 @@ Edit the config to your needs and relaunch pluGET.
|
||||
|
||||
|
||||
## Usage
|
||||
> As always, if you update plugins, shut down your server!
|
||||
|
||||
Execute the `launcher.bat` in the `\pluGET` folder. This will launch pluGET correctly.
|
||||
Another way is to launch the `src\__main__.py` file.
|
||||
The following are examples of input for the general usage:
|
||||
(Hint: 'all' can always be exchanged through the plugin name or the plugin id and reverse)
|
||||
(Hint: [thingsInBrackets] are optional & 'all' can always be exchanged through the plugin name or the plugin id and reverse)
|
||||
|
||||
### General
|
||||
#### Command help:
|
||||
`help command [all/command]`
|
||||
```
|
||||
help command
|
||||
```
|
||||
<details>
|
||||
<summary>Output</summary>
|
||||
|
||||

|
||||
|
||||
</details>
|
||||
|
||||
### Manage Plugins
|
||||
#### Download the latest update of a specific package:
|
||||
`get [pluginID/pluginName]`
|
||||
```
|
||||
@@ -104,6 +134,15 @@ or:
|
||||
```
|
||||
check 'pluginName'
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Output</summary>
|
||||
|
||||

|
||||
|
||||
</details>
|
||||
|
||||
|
||||
#### Update all plugins/one specific plugin:
|
||||
`update [all/pluginName]`
|
||||
```
|
||||
@@ -137,37 +176,34 @@ exit .
|
||||
```
|
||||
help .
|
||||
```
|
||||
### Manage Server Software
|
||||
#### Check installed server software for updates:
|
||||
`check serverjar`
|
||||
```
|
||||
check serverjar
|
||||
```
|
||||
### Update installed server software to latest/specific version:
|
||||
`update serverjar [Version]`
|
||||
```
|
||||
update serverjar 'PaperMCVersion'
|
||||
```
|
||||
### Download specific paper version:
|
||||
`get-paper [paperBuild] [minecraftVersion]`
|
||||
```
|
||||
get-paper 550 1.16.5
|
||||
```
|
||||
or:
|
||||
```
|
||||
get-paper 321
|
||||
```
|
||||
|
||||
## Known problems
|
||||
### Can't get installed version
|
||||
For example:
|
||||
```
|
||||
pluGET >> check all
|
||||
Checking: all
|
||||
Index | Name | Installed V. | Latest V. | Update available
|
||||
[1] Vault N/A 1.7.3 False
|
||||
```
|
||||
This is a known issue because the filename in the `\plugin` folder doesn't include a version.
|
||||
This is the plugin file in the `\plugin` folder right now: `Vault.jar`
|
||||
How it should be: `Vault-1.7.3.jar`
|
||||
Many plugins which get download from Spigot won't have a file version in the name.
|
||||
#### How to solve:
|
||||
Delete the `Vault.jar` file and download the newest version with the `get` command:
|
||||
```
|
||||
pluGET >> get vault
|
||||
Index | Name | Description | Downloads
|
||||
[1] Vault Vault is a Permissions, Chat, & Economy API to give plugins easy hooks into these systems. 989046
|
||||
Select your wanted Ressource (Index)(0 to exit): 1
|
||||
Downloadsize: 267.31 KB
|
||||
File downloaded here: C:\Users\USER\Desktop\plugins\Vault-1.7.3.jar
|
||||
```
|
||||
Now you got the plugin with the correct name inside your `\plugin` folder: `Vault-1.7.3.jar`
|
||||
|
||||
And pluGET will tell you the installed version and check if an update is available when checking again:
|
||||
```
|
||||
pluGET >> check all
|
||||
Checking: all
|
||||
Index | Name | Installed V. | Latest V. | Update available
|
||||
[1] Vault 1.7.3 1.7.3 False
|
||||
```
|
||||
|
||||
### Can't get latest version/Update available
|
||||
For example:
|
||||

|
||||
As you can see the installed version was found but not the latest version for this plugin.
|
||||
This is because this is a plugin which is not available on [Spigot](https://www.spigotmc.org/resources/).
|
||||
pluGET supports currently only plugins from [Spigot](https://www.spigotmc.org/resources/).
|
||||
In this example this is a bukkit plugin.
|
||||
|
||||
|
@@ -7,4 +7,8 @@ pynacl >= 1.4.0
|
||||
cffi >= 1.14.5
|
||||
six >= 1.15.0
|
||||
pycparser >= 2.20
|
||||
pysftp >= 0.2.9
|
||||
pysftp >= 0.2.9
|
||||
rich >= 9.13.0
|
||||
commonmark >= 0.9.1
|
||||
Pygments >= 2.8.1
|
||||
typing_extensions >= 3.7.4.3
|
@@ -1,10 +1,7 @@
|
||||
from utils.consoleoutput import consoleTitle, clearConsole, printMainMenu, oColors
|
||||
from utils.utilities import getHelp, check_requirements
|
||||
from utils.consoleoutput import consoleTitle, clearConsole, printMainMenu
|
||||
from utils.utilities import check_requirements
|
||||
from handlers.handle_input import createInputLists, getInput
|
||||
from handlers.handle_config import checkConfig
|
||||
from plugin.plugin_downloader import searchPackage, getSpecificPackage
|
||||
from plugin.plugin_updatechecker import updateInstalledPackage, checkInstalledPackage
|
||||
from plugin.plugin_remover import removePlugin
|
||||
|
||||
|
||||
def mainFunction():
|
||||
|
@@ -1,13 +1,13 @@
|
||||
import os
|
||||
import sys
|
||||
import configparser
|
||||
from pathlib import Path
|
||||
|
||||
from utils.consoleoutput import oColors
|
||||
|
||||
|
||||
def checkConfig():
|
||||
currentFolder = os.getcwd()
|
||||
os.chdir('..')
|
||||
configAvailable = os.path.isfile("config.ini")
|
||||
|
||||
if not configAvailable:
|
||||
@@ -21,9 +21,9 @@ def checkConfig():
|
||||
config.sections()
|
||||
config.read("config.ini")
|
||||
localPluginFolder = config['General']['LocalPluginFolder']
|
||||
pathToPluginFolder = config['General']['PathToPluginFolder']
|
||||
pathToPluginFolder = Path(config['General']['PathToPluginFolder'])
|
||||
seperateDownloadPath = config['General']['SeperateDownloadPath']
|
||||
pathToSeperateDownloadPath = config['General']['PathToSeperateDownloadPath']
|
||||
pathToSeperateDownloadPath = Path(config['General']['PathToSeperateDownloadPath'])
|
||||
|
||||
sftp_server = config['SFTP - Remote Server']['Server']
|
||||
sftp_user = config['SFTP - Remote Server']['Username']
|
||||
@@ -58,10 +58,10 @@ def createConfig():
|
||||
config['General'] = {}
|
||||
config['General'][';'] = 'If a local plugin folder exists (True/False): (If False SFTP will be used)'
|
||||
config['General']['LocalPluginFolder'] = 'True'
|
||||
config['General']['PathToPluginFolder'] = 'C:\\Users\\USER\\Desktop\\plugins'
|
||||
config['General']['PathToPluginFolder'] = 'C:/Users/USER/Desktop/plugins'
|
||||
config['General'][';_'] = 'If you want a different folder to store the updated plugins change to (True/False) and the path below'
|
||||
config['General']['SeperateDownloadPath'] = 'False'
|
||||
config['General']['PathToSeperateDownloadPath'] = 'C:\\Users\\USER\\Desktop\\plugins'
|
||||
config['General']['PathToSeperateDownloadPath'] = 'C:/Users/USER/Desktop/plugins'
|
||||
|
||||
config['SFTP - Remote Server'] = {}
|
||||
config['SFTP - Remote Server']['Server'] = '0.0.0.0'
|
||||
@@ -75,5 +75,5 @@ def createConfig():
|
||||
config['SFTP - Remote Server']['PathToSeperateDownloadPath'] = '.\\plugins'
|
||||
|
||||
|
||||
with open('./config.ini', 'w') as configfile:
|
||||
with open('config.ini', 'w') as configfile:
|
||||
config.write(configfile)
|
||||
|
@@ -1,11 +1,14 @@
|
||||
import sys
|
||||
|
||||
from utils.consoleoutput import oColors
|
||||
from utils.utilities import getHelp
|
||||
from utils.utilities import getHelp, getCommandHelp
|
||||
from handlers.handle_config import checkConfig
|
||||
from plugin.plugin_downloader import searchPackage, getSpecificPackage
|
||||
from plugin.plugin_updatechecker import updateInstalledPackage, checkInstalledPackage
|
||||
from plugin.plugin_remover import removePlugin
|
||||
from serverjar.serverjar_checker import checkInstalledServerjar, updateServerjar
|
||||
from serverjar.serverjar_paper import papermc_downloader
|
||||
|
||||
|
||||
def createInputLists():
|
||||
global COMMANDLIST
|
||||
@@ -16,7 +19,8 @@ def createInputLists():
|
||||
'search',
|
||||
'exit',
|
||||
'help',
|
||||
'remove'
|
||||
'remove',
|
||||
'get-paper'
|
||||
]
|
||||
global INPUTSELECTEDOBJECT
|
||||
INPUTSELECTEDOBJECT = [
|
||||
@@ -47,10 +51,16 @@ def handleInput(inputCommand, inputSelectedObject, inputParams):
|
||||
searchPackage(inputSelectedObject)
|
||||
break
|
||||
if inputCommand == 'update':
|
||||
updateInstalledPackage(inputSelectedObject)
|
||||
if inputSelectedObject == 'serverjar':
|
||||
updateServerjar(inputParams)
|
||||
else:
|
||||
updateInstalledPackage(inputSelectedObject)
|
||||
break
|
||||
if inputCommand == 'check':
|
||||
checkInstalledPackage(inputSelectedObject)
|
||||
if inputSelectedObject == 'serverjar':
|
||||
checkInstalledServerjar()
|
||||
else:
|
||||
checkInstalledPackage(inputSelectedObject)
|
||||
break
|
||||
if inputCommand == 'search':
|
||||
searchPackage(inputSelectedObject)
|
||||
@@ -58,13 +68,19 @@ def handleInput(inputCommand, inputSelectedObject, inputParams):
|
||||
if inputCommand == 'exit':
|
||||
sys.exit()
|
||||
if inputCommand == 'help':
|
||||
getHelp()
|
||||
if inputSelectedObject == 'command' or inputSelectedObject == 'commands':
|
||||
getCommandHelp(inputParams)
|
||||
else:
|
||||
getHelp()
|
||||
break
|
||||
if inputCommand == 'remove':
|
||||
removePlugin(inputSelectedObject)
|
||||
break
|
||||
if inputCommand == 'get-paper':
|
||||
papermc_downloader(inputSelectedObject, inputParams)
|
||||
break
|
||||
else:
|
||||
print(oColors.brightRed + "Command not found. Please try again." + oColors.standardWhite)
|
||||
print(oColors.brightRed + "Error: Command not found. Please try again. :(" + oColors.standardWhite)
|
||||
getInput()
|
||||
getInput()
|
||||
|
||||
@@ -75,7 +91,8 @@ def getInput():
|
||||
inputCommand, inputSelectedObject, *inputParams = input("pluGET >> ").split()
|
||||
break
|
||||
except ValueError:
|
||||
print(oColors.brightRed + "Wrong input! Use: > *command* *selectedObject* *optionalParams*" + oColors.standardWhite)
|
||||
print(oColors.brightRed + "Wrong input! Use: > 'command' 'selectedObject' [optionalParams]" + oColors.standardWhite)
|
||||
print(oColors.brightRed + "Use: '" + oColors.standardWhite +"help command" + oColors.brightRed +"' to get all available commands" + oColors.standardWhite)
|
||||
|
||||
inputParams = inputParams[0] if inputParams else None
|
||||
handleInput(inputCommand, inputSelectedObject, inputParams)
|
||||
|
@@ -45,6 +45,17 @@ def sftp_upload_file(sftp, itemPath):
|
||||
sftp.close()
|
||||
|
||||
|
||||
def sftp_upload_server_jar(sftp, itemPath):
|
||||
try:
|
||||
sftp.chdir('.')
|
||||
sftp.put(itemPath)
|
||||
|
||||
except FileNotFoundError:
|
||||
print(oColors.brightRed + "The 'plugins' folder couldn*t be found on the remote host!" + oColors.standardWhite)
|
||||
print(oColors.brightRed + "Aborting installation." + oColors.standardWhite)
|
||||
sftp.close()
|
||||
|
||||
|
||||
def sftp_listAll(sftp):
|
||||
try:
|
||||
sftp.chdir('plugins')
|
||||
@@ -56,4 +67,18 @@ def sftp_listAll(sftp):
|
||||
try:
|
||||
return installedPlugins
|
||||
except UnboundLocalError:
|
||||
print(oColors.brightRed + "No plugins were found." + oColors.standardWhite)
|
||||
print(oColors.brightRed + "No plugins were found." + oColors.standardWhite)
|
||||
|
||||
|
||||
def sftp_listFilesInServerRoot(sftp):
|
||||
try:
|
||||
#sftp.chdir('plugins')
|
||||
filesInServerRoot = sftp.listdir()
|
||||
|
||||
except FileNotFoundError:
|
||||
print(oColors.brightRed + "The 'root' folder couldn*t be found on the remote host!" + oColors.standardWhite)
|
||||
|
||||
try:
|
||||
return filesInServerRoot
|
||||
except UnboundLocalError:
|
||||
print(oColors.brightRed + "No Serverjar was found." + oColors.standardWhite)
|
@@ -1,6 +1,7 @@
|
||||
import re
|
||||
import urllib.request
|
||||
from urllib.error import HTTPError
|
||||
from pathlib import Path
|
||||
|
||||
from utils.consoleoutput import oColors
|
||||
from utils.web_request import doAPIRequest
|
||||
@@ -60,7 +61,7 @@ def searchPackage(ressourceName):
|
||||
url = f"https://api.spiget.org/v2/search/resources/{ressourceName}?field=name&sort=-downloads"
|
||||
packageName = doAPIRequest(url)
|
||||
i = 1
|
||||
print(f"Searching: {ressourceName}")
|
||||
print(oColors.brightBlack + f"Searching: {ressourceName}" + oColors.standardWhite)
|
||||
print("Index | Name | Description | Downloads")
|
||||
for ressource in packageName:
|
||||
pName = ressource["name"]
|
||||
@@ -78,9 +79,15 @@ def searchPackage(ressourceName):
|
||||
ressourceSelected = ressourceSelected - 1
|
||||
ressourceId = packageName[ressourceSelected]["id"]
|
||||
if not checkConfig().localPluginFolder:
|
||||
getSpecificPackage(ressourceId, checkConfig().sftp_folderPath)
|
||||
try:
|
||||
getSpecificPackage(ressourceId, checkConfig().sftp_folderPath)
|
||||
except HTTPError as err:
|
||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||
else:
|
||||
getSpecificPackage(ressourceId, checkConfig().pathToPluginFolder)
|
||||
try:
|
||||
getSpecificPackage(ressourceId, checkConfig().pathToPluginFolder)
|
||||
except HTTPError as err:
|
||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||
|
||||
|
||||
def downloadSpecificVersion(ressourceId, downloadPath, versionID='latest'):
|
||||
@@ -113,30 +120,17 @@ def getSpecificPackage(ressourceId, downloadPath, inputPackageVersion='latest'):
|
||||
versionId = getVersionID(ressourceId, inputPackageVersion)
|
||||
packageVersion = getVersionName(ressourceId, versionId)
|
||||
packageDownloadName = f"{packageNameNew}-{packageVersion}.jar"
|
||||
downloadPackagePath = f"{downloadPath}\\{packageDownloadName}"
|
||||
downloadPackagePath = Path(f"{downloadPath}/{packageDownloadName}")
|
||||
if checkConfig().localPluginFolder:
|
||||
if inputPackageVersion is None or inputPackageVersion == 'latest':
|
||||
try:
|
||||
downloadSpecificVersion(ressourceId=ressourceId, downloadPath=downloadPackagePath)
|
||||
except HTTPError as err:
|
||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||
downloadSpecificVersion(ressourceId=ressourceId, downloadPath=downloadPackagePath)
|
||||
else:
|
||||
try:
|
||||
downloadSpecificVersion(ressourceId, downloadPackagePath, versionId)
|
||||
except HTTPError as err:
|
||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||
downloadSpecificVersion(ressourceId, downloadPackagePath, versionId)
|
||||
|
||||
if not checkConfig().localPluginFolder:
|
||||
if inputPackageVersion is None or inputPackageVersion == 'latest':
|
||||
try:
|
||||
downloadSpecificVersion(ressourceId=ressourceId, downloadPath=downloadPackagePath)
|
||||
deleteTempPluginFolder(downloadPath)
|
||||
except HTTPError as err:
|
||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||
downloadSpecificVersion(ressourceId=ressourceId, downloadPath=downloadPackagePath)
|
||||
deleteTempPluginFolder(downloadPath)
|
||||
else:
|
||||
try:
|
||||
downloadSpecificVersion(ressourceId, downloadPackagePath, versionId)
|
||||
deleteTempPluginFolder(downloadPath)
|
||||
except HTTPError as err:
|
||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||
|
||||
downloadSpecificVersion(ressourceId, downloadPackagePath, versionId)
|
||||
deleteTempPluginFolder(downloadPath)
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from utils.consoleoutput import oColors
|
||||
from handlers.handle_config import checkConfig
|
||||
@@ -29,7 +30,7 @@ def removePlugin(pluginToRemove):
|
||||
print(f"Removing: {fileName}")
|
||||
if not checkConfig().localPluginFolder:
|
||||
pluginPath = checkConfig().sftp_folderPath
|
||||
pluginPath = f"{pluginPath}\\{plugin}"
|
||||
pluginPath = f"{pluginPath}/{plugin}"
|
||||
sftp = createSFTPConnection()
|
||||
sftp.remove(pluginPath)
|
||||
print(f"Removed: {fileName}")
|
||||
@@ -37,7 +38,7 @@ def removePlugin(pluginToRemove):
|
||||
break
|
||||
else:
|
||||
pluginPath = checkConfig().pathToPluginFolder
|
||||
pluginPath = f"{pluginPath}\\{plugin}"
|
||||
pluginPath = Path(f"{pluginPath}/{plugin}")
|
||||
os.remove(pluginPath)
|
||||
print(f"Removed: {fileName}")
|
||||
i += 1
|
||||
|
@@ -1,5 +1,10 @@
|
||||
import os
|
||||
import re
|
||||
import io
|
||||
from zipfile import ZipFile
|
||||
from urllib.error import HTTPError
|
||||
from pathlib import Path
|
||||
from rich.progress import track
|
||||
|
||||
from utils.consoleoutput import oColors
|
||||
from utils.web_request import doAPIRequest
|
||||
@@ -36,6 +41,10 @@ def getFileVersion(pluginName):
|
||||
pluginVersion = re.search(r'([\d.]+[.jar]+)', pluginNameFull)
|
||||
pluginVersionFull = pluginVersion.group()
|
||||
pluginVersionString = pluginVersionFull.replace('.jar', '')
|
||||
if pluginVersionString.endswith('.'):
|
||||
pluginVersionString = ''
|
||||
if pluginVersionString == '':
|
||||
pluginVersionString = eggCrackingJar(pluginNameFull)
|
||||
return pluginVersionString
|
||||
|
||||
|
||||
@@ -54,6 +63,28 @@ def compareVersions(plugin_latest_version, pluginVersion):
|
||||
return plugin_is_outdated
|
||||
|
||||
|
||||
def eggCrackingJar(localJarFileName):
|
||||
if not checkConfig().localPluginFolder:
|
||||
pluginPath = checkConfig().sftp_folderPath
|
||||
else:
|
||||
pluginPath = checkConfig().pathToPluginFolder
|
||||
pathToPluginJar = Path(f"{pluginPath}/{localJarFileName}")
|
||||
pluginVersion = ''
|
||||
with ZipFile(pathToPluginJar, 'r') as pluginJar:
|
||||
try:
|
||||
with io.TextIOWrapper(pluginJar.open('plugin.yml', 'r'), encoding="utf-8") as pluginYml:
|
||||
pluginYmlContentLine = pluginYml.readlines()
|
||||
for line in pluginYmlContentLine:
|
||||
if "version: " in line:
|
||||
pluginVersion = line.replace('version: ', '')
|
||||
pluginVersion = pluginVersion.replace('\n', '')
|
||||
break
|
||||
|
||||
except FileNotFoundError:
|
||||
pluginVersion = ''
|
||||
return pluginVersion
|
||||
|
||||
|
||||
def checkInstalledPackage(inputSelectedObject="all"):
|
||||
createPluginList()
|
||||
if not checkConfig().localPluginFolder:
|
||||
@@ -63,26 +94,27 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
||||
pluginList = os.listdir(checkConfig().pathToPluginFolder)
|
||||
i = 0
|
||||
oldPackages = 0
|
||||
print(f"Checking: {inputSelectedObject}")
|
||||
print("Index | Name | Installed V. | Latest V. | Update available")
|
||||
print(oColors.brightBlack + f"Checking: {inputSelectedObject}" + oColors.standardWhite)
|
||||
print("┌─────┬────────────────────────────────┬──────────────┬───────────┬───────────────────┐")
|
||||
print("│ No. │ Name │ Installed V. │ Latest V. │ Update available │")
|
||||
print("└─────┴────────────────────────────────┴──────────────┴───────────┴───────────────────┘")
|
||||
try:
|
||||
for plugin in pluginList:
|
||||
for plugin in track(pluginList, description="Checking for updates" ,transient=True, complete_style="cyan"):
|
||||
try:
|
||||
fileName = getFileName(plugin)
|
||||
fileVersion = getFileVersion(plugin)
|
||||
pluginId = getInstalledPlugin(fileName, fileVersion)
|
||||
except TypeError:
|
||||
i += 1
|
||||
continue
|
||||
pluginIdStr = str(pluginId)
|
||||
|
||||
if fileVersion == '':
|
||||
fileVersion = 'N/A'
|
||||
|
||||
try:
|
||||
pluginLatestVersion = INSTALLEDPLUGINLIST[i][2]
|
||||
except IndexError:
|
||||
pluginLatestVersion = 'N/A'
|
||||
|
||||
|
||||
if pluginLatestVersion == None:
|
||||
pluginLatestVersion = 'N/A'
|
||||
|
||||
@@ -99,22 +131,28 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
||||
|
||||
if inputSelectedObject != "*" and inputSelectedObject != "all":
|
||||
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
||||
print(f" [{1}]".ljust(8), end='')
|
||||
if pluginLatestVersion == 'N/A':
|
||||
print(oColors.brightBlack + f" [{1}]".ljust(8), end='')
|
||||
else:
|
||||
print(f" [{1}]".ljust(8), end='')
|
||||
print(f"{fileName}".ljust(33), end='')
|
||||
print(f"{fileVersion}".ljust(15), end='')
|
||||
print(f"{pluginLatestVersion}".ljust(12), end='')
|
||||
print(f" {pluginIsOutdated}".ljust(5))
|
||||
print(f" {pluginIsOutdated}".ljust(5) + oColors.standardWhite)
|
||||
break
|
||||
else:
|
||||
print(f" [{i+1}]".ljust(8), end='')
|
||||
if pluginLatestVersion == 'N/A':
|
||||
print(oColors.brightBlack + f" [{i+1}]".ljust(8), end='')
|
||||
else:
|
||||
print(f" [{i+1}]".ljust(8), end='')
|
||||
print(f"{fileName}".ljust(33), end='')
|
||||
print(f"{fileVersion}".ljust(15), end='')
|
||||
print(f"{pluginLatestVersion}".ljust(12), end='')
|
||||
print(f" {pluginIsOutdated}".ljust(5))
|
||||
print(f" {pluginIsOutdated}".ljust(5) + oColors.standardWhite)
|
||||
|
||||
i = i + 1
|
||||
i += 1
|
||||
except TypeError:
|
||||
print(oColors.brightRed + "Aborted checking for plugins." + oColors.standardWhite)
|
||||
print(oColors.brightRed + "Error occured: Aborted checking for updates." + oColors.standardWhite)
|
||||
print(oColors.brightYellow + f"Old packages: [{oldPackages}/{i}]" + oColors.standardWhite)
|
||||
|
||||
|
||||
@@ -127,59 +165,32 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
||||
pluginList = os.listdir(checkConfig().pathToPluginFolder)
|
||||
i = 0
|
||||
pluginsUpdated = 0
|
||||
print(f"Updating: {inputSelectedObject}")
|
||||
print("Index | Name | Old V. | New V.")
|
||||
indexNumberUpdated = 0
|
||||
print(oColors.brightBlack + f"Updating: {inputSelectedObject}" + oColors.standardWhite)
|
||||
print("┌─────┬────────────────────────────────┬────────────┬──────────┐")
|
||||
print("│ No. │ Name │ Old V. │ New V. │")
|
||||
print("└─────┴────────────────────────────────┴────────────┴──────────┘")
|
||||
try:
|
||||
for plugin in pluginList:
|
||||
for plugin in track(pluginList, description="Updating" ,transient=True, complete_style="red"):
|
||||
try:
|
||||
fileName = getFileName(plugin)
|
||||
fileVersion = getFileVersion(plugin)
|
||||
pluginId = getInstalledPlugin(fileName, fileVersion)
|
||||
latestVersion = getLatestPluginVersion(pluginId)
|
||||
except TypeError:
|
||||
i += 1
|
||||
continue
|
||||
except ValueError:
|
||||
i += 1
|
||||
continue
|
||||
pluginIdStr = str(pluginId)
|
||||
|
||||
if pluginId == None:
|
||||
if pluginId == None or pluginId == '':
|
||||
print(oColors.brightRed + "Couldn't find plugin id. Sorry :(" + oColors.standardWhite)
|
||||
continue
|
||||
|
||||
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
||||
if INSTALLEDPLUGINLIST[i][3] == True:
|
||||
print(f" [{pluginsUpdated+1}]".ljust(8), end='')
|
||||
print(f"{fileName}".ljust(30), end='')
|
||||
print(f"{fileVersion}".ljust(8), end='')
|
||||
print(" ", end='')
|
||||
print(f"{latestVersion}".ljust(8))
|
||||
|
||||
if not checkConfig().localPluginFolder:
|
||||
pluginPath = checkConfig().sftp_folderPath
|
||||
pluginPath = f"{pluginPath}\\{plugin}"
|
||||
sftp = createSFTPConnection()
|
||||
sftp.remove(pluginPath)
|
||||
getSpecificPackage(pluginId, checkConfig().sftp_folderPath)
|
||||
pluginsUpdated += 1
|
||||
else:
|
||||
if checkConfig().seperateDownloadPath is True:
|
||||
pluginPath = checkConfig().pathToSeperateDownloadPath
|
||||
else:
|
||||
pluginPath = checkConfig().pathToPluginFolder
|
||||
pluginPath = f"{pluginPath}\\{plugin}"
|
||||
os.remove(pluginPath)
|
||||
getSpecificPackage(pluginId, checkConfig().pathToPluginFolder)
|
||||
pluginsUpdated += 1
|
||||
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" [{pluginsUpdated+1}]".ljust(8), end='')
|
||||
print(f"{fileName}".ljust(30), end='')
|
||||
print(f" [{indexNumberUpdated+1}]".ljust(8), end='')
|
||||
print(f"{fileName}".ljust(33), end='')
|
||||
print(f"{fileVersion}".ljust(8), end='')
|
||||
print(" ", end='')
|
||||
print(f"{latestVersion}".ljust(8))
|
||||
@@ -189,40 +200,103 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
||||
pluginPath = checkConfig().sftp_pathToSeperateDownloadPath
|
||||
else:
|
||||
pluginPath = checkConfig().sftp_folderPath
|
||||
pluginPath = checkConfig().sftp_folderPath
|
||||
pluginPath = f"{pluginPath}\\{plugin}"
|
||||
pluginPath = Path(f"{pluginPath}/{plugin}")
|
||||
sftp = createSFTPConnection()
|
||||
sftp.remove(pluginPath)
|
||||
getSpecificPackage(pluginId, checkConfig().sftp_folderPath)
|
||||
indexNumberUpdated += 1
|
||||
pluginsUpdated += 1
|
||||
try:
|
||||
getSpecificPackage(pluginId, checkConfig().sftp_folderPath)
|
||||
if checkConfig().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 checkConfig().seperateDownloadPath is True:
|
||||
pluginPath = checkConfig().pathToSeperateDownloadPath
|
||||
else:
|
||||
pluginPath = checkConfig().pathToPluginFolder
|
||||
pluginPath = Path(f"{pluginPath}/{plugin}")
|
||||
indexNumberUpdated += 1
|
||||
pluginsUpdated += 1
|
||||
try:
|
||||
getSpecificPackage(pluginId, checkConfig().pathToPluginFolder)
|
||||
if checkConfig().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}]".ljust(8), end='')
|
||||
print(f"{fileName}".ljust(33), end='')
|
||||
print(f"{fileVersion}".ljust(8), end='')
|
||||
print(" ", end='')
|
||||
print(f"{latestVersion}".ljust(8))
|
||||
|
||||
if not checkConfig().localPluginFolder:
|
||||
if checkConfig().sftp_seperateDownloadPath is True:
|
||||
pluginPath = checkConfig().sftp_pathToSeperateDownloadPath
|
||||
else:
|
||||
pluginPath = checkConfig().sftp_folderPath
|
||||
pluginPath = f"{pluginPath}/{plugin}"
|
||||
sftp = createSFTPConnection()
|
||||
indexNumberUpdated += 1
|
||||
pluginsUpdated += 1
|
||||
try:
|
||||
getSpecificPackage(pluginId, checkConfig().sftp_folderPath)
|
||||
if checkConfig().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 + f"Error: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
||||
|
||||
else:
|
||||
if checkConfig().seperateDownloadPath is True:
|
||||
pluginPath = checkConfig().pathToSeperateDownloadPath
|
||||
else:
|
||||
pluginPath = checkConfig().pathToPluginFolder
|
||||
pluginPath = f"{pluginPath}\\{plugin}"
|
||||
os.remove(pluginPath)
|
||||
getSpecificPackage(pluginId, checkConfig().pathToPluginFolder)
|
||||
pluginPath = Path(f"{pluginPath}/{plugin}")
|
||||
indexNumberUpdated += 1
|
||||
pluginsUpdated += 1
|
||||
try:
|
||||
getSpecificPackage(pluginId, checkConfig().pathToPluginFolder)
|
||||
if checkConfig().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)
|
||||
|
||||
i = i + 1
|
||||
except TypeError:
|
||||
print(oColors.brightRed + "Aborted updating for plugins." + oColors.standardWhite)
|
||||
print(f"[{pluginsUpdated}/{i}] Plugins updated")
|
||||
print(oColors.brightRed + "Error occured: Aborted updating for plugins." + oColors.standardWhite)
|
||||
print(oColors.brightYellow + f"[{pluginsUpdated}/{i}] Plugins updated" + oColors.standardWhite)
|
||||
if inputSelectedObject =='all' and pluginsUpdated == 0:
|
||||
print(oColors.brightGreen + "All plugins are on the latest version!" + oColors.standardWhite)
|
||||
print(oColors.brightGreen + "All found plugins are on the latest version!" + oColors.standardWhite)
|
||||
|
||||
|
||||
def getInstalledPlugin(localFileName, localFileVersion):
|
||||
url = "https://api.spiget.org/v2/search/resources/" + localFileName + "?field=name&sort=-downloads"
|
||||
packageName = doAPIRequest(url)
|
||||
i = 1
|
||||
plugin_match_found = False
|
||||
pluginID = None
|
||||
for ressource in packageName:
|
||||
if plugin_match_found == True:
|
||||
break
|
||||
|
||||
pID = ressource["id"]
|
||||
url2 = f"https://api.spiget.org/v2/resources/{pID}/versions?size=100&sort=-name"
|
||||
packageVersions = doAPIRequest(url2)
|
||||
@@ -235,9 +309,8 @@ def getInstalledPlugin(localFileName, localFileVersion):
|
||||
plugin_latest_version = getLatestPluginVersion(pID)
|
||||
plugin_is_outdated = compareVersions(plugin_latest_version, updateVersion)
|
||||
addToPluginList(pID, updateId, plugin_latest_version , plugin_is_outdated)
|
||||
break
|
||||
return pluginID
|
||||
|
||||
i = i + 1
|
||||
else:
|
||||
if plugin_match_found != True:
|
||||
pID = None
|
||||
@@ -247,11 +320,3 @@ def getInstalledPlugin(localFileName, localFileVersion):
|
||||
addToPluginList(pID, updateId, plugin_latest_version , plugin_is_outdated)
|
||||
|
||||
return pluginID
|
||||
|
||||
|
||||
# start query
|
||||
# get id
|
||||
# search with id for all version upates
|
||||
# get version that matches installed version
|
||||
# if match then download latest update
|
||||
# else get second query
|
||||
|
0
src/serverjar/__init__.py
Normal file
0
src/serverjar/__init__.py
Normal file
115
src/serverjar/serverjar_checker.py
Normal file
115
src/serverjar/serverjar_checker.py
Normal file
@@ -0,0 +1,115 @@
|
||||
import os
|
||||
import sys
|
||||
from urllib.error import HTTPError
|
||||
from pathlib import Path
|
||||
|
||||
from handlers.handle_sftp import createSFTPConnection, sftp_listFilesInServerRoot
|
||||
from handlers.handle_config import checkConfig
|
||||
from utils.consoleoutput import oColors
|
||||
from serverjar.serverjar_paper import paperCheckForUpdate, papermc_downloader
|
||||
|
||||
|
||||
def checkInstalledServerjar():
|
||||
if not checkConfig().localPluginFolder:
|
||||
sftp = createSFTPConnection()
|
||||
serverRootList = sftp_listFilesInServerRoot(sftp)
|
||||
else:
|
||||
serverRootList = os.path.dirname(checkConfig().pathToPluginFolder)
|
||||
serverRootList = os.listdir(serverRootList)
|
||||
installedServerjarFullName = None
|
||||
try:
|
||||
for files in serverRootList:
|
||||
try:
|
||||
if '.jar' in files:
|
||||
installedServerjarFullName = files
|
||||
break
|
||||
except TypeError:
|
||||
continue
|
||||
except TypeError:
|
||||
print(oColors.brightRed + "Serverjar couldn't be found." + oColors.standardWhite)
|
||||
print(oColors.brightRed + "Aborting the process." + oColors.standardWhite)
|
||||
|
||||
if installedServerjarFullName == None:
|
||||
print(oColors.brightRed + "Serverjar couldn't be found." + oColors.standardWhite)
|
||||
print(oColors.brightRed + "Aborting the process." + oColors.standardWhite)
|
||||
input("Press any key + enter to exit...")
|
||||
sys.exit()
|
||||
|
||||
if 'paper' in installedServerjarFullName:
|
||||
paperCheckForUpdate(installedServerjarFullName)
|
||||
|
||||
else:
|
||||
print(oColors.brightRed + f"{installedServerjarFullName} isn't supported.")
|
||||
print(oColors.brightRed + "Aborting the process." + oColors.standardWhite)
|
||||
|
||||
|
||||
def updateServerjar(serverJarBuild='latest'):
|
||||
try:
|
||||
if serverJarBuild == None:
|
||||
serverJarBuild = 'latest'
|
||||
if not checkConfig().localPluginFolder:
|
||||
sftp = createSFTPConnection()
|
||||
serverRootPath = checkConfig().sftp_folderPath
|
||||
serverRootPath = Path(str(serverRootPath).replace(r'/plugins', ''))
|
||||
serverRootList = sftp_listFilesInServerRoot(sftp)
|
||||
|
||||
else:
|
||||
serverRoot = os.path.dirname(checkConfig().pathToPluginFolder)
|
||||
serverRootList = os.listdir(serverRoot)
|
||||
serverRootPath = checkConfig().pathToPluginFolder
|
||||
helpPath = Path('/plugins')
|
||||
helpPathstr = str(helpPath)
|
||||
serverRootPath = Path(str(serverRootPath).replace(helpPathstr, ''))
|
||||
installedServerjarFullName = None
|
||||
|
||||
except FileNotFoundError:
|
||||
print(oColors.brightRed + "Path couldn't be found!" + oColors.standardWhite)
|
||||
print(oColors.brightRed + "Check your config!" + oColors.standardWhite)
|
||||
print(oColors.brightRed + "Aborting the process." + oColors.standardWhite)
|
||||
input("Press any key + enter to exit...")
|
||||
sys.exit()
|
||||
|
||||
try:
|
||||
for files in serverRootList:
|
||||
try:
|
||||
if '.jar' in files:
|
||||
installedServerjarFullName = files
|
||||
break
|
||||
except TypeError:
|
||||
continue
|
||||
except TypeError:
|
||||
print(oColors.brightRed + "Serverjar couldn't be found." + oColors.standardWhite)
|
||||
print(oColors.brightRed + "Aborting the process." + oColors.standardWhite)
|
||||
|
||||
if installedServerjarFullName == None:
|
||||
print(oColors.brightRed + "Serverjar couldn't be found." + oColors.standardWhite)
|
||||
print(oColors.brightRed + "Aborting the process." + oColors.standardWhite)
|
||||
input("Press any key + enter to exit...")
|
||||
sys.exit()
|
||||
|
||||
serverJarPath = Path(f"{serverRootPath}/{installedServerjarFullName}")
|
||||
|
||||
if 'paper' in installedServerjarFullName:
|
||||
print(f"Updating Paper to build: {serverJarBuild}")
|
||||
if not checkConfig().localPluginFolder:
|
||||
try:
|
||||
papermc_downloader(serverJarBuild, installedServerjarFullName)
|
||||
sftp.remove(serverJarPath)
|
||||
except HTTPError as err:
|
||||
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)
|
||||
except HTTPError as err:
|
||||
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:
|
||||
print(oColors.brightRed + f"{installedServerjarFullName} isn't supported.")
|
||||
print(oColors.brightRed + "Aborting the process." + oColors.standardWhite)
|
||||
|
170
src/serverjar/serverjar_paper.py
Normal file
170
src/serverjar/serverjar_paper.py
Normal file
@@ -0,0 +1,170 @@
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
from utils.consoleoutput import oColors
|
||||
from utils.web_request import doAPIRequest
|
||||
from handlers.handle_sftp import sftp_upload_server_jar, sftp_cdPluginDir, createSFTPConnection
|
||||
from handlers.handle_config import checkConfig
|
||||
from utils.utilities import createTempPluginFolder, deleteTempPluginFolder, calculateFileSizeMb
|
||||
|
||||
|
||||
# = 1.16.5
|
||||
def getInstalledPaperMinecraftVersion(localPaperName):
|
||||
mcVersionFull = re.search(r'(\d*\.*\d)+', localPaperName)
|
||||
try:
|
||||
mcVersion = mcVersionFull.group()
|
||||
except AttributeError:
|
||||
mcVersion = mcVersionFull
|
||||
return mcVersion
|
||||
|
||||
|
||||
# = 550
|
||||
def getInstalledPaperVersion(localPaperName):
|
||||
paperBuildFull = re.search(r'([\d]*.jar)', localPaperName)
|
||||
try:
|
||||
paperBuild = paperBuildFull.group()
|
||||
except AttributeError:
|
||||
paperBuild = paperBuildFull
|
||||
paperBuild = paperBuild.replace('.jar', '')
|
||||
return paperBuild
|
||||
|
||||
|
||||
def findVersionGroup(mcVersion):
|
||||
versionGroups = ['1.16', '1.15']
|
||||
versionGroupFound = False
|
||||
for versionGroup in versionGroups:
|
||||
if versionGroupFound == True:
|
||||
break
|
||||
url = f"https://papermc.io/api/v2/projects/paper/version_group/{versionGroup}/builds"
|
||||
papermcdetails = doAPIRequest(url)
|
||||
papermcVersionForMc = papermcdetails["versions"]
|
||||
for versions in papermcVersionForMc:
|
||||
if versions == mcVersion:
|
||||
versionGroupFound = True
|
||||
paperVersionGroup = versionGroup
|
||||
break
|
||||
if versionGroup == mcVersion:
|
||||
versionGroupFound = True
|
||||
paperVersionGroup = versionGroup
|
||||
break
|
||||
|
||||
return paperVersionGroup
|
||||
|
||||
|
||||
def findBuildVersion(wantedPaperBuild):
|
||||
versionGroups = ['1.16', '1.15']
|
||||
paperBuildFound = False
|
||||
for versionGroup in versionGroups:
|
||||
if paperBuildFound is True:
|
||||
break
|
||||
url = f"https://papermc.io/api/v2/projects/paper/version_group/{versionGroup}/builds"
|
||||
papermcdetails = doAPIRequest(url)
|
||||
paperMcBuilds = papermcdetails["builds"]
|
||||
for build in paperMcBuilds:
|
||||
paperBuild = str(build["build"])
|
||||
if paperBuild == wantedPaperBuild:
|
||||
paperBuildFound = True
|
||||
paperVersionGroup = build["version"]
|
||||
break
|
||||
return paperVersionGroup
|
||||
|
||||
|
||||
def findLatestBuild(paperVersionGroup):
|
||||
url = f"https://papermc.io/api/v2/projects/paper/version_group/{paperVersionGroup}/builds"
|
||||
papermcbuilds = doAPIRequest(url)
|
||||
latestPaperBuild = papermcbuilds["builds"][-1]["build"]
|
||||
return latestPaperBuild
|
||||
|
||||
|
||||
def findLatestBuildForVersion(mcVersion):
|
||||
url = f"https://papermc.io/api/v2/projects/paper/versions/{mcVersion}"
|
||||
papermcbuilds = doAPIRequest(url)
|
||||
latestPaperBuild = papermcbuilds["builds"][-1]
|
||||
return latestPaperBuild
|
||||
|
||||
|
||||
def versionBehind(installedPaperBuild, latestPaperBuild):
|
||||
installedPaperBuildint = int(installedPaperBuild)
|
||||
latestPaperBuildint = int(latestPaperBuild)
|
||||
versionsBehind = latestPaperBuildint - installedPaperBuildint
|
||||
return versionsBehind
|
||||
|
||||
|
||||
def getDownloadFileName(paperMcVersion, paperBuild):
|
||||
url = f"https://papermc.io/api/v2/projects/paper/versions/{paperMcVersion}/builds/{paperBuild}"
|
||||
buildDetails = doAPIRequest(url)
|
||||
downloadName = buildDetails["downloads"]["application"]["name"]
|
||||
return downloadName
|
||||
|
||||
|
||||
def paperCheckForUpdate(installedServerjarFullName):
|
||||
mcVersion = getInstalledPaperMinecraftVersion(installedServerjarFullName)
|
||||
paperInstalledBuild = getInstalledPaperVersion(installedServerjarFullName)
|
||||
versionGroup = findVersionGroup(mcVersion)
|
||||
paperLatestBuild = findLatestBuild(versionGroup)
|
||||
paperVersionBehind = versionBehind(paperInstalledBuild, paperLatestBuild)
|
||||
|
||||
print(f"Paper for {mcVersion}")
|
||||
print("Index | Name | Installed V. | Latest V. | Versions behind ")
|
||||
print(f" [1]".ljust(8), end='')
|
||||
print(f"paper".ljust(21), end='')
|
||||
print(f"{paperInstalledBuild}".ljust(8), end='')
|
||||
print(" ", end='')
|
||||
print(f"{paperLatestBuild}".ljust(8), end='')
|
||||
print(" ", end='')
|
||||
print(f"{paperVersionBehind}".ljust(8))
|
||||
|
||||
|
||||
# https://papermc.io/api/docs/swagger-ui/index.html?configUrl=/api/openapi/swagger-config#/
|
||||
def papermc_downloader(paperBuild='latest', installedServerjarName=None, mcVersion=None):
|
||||
if checkConfig().localPluginFolder == False:
|
||||
downloadPath = createTempPluginFolder()
|
||||
else:
|
||||
downloadPath = checkConfig().pathToPluginFolder
|
||||
helpPath = Path('/plugins')
|
||||
helpPathstr = str(helpPath)
|
||||
downloadPath = Path(str(downloadPath).replace(helpPathstr, ''))
|
||||
|
||||
if mcVersion == None:
|
||||
if paperBuild == 'latest':
|
||||
mcVersion = '1.16.5'
|
||||
else:
|
||||
mcVersion = findBuildVersion(paperBuild)
|
||||
|
||||
if installedServerjarName != None:
|
||||
mcVersion = getInstalledPaperMinecraftVersion(installedServerjarName)
|
||||
|
||||
if paperBuild == 'latest':
|
||||
paperBuild = findLatestBuildForVersion(mcVersion)
|
||||
try:
|
||||
downloadFileName = getDownloadFileName(mcVersion, paperBuild)
|
||||
except KeyError:
|
||||
print(oColors.brightRed + f"This version wasn't found for {mcVersion}" + oColors.standardWhite)
|
||||
print(oColors.brightRed + f"Reverting to latest version for {mcVersion}" + oColors.standardWhite)
|
||||
paperBuild = findLatestBuildForVersion(mcVersion)
|
||||
downloadFileName = getDownloadFileName(mcVersion, paperBuild)
|
||||
|
||||
downloadPackagePath = Path(f"{downloadPath}/{downloadFileName}")
|
||||
|
||||
if checkConfig().localPluginFolder == False:
|
||||
downloadPath = createTempPluginFolder()
|
||||
|
||||
url = f"https://papermc.io/api/v2/projects/paper/versions/{mcVersion}/builds/{paperBuild}/downloads/{downloadFileName}"
|
||||
remotefile = urllib.request.urlopen(url)
|
||||
filesize = remotefile.info()['Content-Length']
|
||||
print(f"Starting Paper-{paperBuild} download for {mcVersion}...")
|
||||
urllib.request.urlretrieve(url, downloadPackagePath)
|
||||
filesizeData = calculateFileSizeMb(filesize)
|
||||
|
||||
print(f"Downloadsize: {filesizeData} MB")
|
||||
print(f"File downloaded here: {downloadPackagePath}")
|
||||
if not checkConfig().localPluginFolder:
|
||||
sftpSession = createSFTPConnection()
|
||||
sftp_upload_server_jar(sftpSession, downloadPackagePath)
|
||||
deleteTempPluginFolder(downloadPath)
|
||||
|
||||
print(oColors.brightGreen + "Downloaded successfully " + oColors.standardWhite + f"Paper-{paperBuild}" + \
|
||||
oColors.brightGreen + " for " + oColors.standardWhite + f"{mcVersion}" + oColors.standardWhite)
|
@@ -13,11 +13,11 @@ def clearConsole():
|
||||
# https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
|
||||
class oColors:
|
||||
standardWhite = "\033[0m"
|
||||
brightYellow = "\033[93m"
|
||||
brightMagenta = "\033[95m"
|
||||
brightBlack = "\033[90m"
|
||||
brightRed = "\033[91m"
|
||||
brightGreen = "\033[92m"
|
||||
darkMagenta = "\033[35m"
|
||||
brightYellow = "\033[93m"
|
||||
brightMagenta = "\033[95m"
|
||||
|
||||
|
||||
def printLogo():
|
||||
@@ -72,9 +72,12 @@ def printLogo():
|
||||
oColors.standardWhite)
|
||||
print()
|
||||
print()
|
||||
print(oColors.brightYellow + " [" + oColors.darkMagenta + "By Neocky" +
|
||||
oColors.brightYellow + "] " + oColors.standardWhite)
|
||||
print()
|
||||
print(oColors.brightBlack + " ┌────────────────────────────────────┐" + oColors.standardWhite)
|
||||
print(oColors.brightBlack + " │ [" + oColors.brightMagenta + "By Neocky" +oColors.brightBlack +
|
||||
"] │ " + oColors.standardWhite)
|
||||
print(oColors.brightBlack + " │ " + oColors.brightMagenta + "https://github.com/Neocky/pluGET" + oColors.brightBlack +
|
||||
" │ " + oColors.standardWhite)
|
||||
print(oColors.brightBlack + " └────────────────────────────────────┘" + oColors.standardWhite)
|
||||
|
||||
|
||||
def printHorizontalLine():
|
||||
|
@@ -3,6 +3,7 @@ import os
|
||||
import sys
|
||||
import shutil
|
||||
import requests
|
||||
from pathlib import Path
|
||||
|
||||
from utils.consoleoutput import oColors
|
||||
from handlers.handle_config import checkConfig
|
||||
@@ -11,12 +12,88 @@ from handlers.handle_sftp import createSFTPConnection
|
||||
|
||||
def getHelp():
|
||||
print(oColors.brightYellow+ "Need help?" + oColors.standardWhite)
|
||||
print("Check the docs here:")
|
||||
print("For a list of all commands: 'help command'")
|
||||
print("Or check the docs here:")
|
||||
print("https://github.com/Neocky/pluGET")
|
||||
print("Or go to the official discord.")
|
||||
print("The link for discord can also be found on Github!")
|
||||
|
||||
|
||||
def getCommandHelp(optionalParams):
|
||||
if optionalParams == None:
|
||||
optionalParams = 'all'
|
||||
print(oColors.brightBlack + f"Help for command: {optionalParams}" +oColors.standardWhite)
|
||||
print("┌────────────────┬─────────────────┬─────────────────┬────────────────────────────────────────────────────────┐")
|
||||
print("│ Command │ Selected Object │ Optional Params │ Function │")
|
||||
print("└────────────────┴─────────────────┴─────────────────┴────────────────────────────────────────────────────────┘")
|
||||
while True:
|
||||
if optionalParams == 'all':
|
||||
print(oColors.brightBlack + " GENERAL:" + oColors.standardWhite)
|
||||
print(" exit ./anything Exit pluGET")
|
||||
print(" help ./anything Get general help")
|
||||
print(" help command all/command Get specific help to the commands of pluGET")
|
||||
print(oColors.brightBlack + " PLUGIN MANAGEMENT:" + oColors.standardWhite)
|
||||
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(" update Name/ID/all Update installed plugins to the latest version")
|
||||
print(" search Name Search for a plugin and download the latest version")
|
||||
print(" remove Name/ID Delete an installed plugin")
|
||||
print(oColors.brightBlack + " SERVER SOFTWARE MANAGEMENT:" + oColors.standardWhite)
|
||||
print(" check serverjar Check installed server software for an update")
|
||||
print(" update serverjar Version/Latest Update installed server software to a specific version")
|
||||
print(" get-paper PaperVersion McVersion Downloads a specific PaperMc version")
|
||||
break
|
||||
|
||||
if optionalParams == 'exit':
|
||||
print(oColors.brightBlack + " GENERAL:" + oColors.standardWhite)
|
||||
print(" exit ./anything Exit pluGET")
|
||||
break
|
||||
|
||||
if optionalParams == 'help':
|
||||
print(oColors.brightBlack + " GENERAL:" + oColors.standardWhite)
|
||||
print(" help ./anything Get general help")
|
||||
print(" help command all/command Get specific help to the commands of pluGET")
|
||||
break
|
||||
|
||||
if optionalParams == 'get':
|
||||
print(oColors.brightBlack + " PLUGIN MANAGEMENT:" + oColors.standardWhite)
|
||||
print(print(" get Name/ID Version Downloads the latest version of a plugin"))
|
||||
break
|
||||
|
||||
if optionalParams == 'check':
|
||||
print(oColors.brightBlack + " PLUGIN MANAGEMENT:" + oColors.standardWhite)
|
||||
print(" check Name/ID/all Check for an update of an installed plugin")
|
||||
print(oColors.brightBlack + " SERVER SOFTWARE MANAGEMENT:" + oColors.standardWhite)
|
||||
print(" check serverjar Check installed server software for an update")
|
||||
break
|
||||
|
||||
if optionalParams == 'update':
|
||||
print(oColors.brightBlack + " PLUGIN MANAGEMENT:" + oColors.standardWhite)
|
||||
print(" update Name/ID/all Update installed plugins to the latest version")
|
||||
print(oColors.brightBlack + " SERVER SOFTWARE MANAGEMENT:" + oColors.standardWhite)
|
||||
print(" update serverjar Version/Latest Update installed server software to a specific version")
|
||||
break
|
||||
|
||||
if optionalParams == 'search':
|
||||
print(oColors.brightBlack + " PLUGIN MANAGEMENT:" + oColors.standardWhite)
|
||||
print(" search Name Search for a plugin and download the latest version")
|
||||
break
|
||||
|
||||
if optionalParams == 'remove':
|
||||
print(oColors.brightBlack + " PLUGIN MANAGEMENT:" + oColors.standardWhite)
|
||||
print(" remove Name/ID Delete an installed plugin")
|
||||
break
|
||||
|
||||
if optionalParams == 'get-paper':
|
||||
print(oColors.brightBlack + " SERVER SOFTWARE MANAGEMENT:" + oColors.standardWhite)
|
||||
print(" get-paper PaperVersion McVersion Downloads a specific PaperMc version")
|
||||
break
|
||||
|
||||
else:
|
||||
print(oColors.brightRed + "Error: Help for Command not found. Please try again. :(" + oColors.standardWhite)
|
||||
break
|
||||
|
||||
|
||||
def check_local_plugin_folder():
|
||||
if checkConfig().localPluginFolder:
|
||||
if checkConfig().seperateDownloadPath:
|
||||
@@ -59,7 +136,7 @@ def check_requirements():
|
||||
|
||||
|
||||
def createTempPluginFolder():
|
||||
tempPluginFolder = ".\\plugins"
|
||||
tempPluginFolder = Path("./TempSFTPUploadFolder")
|
||||
if not os.path.isdir(tempPluginFolder):
|
||||
try:
|
||||
os.mkdir(tempPluginFolder)
|
||||
@@ -76,3 +153,10 @@ def deleteTempPluginFolder(tempPluginFolder):
|
||||
shutil.rmtree(tempPluginFolder)
|
||||
except OSError as e:
|
||||
print ("Error: %s - %s." % (e.filename, e.strerror))
|
||||
|
||||
|
||||
def calculateFileSizeMb(downloadFileSize):
|
||||
fileSizeDownload = int(downloadFileSize)
|
||||
fileSizeMb = fileSizeDownload / 1024 / 1024
|
||||
roundedFileSize = round(fileSizeMb, 2)
|
||||
return roundedFileSize
|
||||
|
Reference in New Issue
Block a user