Compare commits

...

11 Commits

Author SHA1 Message Date
Neocky
662f303935 Catched FileNotfoundError & Plugins updated will now display correctly
Changes:
- Catched file not found error
- Plugins updated
- Updated wrong index numbers when updating
2021-03-14 20:21:26 +01:00
Neocky
053a67e2d8 Update README.md 2021-03-14 19:38:47 +01:00
Neocky
e37840e665 Update README.md 2021-03-14 19:38:22 +01:00
Neocky
ac9b89de4f Edited license badge link 2021-03-14 19:15:06 +01:00
Neocky
f704b29ff9 Added latest release badge 2021-03-14 19:12:56 +01:00
Neocky
12f28107de Updated link 2021-03-14 18:55:39 +01:00
Neocky
b7e9673c80 Updated link 2021-03-14 18:51:43 +01:00
Neocky
0e4abad762 Update README.md 2021-03-14 18:02:09 +01:00
Neocky
972daf5687 Update README.md 2021-03-14 17:53:41 +01:00
Neocky
540a355d3d Added hit counter and removed star counter 2021-03-14 14:14:12 +01:00
Neocky
7e9b5850be Fixed big duplicate array issue for a plugin; Added seperate download path
Changes:
- Fixed big issue where two arrays would be created for a plugin and then everything else would fail
- added seperate location for downloaded files
2021-03-14 13:25:13 +01:00
6 changed files with 118 additions and 38 deletions

View File

