mirror of
https://github.com/Neocky/pluGET.git
synced 2024-04-29 16:12:30 +00:00
Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
60a41015e6 | ||
![]() |
706b8049c3 | ||
![]() |
927767b0aa | ||
![]() |
2a7372dae1 | ||
![]() |
31a2a4aa89 | ||
![]() |
aceca0dec3 | ||
![]() |
205a13ee94 | ||
![]() |
fddc0c252c | ||
![]() |
17611c741e | ||
![]() |
e8e46bb014 | ||
![]() |
5086b36aa3 | ||
![]() |
2a481acbef | ||
![]() |
5b68181661 | ||
![]() |
9b628498f1 | ||
![]() |
d40ee52da1 | ||
![]() |
e66985054c | ||
![]() |
e1efcc4fc7 | ||
![]() |
1147d4f29c | ||
![]() |
ebb04085d3 | ||
![]() |
e161d2c2f9 | ||
![]() |
01465eb769 | ||
![]() |
d478432396 | ||
![]() |
d7fc68195b |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -127,3 +127,6 @@ dmypy.json
|
|||||||
|
|
||||||
# Pyre type checker
|
# Pyre type checker
|
||||||
.pyre/
|
.pyre/
|
||||||
|
|
||||||
|
# VSCode Settings
|
||||||
|
.vscode
|
||||||
|
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"python.linting.pylintEnabled": true,
|
|
||||||
"python.linting.enabled": true
|
|
||||||
}
|
|
107
README.md
107
README.md
@@ -12,14 +12,32 @@
|
|||||||
<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/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/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>
|
||||||
<img src="https://hitcounter.pythonanywhere.com/count/tag.svg?url=https%3A%2F%2Fgithub.com%2FNeocky%2FpluGET" alt="Hits">
|
<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 powerfull package manager which handles [Plugins](https://www.spigotmc.org/resources/) and Server Software for minecraft servers.
|
#### A powerfull 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" />
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Screenshots</summary>
|
||||||
|
|
||||||
|
`check all` to check installed plugins for updates:
|
||||||
|

|
||||||
|
|
||||||
|
`check all` with more plugins:
|
||||||
|

|
||||||
|
|
||||||
|
`help command` list all available commands:
|
||||||
|

|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<img src="https://i.ibb.co/82dnyrK/image.png" alt="meme" border="0" height="350" width="350"></a>
|
||||||
|
|
||||||
|
|
||||||
## Issues? Found a bug?
|
## Issues? Found a bug?
|
||||||
@@ -33,7 +51,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 specifif server software (e.g. [PaperMC](https://papermc.io/)).
|
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.
|
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 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.
|
||||||
@@ -81,7 +99,7 @@ Get it [here](https://www.python.org/downloads/).
|
|||||||
Install the needed packages for this project.
|
Install the needed packages for this project.
|
||||||
Execute this command in the ```\plugGET``` folder:
|
Execute this command in the ```\plugGET``` folder:
|
||||||
```python
|
```python
|
||||||
pip install -r requirements.txt
|
py -m pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -90,14 +108,41 @@ When run the first time, the `config.ini` file will be created in the root packa
|
|||||||
Edit the config to your needs and relaunch pluGET.
|
Edit the config to your needs and relaunch pluGET.
|
||||||
**Now you are good to go!**
|
**Now you are good to go!**
|
||||||
|
|
||||||
|
## Start pluGET
|
||||||
|
### Windows:
|
||||||
|
Execute the `launcher.bat` in the `\pluGET` folder.
|
||||||
|
This will launch pluGET correctly.
|
||||||
|
### Linux:
|
||||||
|
Use `cd` to change into the `/pluGET` directory and change the permission of the `launcher.sh` to make it executeable:
|
||||||
|
```
|
||||||
|
$ chmod +x launcher.sh
|
||||||
|
```
|
||||||
|
Execute the `launcher.sh` file:
|
||||||
|
```
|
||||||
|
$ ./launcher.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
> On both OS you can also launch the `src/__main__.py` file.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
> As always, if you update plugins, shut down your server!
|
> 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:
|
The following are examples of input for the general usage:
|
||||||
(Hint: [thingsInBrackets] are optional & '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
|
### Manage Plugins
|
||||||
#### Download the latest update of a specific package:
|
#### Download the latest update of a specific package:
|
||||||
`get [pluginID/pluginName]`
|
`get [pluginID/pluginName]`
|
||||||
@@ -117,6 +162,15 @@ or:
|
|||||||
```
|
```
|
||||||
check 'pluginName'
|
check 'pluginName'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Output</summary>
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
|
||||||
#### Update all plugins/one specific plugin:
|
#### Update all plugins/one specific plugin:
|
||||||
`update [all/pluginName]`
|
`update [all/pluginName]`
|
||||||
```
|
```
|
||||||
@@ -172,35 +226,12 @@ get-paper 321
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Known problems
|
## Known problems
|
||||||
### Can't get installed version
|
|
||||||
For example:
|
### Can't get latest version/Update available
|
||||||
```
|
For example:
|
||||||
pluGET >> check all
|

|
||||||
Checking: all
|
As you can see the installed version was found but not the latest version for this plugin.
|
||||||
Index | Name | Installed V. | Latest V. | Update available
|
This is because this is a plugin which is not available on [Spigot](https://www.spigotmc.org/resources/).
|
||||||
[1] Vault N/A 1.7.3 False
|
pluGET supports currently only plugins from [Spigot](https://www.spigotmc.org/resources/).
|
||||||
```
|
In this example this is a bukkit plugin.
|
||||||
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
|
|
||||||
```
|
|
||||||
|
|
||||||
|
2
launcher.sh
Normal file
2
launcher.sh
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
cd src/
|
||||||
|
python3 "__main__.py"
|
@@ -7,4 +7,8 @@ pynacl >= 1.4.0
|
|||||||
cffi >= 1.14.5
|
cffi >= 1.14.5
|
||||||
six >= 1.15.0
|
six >= 1.15.0
|
||||||
pycparser >= 2.20
|
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.consoleoutput import consoleTitle, clearConsole, printMainMenu
|
||||||
from utils.utilities import getHelp, check_requirements
|
from utils.utilities import check_requirements
|
||||||
from handlers.handle_input import createInputLists, getInput
|
from handlers.handle_input import createInputLists, getInput
|
||||||
from handlers.handle_config import checkConfig
|
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():
|
def mainFunction():
|
||||||
|
@@ -6,73 +6,81 @@ from pathlib import Path
|
|||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
|
|
||||||
|
|
||||||
|
class configurationValues:
|
||||||
|
def __init__(self):
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.sections()
|
||||||
|
config.read("config.ini")
|
||||||
|
localPluginFolder = config['General']['UseLocalPluginFolder']
|
||||||
|
self.pathToPluginFolder = Path(config['Local - This Machine']['PathToPluginFolder'])
|
||||||
|
seperateDownloadPath = config['Local - This Machine']['SeperateDownloadPath']
|
||||||
|
self.pathToSeperateDownloadPath = Path(config['Local - This Machine']['PathToSeperateDownloadPath'])
|
||||||
|
|
||||||
|
self.sftp_server = config['SFTP - Remote Server']['Server']
|
||||||
|
self.sftp_user = config['SFTP - Remote Server']['Username']
|
||||||
|
self.sftp_password = config['SFTP - Remote Server']['Password']
|
||||||
|
sftp_port = config['SFTP - Remote Server']['SFTPPort']
|
||||||
|
self.sftp_folderPath = config['SFTP - Remote Server']['PluginFolderOnServer']
|
||||||
|
sftp_useSftp = config['SFTP - Remote Server']['USE_SFTP']
|
||||||
|
sftp_seperateDownloadPath = config['SFTP - Remote Server']['SeperateDownloadPath']
|
||||||
|
self.sftp_pathToSeperateDownloadPath = config['SFTP - Remote Server']['PathToSeperateDownloadPath']
|
||||||
|
|
||||||
|
self.sftp_port = int(sftp_port)
|
||||||
|
if localPluginFolder == 'True':
|
||||||
|
self.localPluginFolder = True
|
||||||
|
else:
|
||||||
|
self.localPluginFolder = False
|
||||||
|
|
||||||
|
if seperateDownloadPath == 'True':
|
||||||
|
self.seperateDownloadPath = True
|
||||||
|
else:
|
||||||
|
self.seperateDownloadPath = False
|
||||||
|
|
||||||
|
if sftp_seperateDownloadPath == 'True':
|
||||||
|
self.sftp_seperateDownloadPath = True
|
||||||
|
else:
|
||||||
|
self.sftp_seperateDownloadPath = False
|
||||||
|
|
||||||
|
if sftp_useSftp == 'True':
|
||||||
|
self.sftp_useSftp = True
|
||||||
|
else:
|
||||||
|
self.sftp_useSftp = False
|
||||||
|
|
||||||
|
|
||||||
def checkConfig():
|
def checkConfig():
|
||||||
currentFolder = os.getcwd()
|
|
||||||
configAvailable = os.path.isfile("config.ini")
|
configAvailable = os.path.isfile("config.ini")
|
||||||
|
|
||||||
if not configAvailable:
|
if not configAvailable:
|
||||||
createConfig()
|
createConfig()
|
||||||
print(oColors.brightRed + "Config created. Edit config before executing again!" + oColors.standardWhite)
|
print(oColors.brightRed + "Config created. Edit config before executing again!" + oColors.standardWhite)
|
||||||
input("Press any key + enter to exit...")
|
input("Press any key + enter to exit...")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
class configValues:
|
|
||||||
config = configparser.ConfigParser()
|
|
||||||
config.sections()
|
|
||||||
config.read("config.ini")
|
|
||||||
localPluginFolder = config['General']['LocalPluginFolder']
|
|
||||||
pathToPluginFolder = Path(config['General']['PathToPluginFolder'])
|
|
||||||
seperateDownloadPath = config['General']['SeperateDownloadPath']
|
|
||||||
pathToSeperateDownloadPath = Path(config['General']['PathToSeperateDownloadPath'])
|
|
||||||
|
|
||||||
sftp_server = config['SFTP - Remote Server']['Server']
|
|
||||||
sftp_user = config['SFTP - Remote Server']['Username']
|
|
||||||
sftp_password = config['SFTP - Remote Server']['Password']
|
|
||||||
sftp_port = config['SFTP - Remote Server']['Port']
|
|
||||||
sftp_folderPath = config['SFTP - Remote Server']['PluginFolderOnServer']
|
|
||||||
sftp_seperateDownloadPath = config['SFTP - Remote Server']['SeperateDownloadPath']
|
|
||||||
sftp_pathToSeperateDownloadPath = config['SFTP - Remote Server']['PathToSeperateDownloadPath']
|
|
||||||
|
|
||||||
sftp_port = int(sftp_port)
|
|
||||||
if localPluginFolder == 'True':
|
|
||||||
localPluginFolder = True
|
|
||||||
else:
|
|
||||||
localPluginFolder = False
|
|
||||||
|
|
||||||
if seperateDownloadPath == 'True':
|
|
||||||
seperateDownloadPath = True
|
|
||||||
else:
|
|
||||||
seperateDownloadPath = False
|
|
||||||
|
|
||||||
if sftp_seperateDownloadPath == 'True':
|
|
||||||
sftp_seperateDownloadPath = True
|
|
||||||
else:
|
|
||||||
sftp_seperateDownloadPath = False
|
|
||||||
|
|
||||||
os.chdir(currentFolder)
|
|
||||||
return configValues
|
|
||||||
|
|
||||||
|
|
||||||
def createConfig():
|
def createConfig():
|
||||||
config = configparser.ConfigParser(allow_no_value=True)
|
config = configparser.ConfigParser(allow_no_value=True)
|
||||||
config['General'] = {}
|
config['General'] = {}
|
||||||
config['General'][';'] = 'If a local plugin folder exists (True/False): (If False SFTP will be used)'
|
config['General'][';'] = 'If a local plugin folder exists (True/False) (If False SFTP/FTP will be used):'
|
||||||
config['General']['LocalPluginFolder'] = 'True'
|
config['General']['UseLocalPluginFolder'] = 'True'
|
||||||
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['Local - This Machine'] = {}
|
||||||
config['General']['SeperateDownloadPath'] = 'False'
|
config['Local - This Machine']['PathToPluginFolder'] = 'C:/Users/USER/Desktop/plugins'
|
||||||
config['General']['PathToSeperateDownloadPath'] = 'C:\\Users\\USER\\Desktop\\plugins'
|
config['Local - This Machine'][';'] = 'For a different folder to store the updated plugins change to (True/False) and the path below'
|
||||||
|
config['Local - This Machine']['SeperateDownloadPath'] = 'False'
|
||||||
|
config['Local - This Machine']['PathToSeperateDownloadPath'] = 'C:/Users/USER/Desktop/plugins'
|
||||||
|
|
||||||
config['SFTP - Remote Server'] = {}
|
config['SFTP - Remote Server'] = {}
|
||||||
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'][';'] = 'Normally you won*t need to change anything below this line'
|
config['SFTP - Remote Server'][';'] = 'If a different Port for SFTP needs to be used (Works only for SFTP)'
|
||||||
config['SFTP - Remote Server']['Port'] = '22'
|
config['SFTP - Remote Server']['SFTPPort'] = '22'
|
||||||
config['SFTP - Remote Server']['PluginFolderOnServer'] = '.\\plugins'
|
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 you want a different folder to store the updated plugins change to (True/False) and the path below'
|
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']['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']['SeperateDownloadPath'] = 'False'
|
config['SFTP - Remote Server']['SeperateDownloadPath'] = 'False'
|
||||||
config['SFTP - Remote Server']['PathToSeperateDownloadPath'] = '.\\plugins'
|
config['SFTP - Remote Server']['PathToSeperateDownloadPath'] = './plugins'
|
||||||
|
|
||||||
|
|
||||||
with open('config.ini', 'w') as configfile:
|
with open('config.ini', 'w') as configfile:
|
||||||
|
95
src/handlers/handle_ftp.py
Normal file
95
src/handlers/handle_ftp.py
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import ftplib
|
||||||
|
|
||||||
|
from utils.consoleoutput import oColors
|
||||||
|
from handlers.handle_config import configurationValues
|
||||||
|
|
||||||
|
|
||||||
|
def createFTPConnection():
|
||||||
|
configValues = configurationValues()
|
||||||
|
ftp = ftplib.FTP(configValues.sftp_server, user=configValues.sftp_user, \
|
||||||
|
passwd=configValues.sftp_password)
|
||||||
|
try:
|
||||||
|
return ftp
|
||||||
|
except UnboundLocalError:
|
||||||
|
print(oColors.brightRed + "[FTP]: Check your config.ini!" + oColors.standardWhite)
|
||||||
|
print(oColors.brightRed + "Exiting program..." + oColors.standardWhite)
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
|
def ftp_showPlugins(ftp):
|
||||||
|
configValues = configurationValues()
|
||||||
|
ftp.cwd(configValues.sftp_folderPath)
|
||||||
|
for attr in ftp.dir():
|
||||||
|
print(attr.filename, attr)
|
||||||
|
|
||||||
|
|
||||||
|
def ftp_upload_file(ftp, itemPath):
|
||||||
|
configValues = configurationValues()
|
||||||
|
try:
|
||||||
|
ftp.cwd(configValues.sftp_folderPath)
|
||||||
|
itemPath = os.path.relpath(itemPath, 'TempSFTPFolder/')
|
||||||
|
itemPath = str(itemPath)
|
||||||
|
currentDirectory = os.getcwd()
|
||||||
|
os.chdir('TempSFTPFolder')
|
||||||
|
with open (itemPath, 'rb') as plugin_file:
|
||||||
|
ftp.storbinary('STOR '+ str(itemPath), plugin_file)
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(oColors.brightRed + "[FTP]: The 'plugins' folder couldn*t be found on the remote host!" + oColors.standardWhite)
|
||||||
|
print(oColors.brightRed + "[FTP]: Aborting uploading." + oColors.standardWhite)
|
||||||
|
os.chdir(currentDirectory)
|
||||||
|
ftp.close()
|
||||||
|
|
||||||
|
|
||||||
|
def ftp_upload_server_jar(ftp, itemPath):
|
||||||
|
try:
|
||||||
|
print(f"itempath: {itemPath}")
|
||||||
|
ftp.cwd('.')
|
||||||
|
itemPath = os.path.relpath(itemPath, 'TempSFTPFolder/')
|
||||||
|
itemPath = str(itemPath)
|
||||||
|
currentDirectory = os.getcwd()
|
||||||
|
os.chdir('TempSFTPFolder')
|
||||||
|
with open (itemPath, 'rb') as server_jar:
|
||||||
|
ftp.storbinary('STOR '+ str(itemPath), server_jar)
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(oColors.brightRed + "[FTP]: The 'root' folder couldn*t be found on the remote host!" + oColors.standardWhite)
|
||||||
|
print(oColors.brightRed + "[FTP]: Aborting uploading." + oColors.standardWhite)
|
||||||
|
os.chdir(currentDirectory)
|
||||||
|
ftp.close()
|
||||||
|
|
||||||
|
|
||||||
|
def ftp_listAll(ftp):
|
||||||
|
configValues = configurationValues()
|
||||||
|
try:
|
||||||
|
ftp.cwd(configValues.sftp_folderPath)
|
||||||
|
installedPlugins = ftp.nlst()
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(oColors.brightRed + "[FTP]: The 'plugins' folder couldn*t be found on the remote host!" + oColors.standardWhite)
|
||||||
|
|
||||||
|
try:
|
||||||
|
return installedPlugins
|
||||||
|
except UnboundLocalError:
|
||||||
|
print(oColors.brightRed + "[FTP]: No plugins were found." + oColors.standardWhite)
|
||||||
|
|
||||||
|
|
||||||
|
def ftp_listFilesInServerRoot(ftp):
|
||||||
|
try:
|
||||||
|
ftp.cwd('.')
|
||||||
|
filesInServerRoot = ftp.nlst()
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(oColors.brightRed + "[FTP]: The 'root' folder couldn*t be found on the remote host!" + oColors.standardWhite)
|
||||||
|
|
||||||
|
try:
|
||||||
|
return filesInServerRoot
|
||||||
|
except UnboundLocalError:
|
||||||
|
print(oColors.brightRed + "[FTP]: No Serverjar was found." + oColors.standardWhite)
|
||||||
|
|
||||||
|
|
||||||
|
def ftp_downloadFile(ftp, downloadPath, fileToDownload):
|
||||||
|
configValues = configurationValues()
|
||||||
|
ftp.cwd(configValues.sftp_folderPath)
|
||||||
|
filedata = open(downloadPath,'wb')
|
||||||
|
ftp.retrbinary('RETR '+fileToDownload, filedata.write)
|
||||||
|
filedata.close()
|
||||||
|
ftp.quit()
|
@@ -1,8 +1,8 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from utils.utilities import getHelp
|
from utils.utilities import getHelp, getCommandHelp
|
||||||
from handlers.handle_config import checkConfig
|
from handlers.handle_config import configurationValues
|
||||||
from plugin.plugin_downloader import searchPackage, getSpecificPackage
|
from plugin.plugin_downloader import searchPackage, getSpecificPackage
|
||||||
from plugin.plugin_updatechecker import updateInstalledPackage, checkInstalledPackage
|
from plugin.plugin_updatechecker import updateInstalledPackage, checkInstalledPackage
|
||||||
from plugin.plugin_remover import removePlugin
|
from plugin.plugin_remover import removePlugin
|
||||||
@@ -30,21 +30,22 @@ def createInputLists():
|
|||||||
|
|
||||||
|
|
||||||
def handleInput(inputCommand, inputSelectedObject, inputParams):
|
def handleInput(inputCommand, inputSelectedObject, inputParams):
|
||||||
|
configValues = configurationValues()
|
||||||
while True:
|
while True:
|
||||||
if inputCommand == 'get':
|
if inputCommand == 'get':
|
||||||
if inputSelectedObject.isdigit():
|
if inputSelectedObject.isdigit():
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
if checkConfig().sftp_seperateDownloadPath is True:
|
if configValues.sftp_seperateDownloadPath is True:
|
||||||
pluginPath = checkConfig().sftp_pathToSeperateDownloadPath
|
pluginPath = configValues.sftp_pathToSeperateDownloadPath
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().sftp_folderPath
|
pluginPath = configValues.sftp_folderPath
|
||||||
getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
|
getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if checkConfig().seperateDownloadPath is True:
|
if configValues.seperateDownloadPath is True:
|
||||||
pluginPath = checkConfig().pathToSeperateDownloadPath
|
pluginPath = configValues.pathToSeperateDownloadPath
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().pathToPluginFolder
|
pluginPath = configValues.pathToPluginFolder
|
||||||
getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
|
getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
@@ -68,7 +69,10 @@ def handleInput(inputCommand, inputSelectedObject, inputParams):
|
|||||||
if inputCommand == 'exit':
|
if inputCommand == 'exit':
|
||||||
sys.exit()
|
sys.exit()
|
||||||
if inputCommand == 'help':
|
if inputCommand == 'help':
|
||||||
getHelp()
|
if inputSelectedObject == 'command' or inputSelectedObject == 'commands':
|
||||||
|
getCommandHelp(inputParams)
|
||||||
|
else:
|
||||||
|
getHelp()
|
||||||
break
|
break
|
||||||
if inputCommand == 'remove':
|
if inputCommand == 'remove':
|
||||||
removePlugin(inputSelectedObject)
|
removePlugin(inputSelectedObject)
|
||||||
@@ -77,18 +81,25 @@ def handleInput(inputCommand, inputSelectedObject, inputParams):
|
|||||||
papermc_downloader(inputSelectedObject, inputParams)
|
papermc_downloader(inputSelectedObject, inputParams)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print(oColors.brightRed + "Command not found. Please try again." + oColors.standardWhite)
|
print(oColors.brightRed + "Error: Command not found. Please try again. :(" + oColors.standardWhite)
|
||||||
|
print(oColors.brightRed + "Use: '" + oColors.standardWhite +"help command" + oColors.brightRed +"' to get all available commands" + oColors.standardWhite)
|
||||||
getInput()
|
getInput()
|
||||||
getInput()
|
getInput()
|
||||||
|
|
||||||
|
|
||||||
def getInput():
|
def getInput():
|
||||||
|
inputCommand = None
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
inputCommand, inputSelectedObject, *inputParams = input("pluGET >> ").split()
|
inputCommand, inputSelectedObject, *inputParams = input("pluGET >> ").split()
|
||||||
break
|
break
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print(oColors.brightRed + "Wrong input! Use: > *command* *selectedObject* *optionalParams*" + oColors.standardWhite)
|
if inputCommand == None:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
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)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
sys.exit()
|
||||||
inputParams = inputParams[0] if inputParams else None
|
inputParams = inputParams[0] if inputParams else None
|
||||||
handleInput(inputCommand, inputSelectedObject, inputParams)
|
handleInput(inputCommand, inputSelectedObject, inputParams)
|
||||||
|
@@ -1,17 +1,19 @@
|
|||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
import pysftp
|
import pysftp
|
||||||
import paramiko
|
import paramiko
|
||||||
|
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from handlers.handle_config import checkConfig
|
from handlers.handle_config import configurationValues
|
||||||
|
|
||||||
|
|
||||||
def createSFTPConnection():
|
def createSFTPConnection():
|
||||||
|
configValues = configurationValues()
|
||||||
cnopts = pysftp.CnOpts()
|
cnopts = pysftp.CnOpts()
|
||||||
cnopts.hostkeys = None # TODO fix this
|
cnopts.hostkeys = None # TODO fix this
|
||||||
try:
|
try:
|
||||||
sftp = pysftp.Connection(checkConfig().sftp_server, username=checkConfig().sftp_user, \
|
sftp = pysftp.Connection(configValues.sftp_server, username=configValues.sftp_user, \
|
||||||
password=checkConfig().sftp_password, port=checkConfig().sftp_port, cnopts=cnopts)
|
password=configValues.sftp_password, port=configValues.sftp_port, cnopts=cnopts)
|
||||||
except paramiko.ssh_exception.AuthenticationException:
|
except paramiko.ssh_exception.AuthenticationException:
|
||||||
print(oColors.brightRed + "[SFTP]: Wrong Username/Password" + oColors.standardWhite)
|
print(oColors.brightRed + "[SFTP]: Wrong Username/Password" + oColors.standardWhite)
|
||||||
except paramiko.ssh_exception.SSHException:
|
except paramiko.ssh_exception.SSHException:
|
||||||
@@ -30,18 +32,14 @@ def sftp_showPlugins(sftp):
|
|||||||
print(attr.filename, attr)
|
print(attr.filename, attr)
|
||||||
|
|
||||||
|
|
||||||
def sftp_cdPluginDir(sftp):
|
|
||||||
sftp.cd('plugins')
|
|
||||||
|
|
||||||
|
|
||||||
def sftp_upload_file(sftp, itemPath):
|
def sftp_upload_file(sftp, itemPath):
|
||||||
try:
|
try:
|
||||||
sftp.chdir('plugins')
|
sftp.chdir('plugins')
|
||||||
sftp.put(itemPath)
|
sftp.put(itemPath)
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(oColors.brightRed + "The 'plugins' folder couldn*t be found on the remote host!" + oColors.standardWhite)
|
print(oColors.brightRed + "[SFTP]: The 'plugins' folder couldn*t be found on the remote host!" + oColors.standardWhite)
|
||||||
print(oColors.brightRed + "Aborting installation." + oColors.standardWhite)
|
print(oColors.brightRed + "[SFTP]: Aborting uploading." + oColors.standardWhite)
|
||||||
sftp.close()
|
sftp.close()
|
||||||
|
|
||||||
|
|
||||||
@@ -49,10 +47,9 @@ def sftp_upload_server_jar(sftp, itemPath):
|
|||||||
try:
|
try:
|
||||||
sftp.chdir('.')
|
sftp.chdir('.')
|
||||||
sftp.put(itemPath)
|
sftp.put(itemPath)
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(oColors.brightRed + "The 'plugins' folder couldn*t be found on the remote host!" + oColors.standardWhite)
|
print(oColors.brightRed + "[SFTP]: The 'root' folder couldn*t be found on the remote host!" + oColors.standardWhite)
|
||||||
print(oColors.brightRed + "Aborting installation." + oColors.standardWhite)
|
print(oColors.brightRed + "[SFTP]: Aborting uploading." + oColors.standardWhite)
|
||||||
sftp.close()
|
sftp.close()
|
||||||
|
|
||||||
|
|
||||||
@@ -60,25 +57,33 @@ def sftp_listAll(sftp):
|
|||||||
try:
|
try:
|
||||||
sftp.chdir('plugins')
|
sftp.chdir('plugins')
|
||||||
installedPlugins = sftp.listdir()
|
installedPlugins = sftp.listdir()
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(oColors.brightRed + "The 'plugins' folder couldn*t be found on the remote host!" + oColors.standardWhite)
|
print(oColors.brightRed + "[SFTP]: The 'plugins' folder couldn*t be found on the remote host!" + oColors.standardWhite)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return installedPlugins
|
return installedPlugins
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
print(oColors.brightRed + "No plugins were found." + oColors.standardWhite)
|
print(oColors.brightRed + "[SFTP]: No plugins were found." + oColors.standardWhite)
|
||||||
|
|
||||||
|
|
||||||
def sftp_listFilesInServerRoot(sftp):
|
def sftp_listFilesInServerRoot(sftp):
|
||||||
try:
|
try:
|
||||||
#sftp.chdir('plugins')
|
|
||||||
filesInServerRoot = sftp.listdir()
|
filesInServerRoot = sftp.listdir()
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(oColors.brightRed + "The 'root' folder couldn*t be found on the remote host!" + oColors.standardWhite)
|
print(oColors.brightRed + "[SFTP]: The 'root' folder couldn*t be found on the remote host!" + oColors.standardWhite)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return filesInServerRoot
|
return filesInServerRoot
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
print(oColors.brightRed + "No Serverjar was found." + oColors.standardWhite)
|
print(oColors.brightRed + "[SFTP]: No Serverjar was found." + oColors.standardWhite)
|
||||||
|
|
||||||
|
|
||||||
|
def sftp_downloadFile(sftp, downloadPath, fileToDownload):
|
||||||
|
configValues = configurationValues()
|
||||||
|
sftp.cwd(configValues.sftp_folderPath)
|
||||||
|
currentDirectory = os.getcwd()
|
||||||
|
os.chdir('TempSFTPFolder')
|
||||||
|
sftp.get(fileToDownload)
|
||||||
|
sftp.close()
|
||||||
|
os.chdir(currentDirectory)
|
||||||
|
|
@@ -5,16 +5,10 @@ from pathlib import Path
|
|||||||
|
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from utils.web_request import doAPIRequest
|
from utils.web_request import doAPIRequest
|
||||||
from utils.utilities import createTempPluginFolder, deleteTempPluginFolder
|
from utils.utilities import createTempPluginFolder, deleteTempPluginFolder, calculateFileSizeKb, calculateFileSizeMb
|
||||||
from handlers.handle_config import checkConfig
|
from handlers.handle_config import configurationValues
|
||||||
from handlers.handle_sftp import sftp_upload_file, sftp_cdPluginDir, createSFTPConnection
|
from handlers.handle_sftp import sftp_upload_file, createSFTPConnection
|
||||||
|
from handlers.handle_ftp import ftp_upload_file, createFTPConnection
|
||||||
|
|
||||||
def calculateFileSize(downloadFileSize):
|
|
||||||
fileSizeDownload = int(downloadFileSize)
|
|
||||||
fileSizeKb = fileSizeDownload / 1024
|
|
||||||
roundedFileSize = round(fileSizeKb, 2)
|
|
||||||
return roundedFileSize
|
|
||||||
|
|
||||||
|
|
||||||
def handleRegexPackageName(packageNameFull):
|
def handleRegexPackageName(packageNameFull):
|
||||||
@@ -58,39 +52,45 @@ def getVersionName(packageId, versionId):
|
|||||||
|
|
||||||
|
|
||||||
def searchPackage(ressourceName):
|
def searchPackage(ressourceName):
|
||||||
|
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/{ressourceName}?field=name&sort=-downloads"
|
||||||
packageName = doAPIRequest(url)
|
packageName = doAPIRequest(url)
|
||||||
i = 1
|
i = 1
|
||||||
print(f"Searching: {ressourceName}")
|
print(oColors.brightBlack + f"Searching: {ressourceName}" + oColors.standardWhite)
|
||||||
print("Index | Name | Description | Downloads")
|
print("┌─────┬─────────────────────────────┬───────────┬──────────────────────────────────────────────────────────────────────┐")
|
||||||
|
print("│ No. │ Name │ Downloads │ Description │")
|
||||||
|
print("└─────┴─────────────────────────────┴───────────┴──────────────────────────────────────────────────────────────────────┘")
|
||||||
for ressource in packageName:
|
for ressource in packageName:
|
||||||
pName = ressource["name"]
|
pName = ressource["name"]
|
||||||
newName = handleRegexPackageName(pName)
|
newName = handleRegexPackageName(pName)
|
||||||
pTag = ressource["tag"]
|
pTag = ressource["tag"]
|
||||||
pDownloads = ressource["downloads"]
|
pDownloads = ressource["downloads"]
|
||||||
print(f" [{i}]".ljust(8), end='')
|
print(f" [{i}]".rjust(6), end='')
|
||||||
|
print(" ", end='')
|
||||||
print(f"{newName}".ljust(30), end='')
|
print(f"{newName}".ljust(30), end='')
|
||||||
print(f"{pTag}".ljust(120), end='')
|
print(f"{pDownloads}".rjust(9), end='')
|
||||||
print(f"{pDownloads}".ljust(7))
|
print(" ", end='')
|
||||||
|
print(f"{pTag}".ljust(120))
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
ressourceSelected = int(input("Select your wanted Ressource (Index)(0 to exit): "))
|
ressourceSelected = int(input("Select your wanted Ressource (No.)(0 to exit): "))
|
||||||
if ressourceSelected != 0:
|
if ressourceSelected != 0:
|
||||||
ressourceSelected = ressourceSelected - 1
|
ressourceSelected = ressourceSelected - 1
|
||||||
ressourceId = packageName[ressourceSelected]["id"]
|
ressourceId = packageName[ressourceSelected]["id"]
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
try:
|
try:
|
||||||
getSpecificPackage(ressourceId, checkConfig().sftp_folderPath)
|
getSpecificPackage(ressourceId, configValues.sftp_folderPath)
|
||||||
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)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
getSpecificPackage(ressourceId, checkConfig().pathToPluginFolder)
|
getSpecificPackage(ressourceId, configValues.pathToPluginFolder)
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
def downloadSpecificVersion(ressourceId, downloadPath, versionID='latest'):
|
def downloadSpecificVersion(ressourceId, downloadPath, versionID='latest'):
|
||||||
|
configValues = configurationValues()
|
||||||
if versionID != 'latest':
|
if versionID != 'latest':
|
||||||
#url = f"https://spigotmc.org/resources/{ressourceId}/download?version={versionID}"
|
#url = f"https://spigotmc.org/resources/{ressourceId}/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)
|
||||||
@@ -99,19 +99,33 @@ def downloadSpecificVersion(ressourceId, downloadPath, versionID='latest'):
|
|||||||
url = f"https://api.spiget.org/v2/resources/{ressourceId}/download"
|
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/{ressourceId}/versions/latest/download" #throws 403 forbidden error...cloudflare :(
|
||||||
|
|
||||||
|
urrlib_opener = urllib.request.build_opener()
|
||||||
|
urrlib_opener.addheaders = [('User-agent', 'pluGET/1.0')]
|
||||||
|
urllib.request.install_opener(urrlib_opener)
|
||||||
|
|
||||||
remotefile = urllib.request.urlopen(url)
|
remotefile = urllib.request.urlopen(url)
|
||||||
filesize = remotefile.info()['Content-Length']
|
filesize = remotefile.info()['Content-Length']
|
||||||
urllib.request.urlretrieve(url, downloadPath)
|
urllib.request.urlretrieve(url, downloadPath)
|
||||||
filesizeData = calculateFileSize(filesize)
|
filesize = int(filesize)
|
||||||
print(f"Downloadsize: {filesizeData} KB")
|
print(" ", end='')
|
||||||
print(f"File downloaded here: {downloadPath}")
|
if filesize >= 1000000:
|
||||||
if not checkConfig().localPluginFolder:
|
filesizeData = calculateFileSizeMb(filesize)
|
||||||
sftpSession = createSFTPConnection()
|
print("Downloaded " + (str(filesizeData)).rjust(9) + f" MB here {downloadPath}")
|
||||||
sftp_upload_file(sftpSession, downloadPath)
|
else:
|
||||||
|
filesizeData = calculateFileSizeKb(filesize)
|
||||||
|
print("Downloaded " + (str(filesizeData)).rjust(9) + f" KB here {downloadPath}")
|
||||||
|
if not configValues.localPluginFolder:
|
||||||
|
if configValues.sftp_useSftp:
|
||||||
|
sftpSession = createSFTPConnection()
|
||||||
|
sftp_upload_file(sftpSession, downloadPath)
|
||||||
|
else:
|
||||||
|
ftpSession = createFTPConnection()
|
||||||
|
ftp_upload_file(ftpSession, downloadPath)
|
||||||
|
|
||||||
|
|
||||||
def getSpecificPackage(ressourceId, downloadPath, inputPackageVersion='latest'):
|
def getSpecificPackage(ressourceId, downloadPath, inputPackageVersion='latest'):
|
||||||
if checkConfig().localPluginFolder == False:
|
configValues = configurationValues()
|
||||||
|
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/{ressourceId}"
|
||||||
packageDetails = doAPIRequest(url)
|
packageDetails = doAPIRequest(url)
|
||||||
@@ -120,17 +134,14 @@ def getSpecificPackage(ressourceId, downloadPath, inputPackageVersion='latest'):
|
|||||||
versionId = getVersionID(ressourceId, inputPackageVersion)
|
versionId = getVersionID(ressourceId, inputPackageVersion)
|
||||||
packageVersion = getVersionName(ressourceId, versionId)
|
packageVersion = getVersionName(ressourceId, versionId)
|
||||||
packageDownloadName = f"{packageNameNew}-{packageVersion}.jar"
|
packageDownloadName = f"{packageNameNew}-{packageVersion}.jar"
|
||||||
|
#if not configValues.localPluginFolder:
|
||||||
|
#downloadPackagePath = f"{downloadPath}/{packageDownloadName}"
|
||||||
|
#else:
|
||||||
downloadPackagePath = Path(f"{downloadPath}/{packageDownloadName}")
|
downloadPackagePath = Path(f"{downloadPath}/{packageDownloadName}")
|
||||||
if checkConfig().localPluginFolder:
|
if inputPackageVersion is None or inputPackageVersion == 'latest':
|
||||||
if inputPackageVersion is None or inputPackageVersion == 'latest':
|
downloadSpecificVersion(ressourceId=ressourceId, downloadPath=downloadPackagePath)
|
||||||
downloadSpecificVersion(ressourceId=ressourceId, downloadPath=downloadPackagePath)
|
else:
|
||||||
else:
|
downloadSpecificVersion(ressourceId, downloadPackagePath, versionId)
|
||||||
downloadSpecificVersion(ressourceId, downloadPackagePath, versionId)
|
|
||||||
|
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
if inputPackageVersion is None or inputPackageVersion == 'latest':
|
deleteTempPluginFolder(downloadPath)
|
||||||
downloadSpecificVersion(ressourceId=ressourceId, downloadPath=downloadPackagePath)
|
|
||||||
deleteTempPluginFolder(downloadPath)
|
|
||||||
else:
|
|
||||||
downloadSpecificVersion(ressourceId, downloadPackagePath, versionId)
|
|
||||||
deleteTempPluginFolder(downloadPath)
|
|
||||||
|
@@ -3,18 +3,24 @@ import re
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from handlers.handle_config import checkConfig
|
from handlers.handle_config import configurationValues
|
||||||
from handlers.handle_sftp import createSFTPConnection, sftp_listAll
|
from handlers.handle_sftp import createSFTPConnection, sftp_listAll
|
||||||
|
from handlers.handle_ftp import createFTPConnection, ftp_listAll
|
||||||
from plugin.plugin_updatechecker import getFileName, getFileVersion, getInstalledPlugin, createPluginList
|
from plugin.plugin_updatechecker import getFileName, getFileVersion, getInstalledPlugin, createPluginList
|
||||||
|
|
||||||
|
|
||||||
def removePlugin(pluginToRemove):
|
def removePlugin(pluginToRemove):
|
||||||
|
configValues = configurationValues()
|
||||||
createPluginList()
|
createPluginList()
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
sftp = createSFTPConnection()
|
if not configValues.sftp_useSftp:
|
||||||
pluginList = sftp_listAll(sftp)
|
ftp = createFTPConnection()
|
||||||
|
pluginList = ftp_listAll(ftp)
|
||||||
|
else:
|
||||||
|
sftp = createSFTPConnection()
|
||||||
|
pluginList = sftp_listAll(sftp)
|
||||||
else:
|
else:
|
||||||
pluginList = os.listdir(checkConfig().pathToPluginFolder)
|
pluginList = os.listdir(configValues.pathToPluginFolder)
|
||||||
i = 0
|
i = 0
|
||||||
try:
|
try:
|
||||||
for plugin in pluginList:
|
for plugin in pluginList:
|
||||||
@@ -28,16 +34,20 @@ def removePlugin(pluginToRemove):
|
|||||||
|
|
||||||
if pluginToRemove == pluginIdStr or re.search(pluginToRemove, fileName, re.IGNORECASE):
|
if pluginToRemove == pluginIdStr or re.search(pluginToRemove, fileName, re.IGNORECASE):
|
||||||
print(f"Removing: {fileName}")
|
print(f"Removing: {fileName}")
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
pluginPath = checkConfig().sftp_folderPath
|
pluginPath = configValues.sftp_folderPath
|
||||||
pluginPath = f"{pluginPath}/{plugin}"
|
pluginPath = f"{pluginPath}/{plugin}"
|
||||||
sftp = createSFTPConnection()
|
if not configValues.sftp_useSftp:
|
||||||
sftp.remove(pluginPath)
|
ftp = createFTPConnection()
|
||||||
|
ftp.delete(pluginPath)
|
||||||
|
else:
|
||||||
|
sftp = createSFTPConnection()
|
||||||
|
sftp.remove(pluginPath)
|
||||||
print(f"Removed: {fileName}")
|
print(f"Removed: {fileName}")
|
||||||
i += 1
|
i += 1
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().pathToPluginFolder
|
pluginPath = configValues.pathToPluginFolder
|
||||||
pluginPath = Path(f"{pluginPath}/{plugin}")
|
pluginPath = Path(f"{pluginPath}/{plugin}")
|
||||||
os.remove(pluginPath)
|
os.remove(pluginPath)
|
||||||
print(f"Removed: {fileName}")
|
print(f"Removed: {fileName}")
|
||||||
|
@@ -1,13 +1,18 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import io
|
||||||
|
from zipfile import ZipFile
|
||||||
from urllib.error import HTTPError
|
from urllib.error import HTTPError
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from rich.progress import track
|
||||||
|
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from utils.web_request import doAPIRequest
|
from utils.web_request import doAPIRequest
|
||||||
from handlers.handle_config import checkConfig
|
from handlers.handle_config import configurationValues
|
||||||
from handlers.handle_sftp import createSFTPConnection, sftp_listAll
|
from handlers.handle_sftp import createSFTPConnection, sftp_listAll, sftp_downloadFile
|
||||||
|
from handlers.handle_ftp import createFTPConnection, ftp_listAll, ftp_downloadFile
|
||||||
from plugin.plugin_downloader import getSpecificPackage
|
from plugin.plugin_downloader import getSpecificPackage
|
||||||
|
from utils.utilities import createTempPluginFolder, deleteTempPluginFolder
|
||||||
|
|
||||||
|
|
||||||
def createPluginList():
|
def createPluginList():
|
||||||
@@ -38,6 +43,10 @@ def getFileVersion(pluginName):
|
|||||||
pluginVersion = re.search(r'([\d.]+[.jar]+)', pluginNameFull)
|
pluginVersion = re.search(r'([\d.]+[.jar]+)', pluginNameFull)
|
||||||
pluginVersionFull = pluginVersion.group()
|
pluginVersionFull = pluginVersion.group()
|
||||||
pluginVersionString = pluginVersionFull.replace('.jar', '')
|
pluginVersionString = pluginVersionFull.replace('.jar', '')
|
||||||
|
if pluginVersionString.endswith('.'):
|
||||||
|
pluginVersionString = ''
|
||||||
|
if pluginVersionString == '':
|
||||||
|
pluginVersionString = eggCrackingJar(pluginNameFull)
|
||||||
return pluginVersionString
|
return pluginVersionString
|
||||||
|
|
||||||
|
|
||||||
@@ -56,19 +65,60 @@ def compareVersions(plugin_latest_version, pluginVersion):
|
|||||||
return plugin_is_outdated
|
return plugin_is_outdated
|
||||||
|
|
||||||
|
|
||||||
def checkInstalledPackage(inputSelectedObject="all"):
|
def eggCrackingJar(localJarFileName):
|
||||||
createPluginList()
|
configValues = configurationValues()
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
sftp = createSFTPConnection()
|
if configValues.sftp_useSftp:
|
||||||
pluginList = sftp_listAll(sftp)
|
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)
|
||||||
else:
|
else:
|
||||||
pluginList = os.listdir(checkConfig().pathToPluginFolder)
|
pluginPath = configValues.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 = ''
|
||||||
|
if not configValues.localPluginFolder:
|
||||||
|
deleteTempPluginFolder(tempPluginFolderPath)
|
||||||
|
return pluginVersion
|
||||||
|
|
||||||
|
|
||||||
|
def checkInstalledPackage(inputSelectedObject="all"):
|
||||||
|
configValues = configurationValues()
|
||||||
|
createPluginList()
|
||||||
|
if not configValues.localPluginFolder:
|
||||||
|
if configValues.sftp_useSftp:
|
||||||
|
connection = createSFTPConnection()
|
||||||
|
pluginList = sftp_listAll(connection)
|
||||||
|
else:
|
||||||
|
connection = createFTPConnection()
|
||||||
|
pluginList = ftp_listAll(connection)
|
||||||
|
else:
|
||||||
|
pluginList = os.listdir(configValues.pathToPluginFolder)
|
||||||
i = 0
|
i = 0
|
||||||
oldPackages = 0
|
oldPlugins = 0
|
||||||
print(f"Checking: {inputSelectedObject}")
|
print(oColors.brightBlack + f"Checking: {inputSelectedObject}" + oColors.standardWhite)
|
||||||
print("Index | Name | Installed V. | Latest V. | Update available")
|
print("┌─────┬────────────────────────────────┬──────────────┬──────────────┬───────────────────┐")
|
||||||
|
print("│ No. │ Name │ Installed V. │ Latest V. │ Update available │")
|
||||||
|
print("└─────┴────────────────────────────────┴──────────────┴──────────────┴───────────────────┘")
|
||||||
try:
|
try:
|
||||||
for plugin in pluginList:
|
for plugin in track(pluginList, description="Checking for updates" ,transient=True, complete_style="bright_yellow"):
|
||||||
try:
|
try:
|
||||||
fileName = getFileName(plugin)
|
fileName = getFileName(plugin)
|
||||||
fileVersion = getFileVersion(plugin)
|
fileVersion = getFileVersion(plugin)
|
||||||
@@ -77,10 +127,8 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
|||||||
i += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
pluginIdStr = str(pluginId)
|
pluginIdStr = str(pluginId)
|
||||||
|
|
||||||
if fileVersion == '':
|
if fileVersion == '':
|
||||||
fileVersion = 'N/A'
|
fileVersion = 'N/A'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pluginLatestVersion = INSTALLEDPLUGINLIST[i][2]
|
pluginLatestVersion = INSTALLEDPLUGINLIST[i][2]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
@@ -98,43 +146,58 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
|||||||
pluginIsOutdated = 'N/A'
|
pluginIsOutdated = 'N/A'
|
||||||
|
|
||||||
if pluginIsOutdated == True:
|
if pluginIsOutdated == True:
|
||||||
oldPackages = oldPackages + 1
|
oldPlugins = oldPlugins + 1
|
||||||
|
|
||||||
if inputSelectedObject != "*" and inputSelectedObject != "all":
|
if inputSelectedObject != "*" and inputSelectedObject != "all":
|
||||||
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
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}]".rjust(6), end='')
|
||||||
|
else:
|
||||||
|
print(f" [{1}]".rjust(6), end='')
|
||||||
|
print(" ", end='')
|
||||||
print(f"{fileName}".ljust(33), end='')
|
print(f"{fileName}".ljust(33), end='')
|
||||||
print(f"{fileVersion}".ljust(15), end='')
|
print(f"{fileVersion}".ljust(15), end='')
|
||||||
print(f"{pluginLatestVersion}".ljust(12), end='')
|
print(f"{pluginLatestVersion}".ljust(15), end='')
|
||||||
print(f" {pluginIsOutdated}".ljust(5))
|
print(f"{pluginIsOutdated}".ljust(5) + oColors.standardWhite)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print(f" [{i+1}]".ljust(8), end='')
|
if pluginLatestVersion == 'N/A':
|
||||||
|
print(oColors.brightBlack + f" [{i+1}]".rjust(6), end='')
|
||||||
|
else:
|
||||||
|
print(f" [{i+1}]".rjust(6), end='')
|
||||||
|
print(" ", end='')
|
||||||
print(f"{fileName}".ljust(33), end='')
|
print(f"{fileName}".ljust(33), end='')
|
||||||
print(f"{fileVersion}".ljust(15), end='')
|
print(f"{fileVersion}".ljust(15), end='')
|
||||||
print(f"{pluginLatestVersion}".ljust(12), end='')
|
print(f"{pluginLatestVersion}".ljust(15), end='')
|
||||||
print(f" {pluginIsOutdated}".ljust(5))
|
print(f"{pluginIsOutdated}".ljust(5) + oColors.standardWhite)
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
except TypeError:
|
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)
|
print(oColors.brightYellow + f"Outdated plugins: [{oldPlugins}/{i}]" + oColors.standardWhite)
|
||||||
|
|
||||||
|
|
||||||
def updateInstalledPackage(inputSelectedObject='all'):
|
def updateInstalledPackage(inputSelectedObject='all'):
|
||||||
|
configValues = configurationValues()
|
||||||
createPluginList()
|
createPluginList()
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
sftp = createSFTPConnection()
|
if configValues.sftp_useSftp:
|
||||||
pluginList = sftp_listAll(sftp)
|
connection = createSFTPConnection()
|
||||||
|
pluginList = sftp_listAll(connection)
|
||||||
|
else:
|
||||||
|
connection = createFTPConnection()
|
||||||
|
pluginList = ftp_listAll(connection)
|
||||||
else:
|
else:
|
||||||
pluginList = os.listdir(checkConfig().pathToPluginFolder)
|
pluginList = os.listdir(configValues.pathToPluginFolder)
|
||||||
i = 0
|
i = 0
|
||||||
pluginsUpdated = 0
|
pluginsUpdated = 0
|
||||||
indexNumberUpdated = 0
|
indexNumberUpdated = 0
|
||||||
print(f"Updating: {inputSelectedObject}")
|
print(oColors.brightBlack + f"Updating: {inputSelectedObject}" + oColors.standardWhite)
|
||||||
print("Index | Name | Old V. | New V.")
|
print("┌─────┬────────────────────────────────┬────────────┬──────────┐")
|
||||||
|
print("│ No. │ Name │ Old V. │ New V. │")
|
||||||
|
print("└─────┴────────────────────────────────┴────────────┴──────────┘")
|
||||||
try:
|
try:
|
||||||
for plugin in pluginList:
|
for plugin in track(pluginList, description="Updating" ,transient=True, complete_style="bright_magenta"):
|
||||||
try:
|
try:
|
||||||
fileName = getFileName(plugin)
|
fileName = getFileName(plugin)
|
||||||
fileVersion = getFileVersion(plugin)
|
fileVersion = getFileVersion(plugin)
|
||||||
@@ -147,31 +210,29 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
i += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
pluginIdStr = str(pluginId)
|
pluginIdStr = str(pluginId)
|
||||||
|
if pluginId == None or pluginId == '':
|
||||||
if pluginId == None:
|
|
||||||
print(oColors.brightRed + "Couldn't find plugin id. Sorry :(" + oColors.standardWhite)
|
print(oColors.brightRed + "Couldn't find plugin id. Sorry :(" + oColors.standardWhite)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
||||||
if INSTALLEDPLUGINLIST[i][3] == True:
|
if INSTALLEDPLUGINLIST[i][3] == True:
|
||||||
print(f" [{indexNumberUpdated+1}]".ljust(8), end='')
|
print(f" [{indexNumberUpdated+1}]".rjust(6), end='')
|
||||||
print(f"{fileName}".ljust(30), end='')
|
print(" ", end='')
|
||||||
print(f"{fileVersion}".ljust(8), end='')
|
print(f"{fileName}".ljust(33), end='')
|
||||||
print(" ", end='')
|
print(f"{fileVersion}".ljust(13), end='')
|
||||||
print(f"{latestVersion}".ljust(8))
|
print(f"{latestVersion}".ljust(13))
|
||||||
|
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
if checkConfig().sftp_pathToSeperateDownloadPath is True:
|
if configValues.sftp_seperateDownloadPath is True:
|
||||||
pluginPath = checkConfig().sftp_pathToSeperateDownloadPath
|
pluginPath = configValues.sftp_pathToSeperateDownloadPath
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().sftp_folderPath
|
pluginPath = configValues.sftp_folderPath
|
||||||
pluginPath = Path(f"{pluginPath}/{plugin}")
|
pluginPath = Path(f"{pluginPath}/{plugin}")
|
||||||
sftp = createSFTPConnection()
|
sftp = createSFTPConnection()
|
||||||
indexNumberUpdated += 1
|
indexNumberUpdated += 1
|
||||||
pluginsUpdated += 1
|
pluginsUpdated += 1
|
||||||
try:
|
try:
|
||||||
getSpecificPackage(pluginId, checkConfig().sftp_folderPath)
|
getSpecificPackage(pluginId, configValues.sftp_folderPath)
|
||||||
if checkConfig().sftp_seperateDownloadPath is False:
|
if configValues.sftp_seperateDownloadPath is False:
|
||||||
sftp.remove(pluginPath)
|
sftp.remove(pluginPath)
|
||||||
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)
|
||||||
@@ -179,16 +240,16 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(oColors.brightRed + "Error: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
print(oColors.brightRed + "Error: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
||||||
else:
|
else:
|
||||||
if checkConfig().seperateDownloadPath is True:
|
if configValues.seperateDownloadPath is True:
|
||||||
pluginPath = checkConfig().pathToSeperateDownloadPath
|
pluginPath = configValues.pathToSeperateDownloadPath
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().pathToPluginFolder
|
pluginPath = configValues.pathToPluginFolder
|
||||||
pluginPath = Path(f"{pluginPath}/{plugin}")
|
pluginPath = Path(f"{pluginPath}/{plugin}")
|
||||||
indexNumberUpdated += 1
|
indexNumberUpdated += 1
|
||||||
pluginsUpdated += 1
|
pluginsUpdated += 1
|
||||||
try:
|
try:
|
||||||
getSpecificPackage(pluginId, checkConfig().pathToPluginFolder)
|
getSpecificPackage(pluginId, configValues.pathToPluginFolder)
|
||||||
if checkConfig().seperateDownloadPath is False:
|
if configValues.seperateDownloadPath is False:
|
||||||
os.remove(pluginPath)
|
os.remove(pluginPath)
|
||||||
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)
|
||||||
@@ -203,56 +264,74 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
|
|
||||||
if inputSelectedObject == 'all':
|
if inputSelectedObject == 'all':
|
||||||
if INSTALLEDPLUGINLIST[i][3] == True:
|
if INSTALLEDPLUGINLIST[i][3] == True:
|
||||||
print(f" [{indexNumberUpdated+1}]".ljust(8), end='')
|
print(f" [{indexNumberUpdated+1}]".rjust(6), end='')
|
||||||
print(f"{fileName}".ljust(30), end='')
|
print(" ", end='')
|
||||||
print(f"{fileVersion}".ljust(8), end='')
|
print(f"{fileName}".ljust(33), end='')
|
||||||
print(" ", end='')
|
print(f"{fileVersion}".ljust(13), end='')
|
||||||
print(f"{latestVersion}".ljust(8))
|
print(f"{latestVersion}".ljust(13))
|
||||||
|
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
if checkConfig().sftp_seperateDownloadPath is True:
|
if configValues.sftp_useSftp:
|
||||||
pluginPath = checkConfig().sftp_pathToSeperateDownloadPath
|
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:
|
else:
|
||||||
pluginPath = checkConfig().sftp_folderPath
|
if configValues.sftp_seperateDownloadPath is True:
|
||||||
pluginPath = checkConfig().sftp_folderPath
|
pluginPath = configValues.sftp_pathToSeperateDownloadPath
|
||||||
pluginPath = f"{pluginPath}/{plugin}"
|
else:
|
||||||
sftp = createSFTPConnection()
|
pluginPath = configValues.sftp_folderPath
|
||||||
indexNumberUpdated += 1
|
pluginPath = f"{pluginPath}/{plugin}"
|
||||||
pluginsUpdated += 1
|
ftp = createFTPConnection()
|
||||||
try:
|
indexNumberUpdated += 1
|
||||||
getSpecificPackage(pluginId, checkConfig().sftp_folderPath)
|
pluginsUpdated += 1
|
||||||
if checkConfig().sftp_seperateDownloadPath is False:
|
try:
|
||||||
sftp.remove(pluginPath)
|
getSpecificPackage(pluginId, configValues.sftp_folderPath)
|
||||||
except HTTPError as err:
|
if configValues.sftp_seperateDownloadPath is False:
|
||||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
ftp.delete(pluginPath)
|
||||||
pluginsUpdated -= 1
|
except HTTPError as err:
|
||||||
except FileNotFoundError:
|
print(oColors.brightRed + f"HTTPError: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||||
print(oColors.brightRed + f"Error: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
pluginsUpdated -= 1
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(oColors.brightRed + f"FileNotFoundError: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if checkConfig().seperateDownloadPath is True:
|
if configValues.seperateDownloadPath is True:
|
||||||
pluginPath = checkConfig().pathToSeperateDownloadPath
|
pluginPath = configValues.pathToSeperateDownloadPath
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().pathToPluginFolder
|
pluginPath = configValues.pathToPluginFolder
|
||||||
pluginPath = Path(f"{pluginPath}/{plugin}")
|
pluginPath = Path(f"{pluginPath}/{plugin}")
|
||||||
indexNumberUpdated += 1
|
indexNumberUpdated += 1
|
||||||
pluginsUpdated += 1
|
pluginsUpdated += 1
|
||||||
try:
|
try:
|
||||||
getSpecificPackage(pluginId, checkConfig().pathToPluginFolder)
|
getSpecificPackage(pluginId, configValues.pathToPluginFolder)
|
||||||
if checkConfig().seperateDownloadPath is False:
|
if configValues.seperateDownloadPath is False:
|
||||||
os.remove(pluginPath)
|
os.remove(pluginPath)
|
||||||
except HTTPError as err:
|
except HTTPError as err:
|
||||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
print(oColors.brightRed + f"HTTPError: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||||
pluginsUpdated -= 1
|
pluginsUpdated -= 1
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(oColors.brightRed + f"Error: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
print(oColors.brightRed + f"FileNotFoundError: Old plugin file coulnd't be deleted" + oColors.standardWhite)
|
||||||
|
|
||||||
i = i + 1
|
i = i + 1
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print(oColors.brightRed + "Aborted updating for plugins." + oColors.standardWhite)
|
print(oColors.brightRed + "Error occured: Aborted updating for plugins." + oColors.standardWhite)
|
||||||
print(f"[{pluginsUpdated}/{i}] Plugins updated")
|
print(oColors.brightYellow + f"Plugins updated: [{pluginsUpdated}/{i}]" + oColors.standardWhite)
|
||||||
if inputSelectedObject =='all' and pluginsUpdated == 0:
|
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):
|
def getInstalledPlugin(localFileName, localFileVersion):
|
||||||
|
@@ -4,17 +4,23 @@ from urllib.error import HTTPError
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from handlers.handle_sftp import createSFTPConnection, sftp_listFilesInServerRoot
|
from handlers.handle_sftp import createSFTPConnection, sftp_listFilesInServerRoot
|
||||||
from handlers.handle_config import checkConfig
|
from handlers.handle_ftp import createFTPConnection, ftp_listFilesInServerRoot
|
||||||
|
from handlers.handle_config import configurationValues
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from serverjar.serverjar_paper import paperCheckForUpdate, papermc_downloader
|
from serverjar.serverjar_paper import paperCheckForUpdate, papermc_downloader
|
||||||
|
|
||||||
|
|
||||||
def checkInstalledServerjar():
|
def checkInstalledServerjar():
|
||||||
if not checkConfig().localPluginFolder:
|
configValues = configurationValues()
|
||||||
sftp = createSFTPConnection()
|
if not configValues.localPluginFolder:
|
||||||
serverRootList = sftp_listFilesInServerRoot(sftp)
|
if not configValues.sftp_useSftp:
|
||||||
|
ftp = createFTPConnection()
|
||||||
|
serverRootList = ftp_listFilesInServerRoot(ftp)
|
||||||
|
else:
|
||||||
|
sftp = createSFTPConnection()
|
||||||
|
serverRootList = sftp_listFilesInServerRoot(sftp)
|
||||||
else:
|
else:
|
||||||
serverRootList = os.path.dirname(checkConfig().pathToPluginFolder)
|
serverRootList = os.path.dirname(configValues.pathToPluginFolder)
|
||||||
serverRootList = os.listdir(serverRootList)
|
serverRootList = os.listdir(serverRootList)
|
||||||
installedServerjarFullName = None
|
installedServerjarFullName = None
|
||||||
try:
|
try:
|
||||||
@@ -34,7 +40,7 @@ def checkInstalledServerjar():
|
|||||||
print(oColors.brightRed + "Aborting the process." + oColors.standardWhite)
|
print(oColors.brightRed + "Aborting the process." + oColors.standardWhite)
|
||||||
input("Press any key + enter to exit...")
|
input("Press any key + enter to exit...")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
print(oColors.brightBlack + f"Checking: {installedServerjarFullName}" + oColors.standardWhite)
|
||||||
if 'paper' in installedServerjarFullName:
|
if 'paper' in installedServerjarFullName:
|
||||||
paperCheckForUpdate(installedServerjarFullName)
|
paperCheckForUpdate(installedServerjarFullName)
|
||||||
|
|
||||||
@@ -44,19 +50,20 @@ def checkInstalledServerjar():
|
|||||||
|
|
||||||
|
|
||||||
def updateServerjar(serverJarBuild='latest'):
|
def updateServerjar(serverJarBuild='latest'):
|
||||||
|
configValues = configurationValues()
|
||||||
try:
|
try:
|
||||||
if serverJarBuild == None:
|
if serverJarBuild == None:
|
||||||
serverJarBuild = 'latest'
|
serverJarBuild = 'latest'
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
sftp = createSFTPConnection()
|
sftp = createSFTPConnection()
|
||||||
serverRootPath = checkConfig().sftp_folderPath
|
serverRootPath = configValues.sftp_folderPath
|
||||||
serverRootPath = Path(str(serverRootPath).replace(r'/plugins', ''))
|
serverRootPath = Path(str(serverRootPath).replace(r'/plugins', ''))
|
||||||
serverRootList = sftp_listFilesInServerRoot(sftp)
|
serverRootList = sftp_listFilesInServerRoot(sftp)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
serverRoot = os.path.dirname(checkConfig().pathToPluginFolder)
|
serverRoot = os.path.dirname(configValues.pathToPluginFolder)
|
||||||
serverRootList = os.listdir(serverRoot)
|
serverRootList = os.listdir(serverRoot)
|
||||||
serverRootPath = checkConfig().pathToPluginFolder
|
serverRootPath = configValues.pathToPluginFolder
|
||||||
helpPath = Path('/plugins')
|
helpPath = Path('/plugins')
|
||||||
helpPathstr = str(helpPath)
|
helpPathstr = str(helpPath)
|
||||||
serverRootPath = Path(str(serverRootPath).replace(helpPathstr, ''))
|
serverRootPath = Path(str(serverRootPath).replace(helpPathstr, ''))
|
||||||
@@ -90,8 +97,8 @@ def updateServerjar(serverJarBuild='latest'):
|
|||||||
serverJarPath = Path(f"{serverRootPath}/{installedServerjarFullName}")
|
serverJarPath = Path(f"{serverRootPath}/{installedServerjarFullName}")
|
||||||
|
|
||||||
if 'paper' in installedServerjarFullName:
|
if 'paper' in installedServerjarFullName:
|
||||||
print(f"Updating Paper to build: {serverJarBuild}")
|
print(oColors.brightBlack + f"Updating Paper to build: {serverJarBuild}" + oColors.standardWhite)
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
try:
|
try:
|
||||||
papermc_downloader(serverJarBuild, installedServerjarFullName)
|
papermc_downloader(serverJarBuild, installedServerjarFullName)
|
||||||
sftp.remove(serverJarPath)
|
sftp.remove(serverJarPath)
|
||||||
|
@@ -3,11 +3,13 @@ import sys
|
|||||||
import re
|
import re
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from rich.console import Console
|
||||||
|
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from utils.web_request import doAPIRequest
|
from utils.web_request import doAPIRequest
|
||||||
from handlers.handle_sftp import sftp_upload_server_jar, sftp_cdPluginDir, createSFTPConnection
|
from handlers.handle_sftp import createSFTPConnection, sftp_upload_server_jar
|
||||||
from handlers.handle_config import checkConfig
|
from handlers.handle_ftp import createFTPConnection, ftp_upload_server_jar
|
||||||
|
from handlers.handle_config import configurationValues
|
||||||
from utils.utilities import createTempPluginFolder, deleteTempPluginFolder, calculateFileSizeMb
|
from utils.utilities import createTempPluginFolder, deleteTempPluginFolder, calculateFileSizeMb
|
||||||
|
|
||||||
|
|
||||||
@@ -107,23 +109,25 @@ def paperCheckForUpdate(installedServerjarFullName):
|
|||||||
paperLatestBuild = findLatestBuild(versionGroup)
|
paperLatestBuild = findLatestBuild(versionGroup)
|
||||||
paperVersionBehind = versionBehind(paperInstalledBuild, paperLatestBuild)
|
paperVersionBehind = versionBehind(paperInstalledBuild, paperLatestBuild)
|
||||||
|
|
||||||
print(f"Paper for {mcVersion}")
|
print("┌─────┬────────────────────────────────┬──────────────┬──────────────┬───────────────────┐")
|
||||||
print("Index | Name | Installed V. | Latest V. | Versions behind ")
|
print("│ No. │ Name │ Installed V. │ Latest V. │ Versions behind │")
|
||||||
print(f" [1]".ljust(8), end='')
|
print("└─────┴────────────────────────────────┴──────────────┴──────────────┴───────────────────┘")
|
||||||
print(f"paper".ljust(21), end='')
|
print(" [1]".rjust(6), end='')
|
||||||
print(f"{paperInstalledBuild}".ljust(8), end='')
|
print(" ", end='')
|
||||||
print(" ", end='')
|
print("paper".ljust(33), end='')
|
||||||
print(f"{paperLatestBuild}".ljust(8), end='')
|
print(f"{paperInstalledBuild}".ljust(15), end='')
|
||||||
print(" ", end='')
|
print(f"{paperLatestBuild}".ljust(15), end='')
|
||||||
print(f"{paperVersionBehind}".ljust(8))
|
print(f"{paperVersionBehind}".ljust(8))
|
||||||
|
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', installedServerjarName=None, mcVersion=None):
|
||||||
if checkConfig().localPluginFolder == False:
|
configValues = configurationValues()
|
||||||
|
if configValues.localPluginFolder == False:
|
||||||
downloadPath = createTempPluginFolder()
|
downloadPath = createTempPluginFolder()
|
||||||
else:
|
else:
|
||||||
downloadPath = checkConfig().pathToPluginFolder
|
downloadPath = configValues.pathToPluginFolder
|
||||||
helpPath = Path('/plugins')
|
helpPath = Path('/plugins')
|
||||||
helpPathstr = str(helpPath)
|
helpPathstr = str(helpPath)
|
||||||
downloadPath = Path(str(downloadPath).replace(helpPathstr, ''))
|
downloadPath = Path(str(downloadPath).replace(helpPathstr, ''))
|
||||||
@@ -149,22 +153,27 @@ def papermc_downloader(paperBuild='latest', installedServerjarName=None, mcVersi
|
|||||||
|
|
||||||
downloadPackagePath = Path(f"{downloadPath}/{downloadFileName}")
|
downloadPackagePath = Path(f"{downloadPath}/{downloadFileName}")
|
||||||
|
|
||||||
if checkConfig().localPluginFolder == False:
|
if configValues.localPluginFolder == False:
|
||||||
downloadPath = createTempPluginFolder()
|
downloadPath = createTempPluginFolder()
|
||||||
|
|
||||||
url = f"https://papermc.io/api/v2/projects/paper/versions/{mcVersion}/builds/{paperBuild}/downloads/{downloadFileName}"
|
url = f"https://papermc.io/api/v2/projects/paper/versions/{mcVersion}/builds/{paperBuild}/downloads/{downloadFileName}"
|
||||||
remotefile = urllib.request.urlopen(url)
|
remotefile = urllib.request.urlopen(url)
|
||||||
filesize = remotefile.info()['Content-Length']
|
filesize = remotefile.info()['Content-Length']
|
||||||
print(f"Starting Paper-{paperBuild} download for {mcVersion}...")
|
print(f"Getting Paper {paperBuild} for {mcVersion}")
|
||||||
urllib.request.urlretrieve(url, downloadPackagePath)
|
console = Console()
|
||||||
|
with console.status("Downloading...", spinner='line', spinner_style='bright_magenta') as status:
|
||||||
|
urllib.request.urlretrieve(url, downloadPackagePath)
|
||||||
filesizeData = calculateFileSizeMb(filesize)
|
filesizeData = calculateFileSizeMb(filesize)
|
||||||
|
print("Downloaded " + (str(filesizeData)).rjust(9) + f" MB here {downloadPackagePath}")
|
||||||
print(f"Downloadsize: {filesizeData} MB")
|
if not configValues.localPluginFolder:
|
||||||
print(f"File downloaded here: {downloadPackagePath}")
|
if not configValues.sftp_useSftp:
|
||||||
if not checkConfig().localPluginFolder:
|
ftpSession = createFTPConnection()
|
||||||
sftpSession = createSFTPConnection()
|
ftp_upload_server_jar(ftpSession, downloadPackagePath)
|
||||||
sftp_upload_server_jar(sftpSession, downloadPackagePath)
|
else:
|
||||||
|
sftpSession = createSFTPConnection()
|
||||||
|
sftp_upload_server_jar(sftpSession, downloadPackagePath)
|
||||||
|
|
||||||
deleteTempPluginFolder(downloadPath)
|
deleteTempPluginFolder(downloadPath)
|
||||||
|
|
||||||
print(oColors.brightGreen + "Downloaded successfully " + oColors.standardWhite + f"Paper-{paperBuild}" + \
|
print(oColors.brightGreen + "Downloaded successfully " + oColors.standardWhite + f"Paper {paperBuild}" + \
|
||||||
oColors.brightGreen + " for " + oColors.standardWhite + f"{mcVersion}" + oColors.standardWhite)
|
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
|
# https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
|
||||||
class oColors:
|
class oColors:
|
||||||
standardWhite = "\033[0m"
|
standardWhite = "\033[0m"
|
||||||
brightYellow = "\033[93m"
|
brightBlack = "\033[90m"
|
||||||
brightMagenta = "\033[95m"
|
|
||||||
brightRed = "\033[91m"
|
brightRed = "\033[91m"
|
||||||
brightGreen = "\033[92m"
|
brightGreen = "\033[92m"
|
||||||
darkMagenta = "\033[35m"
|
brightYellow = "\033[93m"
|
||||||
|
brightMagenta = "\033[95m"
|
||||||
|
|
||||||
|
|
||||||
def printLogo():
|
def printLogo():
|
||||||
@@ -72,9 +72,12 @@ def printLogo():
|
|||||||
oColors.standardWhite)
|
oColors.standardWhite)
|
||||||
print()
|
print()
|
||||||
print()
|
print()
|
||||||
print(oColors.brightYellow + " [" + oColors.darkMagenta + "By Neocky" +
|
print(oColors.brightBlack + " ┌────────────────────────────────────┐" + oColors.standardWhite)
|
||||||
oColors.brightYellow + "] " + oColors.standardWhite)
|
print(oColors.brightBlack + " │ [" + oColors.brightMagenta + "By Neocky" +oColors.brightBlack +
|
||||||
print()
|
"] │ " + oColors.standardWhite)
|
||||||
|
print(oColors.brightBlack + " │ " + oColors.brightMagenta + "https://github.com/Neocky/pluGET" + oColors.brightBlack +
|
||||||
|
" │ " + oColors.standardWhite)
|
||||||
|
print(oColors.brightBlack + " └────────────────────────────────────┘" + oColors.standardWhite)
|
||||||
|
|
||||||
|
|
||||||
def printHorizontalLine():
|
def printHorizontalLine():
|
||||||
|
@@ -6,24 +6,102 @@ import requests
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from utils.consoleoutput import oColors
|
from utils.consoleoutput import oColors
|
||||||
from handlers.handle_config import checkConfig
|
from handlers.handle_config import configurationValues
|
||||||
from handlers.handle_sftp import createSFTPConnection
|
from handlers.handle_sftp import createSFTPConnection
|
||||||
|
from handlers.handle_ftp import createFTPConnection
|
||||||
|
|
||||||
|
|
||||||
def getHelp():
|
def getHelp():
|
||||||
print(oColors.brightYellow+ "Need help?" + oColors.standardWhite)
|
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("https://github.com/Neocky/pluGET")
|
||||||
print("Or go to the official discord.")
|
print("Or go to the official discord.")
|
||||||
print("The link for discord can also be found on Github!")
|
print("The link for discord can also be found on Github!")
|
||||||
|
|
||||||
|
|
||||||
def check_local_plugin_folder():
|
def getCommandHelp(optionalParams):
|
||||||
if checkConfig().localPluginFolder:
|
if optionalParams == None:
|
||||||
if checkConfig().seperateDownloadPath:
|
optionalParams = 'all'
|
||||||
pluginFolderPath = checkConfig().pathToSeperateDownloadPath
|
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:
|
else:
|
||||||
pluginFolderPath = checkConfig().pathToPluginFolder
|
print(oColors.brightRed + "Error: Help for Command not found. Please try again. :(" + oColors.standardWhite)
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
def check_local_plugin_folder():
|
||||||
|
configValues = configurationValues()
|
||||||
|
if configValues.localPluginFolder:
|
||||||
|
if configValues.seperateDownloadPath:
|
||||||
|
pluginFolderPath = configValues.pathToSeperateDownloadPath
|
||||||
|
else:
|
||||||
|
pluginFolderPath = configValues.pathToPluginFolder
|
||||||
|
|
||||||
if not os.path.isdir(pluginFolderPath):
|
if not os.path.isdir(pluginFolderPath):
|
||||||
print(oColors.brightRed + "Plugin folder coulnd*t be found. Creating one..." + oColors.standardWhite)
|
print(oColors.brightRed + "Plugin folder coulnd*t be found. Creating one..." + oColors.standardWhite)
|
||||||
@@ -53,19 +131,24 @@ def apiTest():
|
|||||||
|
|
||||||
|
|
||||||
def check_requirements():
|
def check_requirements():
|
||||||
|
configValues = configurationValues()
|
||||||
apiTest()
|
apiTest()
|
||||||
check_local_plugin_folder()
|
check_local_plugin_folder()
|
||||||
if not checkConfig().localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
createSFTPConnection()
|
if configValues.sftp_useSftp:
|
||||||
|
createSFTPConnection()
|
||||||
|
else:
|
||||||
|
createFTPConnection()
|
||||||
|
|
||||||
|
|
||||||
def createTempPluginFolder():
|
def createTempPluginFolder():
|
||||||
tempPluginFolder = Path("./TempSFTPUploadFolder")
|
configValues = configurationValues()
|
||||||
|
tempPluginFolder = Path("./TempSFTPFolder")
|
||||||
if not os.path.isdir(tempPluginFolder):
|
if not os.path.isdir(tempPluginFolder):
|
||||||
try:
|
try:
|
||||||
os.mkdir(tempPluginFolder)
|
os.mkdir(tempPluginFolder)
|
||||||
except OSError:
|
except OSError:
|
||||||
print(oColors.brightRed + "Creation of directory %s failed" % checkConfig().pathToPluginFolder)
|
print(oColors.brightRed + "Creation of directory %s failed" % configValues.pathToPluginFolder)
|
||||||
print(oColors.brightRed + "Please check the config file!" + oColors.standardWhite)
|
print(oColors.brightRed + "Please check the config file!" + oColors.standardWhite)
|
||||||
input("Press any key + enter to exit...")
|
input("Press any key + enter to exit...")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
@@ -84,3 +167,9 @@ def calculateFileSizeMb(downloadFileSize):
|
|||||||
fileSizeMb = fileSizeDownload / 1024 / 1024
|
fileSizeMb = fileSizeDownload / 1024 / 1024
|
||||||
roundedFileSize = round(fileSizeMb, 2)
|
roundedFileSize = round(fileSizeMb, 2)
|
||||||
return roundedFileSize
|
return roundedFileSize
|
||||||
|
|
||||||
|
def calculateFileSizeKb(downloadFileSize):
|
||||||
|
fileSizeDownload = int(downloadFileSize)
|
||||||
|
fileSizeKb = fileSizeDownload / 1024
|
||||||
|
roundedFileSize = round(fileSizeKb, 2)
|
||||||
|
return roundedFileSize
|
||||||
|
@@ -3,7 +3,7 @@ import requests
|
|||||||
|
|
||||||
|
|
||||||
def doAPIRequest(url):
|
def doAPIRequest(url):
|
||||||
headers = {'user-agent': 'pluGET'}
|
headers = {'user-agent': 'pluGET/1.0'}
|
||||||
response = requests.get(url, headers=headers)
|
response = requests.get(url, headers=headers)
|
||||||
packageDetails = response.json()
|
packageDetails = response.json()
|
||||||
return packageDetails
|
return packageDetails
|
||||||
|
Reference in New Issue
Block a user