@@ -1,4 +1,5 @@
<p align="center">
<img src="https://i.ibb.co/JyCxnQn/logoreal.png" alt="pluGET" border="0"></a>
</p>
@@ -8,14 +9,15 @@
</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/downloads/Neocky/pluGET/total" alt="downloads" 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>
</p>
# pluGET
# pluGET
[![HitCount](http://hits.dwyl.com/Neocky/pluGET.svg)](http://hits.dwyl.com/Neocky/pluGET)
A powerfull package manager which handles [Plugins](https://www.spigotmc.org/resources/) for minecraft servers.

View File

@@ -22,18 +22,32 @@ def checkConfig():
config.read("config.ini")
localPluginFolder = config['General']['LocalPluginFolder']
pathToPluginFolder = config['General']['PathToPluginFolder']
seperateDownloadPath = config['General']['SeperateDownloadPath']
pathToSeperateDownloadPath = 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']['PluginFolderForUpload']
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
@@ -45,13 +59,21 @@ def createConfig():
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'][';_'] = '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['SFTP - Remote Server'] = {}
config['SFTP - Remote Server']['Server'] = '0.0.0.0'
config['SFTP - Remote Server']['Username'] = 'user'
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']['Port'] = '22'
config['SFTP - Remote Server']['PluginFolderForUpload'] = '.\\plugins'
config['SFTP - Remote Server']['PluginFolderOnServer'] = '.\\plugins'
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']['SeperateDownloadPath'] = 'False'
config['SFTP - Remote Server']['PathToSeperateDownloadPath'] = '.\\plugins'
with open('./config.ini', 'w') as configfile:
config.write(configfile)

View File

@@ -30,10 +30,18 @@ def handleInput(inputCommand, inputSelectedObject, inputParams):
if inputCommand == 'get':
if inputSelectedObject.isdigit():
if not checkConfig().localPluginFolder:
getSpecificPackage(inputSelectedObject, checkConfig().sftp_folderPath, inputParams)
if checkConfig().sftp_seperateDownloadPath is True:
pluginPath = checkConfig().sftp_pathToSeperateDownloadPath
else:
pluginPath = checkConfig().sftp_folderPath
getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
break
else:
getSpecificPackage(inputSelectedObject, checkConfig().pathToPluginFolder, inputParams)
if checkConfig().seperateDownloadPath is True:
pluginPath = checkConfig().pathToSeperateDownloadPath
else:
pluginPath = checkConfig().pathToPluginFolder
getSpecificPackage(inputSelectedObject, pluginPath, inputParams)
break
else:
searchPackage(inputSelectedObject)

View File

@@ -116,15 +116,9 @@ def getSpecificPackage(ressourceId, downloadPath, inputPackageVersion='latest'):
downloadPackagePath = 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':

View File

@@ -1,5 +1,6 @@
import os
import re
from urllib.error import HTTPError
from utils.consoleoutput import oColors
from utils.web_request import doAPIRequest
@@ -127,6 +128,7 @@ def updateInstalledPackage(inputSelectedObject='all'):
pluginList = os.listdir(checkConfig().pathToPluginFolder)
i = 0
pluginsUpdated = 0
indexNumberUpdated = 0
print(f"Updating: {inputSelectedObject}")
print("Index | Name | Old V. | New V.")
try:
@@ -148,25 +150,47 @@ def updateInstalledPackage(inputSelectedObject='all'):
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
if INSTALLEDPLUGINLIST[i][3] == True:
print(f" [{pluginsUpdated+1}]".ljust(8), end='')
print(f" [{indexNumberUpdated+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
if checkConfig().sftp_pathToSeperateDownloadPath is True:
pluginPath = checkConfig().sftp_pathToSeperateDownloadPath
else:
pluginPath = checkConfig().sftp_folderPath
pluginPath = 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 + f"Error: Old plugin file coulnd't be deleted" + oColors.standardWhite)
else:
pluginPath = checkConfig().pathToPluginFolder
if checkConfig().seperateDownloadPath is True:
pluginPath = checkConfig().pathToSeperateDownloadPath
else:
pluginPath = checkConfig().pathToPluginFolder
pluginPath = f"{pluginPath}\\{plugin}"
os.remove(pluginPath)
getSpecificPackage(pluginId, checkConfig().pathToPluginFolder)
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}")
@@ -175,26 +199,50 @@ def updateInstalledPackage(inputSelectedObject='all'):
if inputSelectedObject == 'all':
if INSTALLEDPLUGINLIST[i][3] == True:
print(f" [{pluginsUpdated+1}]".ljust(8), end='')
print(f" [{indexNumberUpdated+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:
if checkConfig().sftp_seperateDownloadPath is True:
pluginPath = checkConfig().sftp_pathToSeperateDownloadPath
else:
pluginPath = checkConfig().sftp_folderPath
pluginPath = checkConfig().sftp_folderPath
pluginPath = 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 + f"Error: Old plugin file coulnd't be deleted" + oColors.standardWhite)
else:
pluginPath = checkConfig().pathToPluginFolder
if checkConfig().seperateDownloadPath is True:
pluginPath = checkConfig().pathToSeperateDownloadPath
else:
pluginPath = checkConfig().pathToPluginFolder
pluginPath = f"{pluginPath}\\{plugin}"
os.remove(pluginPath)
getSpecificPackage(pluginId, checkConfig().pathToPluginFolder)
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)
@@ -226,14 +274,15 @@ def getInstalledPlugin(localFileName, localFileVersion):
plugin_is_outdated = compareVersions(plugin_latest_version, updateVersion)
addToPluginList(pID, updateId, plugin_latest_version , plugin_is_outdated)
break
i = i + 1
else:
pID = None
updateId = None
plugin_latest_version = None
plugin_is_outdated = None
addToPluginList(pID, updateId, plugin_latest_version , plugin_is_outdated)
if plugin_match_found != True:
pID = None
updateId = None
plugin_latest_version = None
plugin_is_outdated = None
addToPluginList(pID, updateId, plugin_latest_version , plugin_is_outdated)
return pluginID

View File

@@ -19,17 +19,22 @@ def getHelp():
def check_local_plugin_folder():
if checkConfig().localPluginFolder:
if not os.path.isdir(checkConfig().pathToPluginFolder):
if checkConfig().seperateDownloadPath:
pluginFolderPath = checkConfig().pathToSeperateDownloadPath
else:
pluginFolderPath = checkConfig().pathToPluginFolder
if not os.path.isdir(pluginFolderPath):
print(oColors.brightRed + "Plugin folder coulnd*t be found. Creating one..." + oColors.standardWhite)
try:
os.mkdir(checkConfig().pathToPluginFolder)
os.mkdir(pluginFolderPath)
except OSError:
print(oColors.brightRed + "Creation of directory %s failed" % checkConfig().pathToPluginFolder)
print(oColors.brightRed + "Creation of directory %s failed" % pluginFolderPath)
print(oColors.brightRed + "Please check the config file!" + oColors.standardWhite)
input("Press any key + enter to exit...")
sys.exit()
else:
print("Created directory %s" % checkConfig().pathToPluginFolder)
print("Created directory %s" % pluginFolderPath)
def apiTest():