mirror of
https://github.com/Neocky/pluGET.git
synced 2024-04-29 16:12:30 +00:00
Removed error when yaml file is in plugin folder & created file in which the remove plugin function comes
This commit is contained in:
parent
db13b79a39
commit
1aae4bf9d3
@ -6,6 +6,7 @@ from plugin_updatechecker import updateInstalledPackage, checkInstalledPackage
|
|||||||
from handle_config import checkConfig
|
from handle_config import checkConfig
|
||||||
from utilities import getHelp, check_requirements
|
from utilities import getHelp, check_requirements
|
||||||
from handle_sftp import createSFTPConnection, sftp_showPlugins
|
from handle_sftp import createSFTPConnection, sftp_showPlugins
|
||||||
|
from plugin_remover import removePlugin
|
||||||
|
|
||||||
def createInputLists():
|
def createInputLists():
|
||||||
global COMMANDLIST
|
global COMMANDLIST
|
||||||
@ -14,7 +15,8 @@ def createInputLists():
|
|||||||
'update',
|
'update',
|
||||||
'check',
|
'check',
|
||||||
'exit',
|
'exit',
|
||||||
'help'
|
'help',
|
||||||
|
'remove'
|
||||||
]
|
]
|
||||||
global INPUTSELECTEDOBJECT
|
global INPUTSELECTEDOBJECT
|
||||||
INPUTSELECTEDOBJECT = [
|
INPUTSELECTEDOBJECT = [
|
||||||
@ -46,9 +48,8 @@ def handleInput(inputCommand, inputSelectedObject, inputParams):
|
|||||||
if inputCommand == 'help':
|
if inputCommand == 'help':
|
||||||
getHelp()
|
getHelp()
|
||||||
break
|
break
|
||||||
if inputCommand == 'sftp':
|
if inputCommand == 'remove':
|
||||||
sftp = createSFTPConnection()
|
removePlugin(inputSelectedObject)
|
||||||
sftp_showPlugins(sftp)
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print(oColors.brightRed + "Command not found. Please try again." + oColors.standardWhite)
|
print(oColors.brightRed + "Command not found. Please try again." + oColors.standardWhite)
|
||||||
|
@ -104,7 +104,6 @@ def downloadSpecificVersion(ressourceId, downloadPath, versionID='latest'):
|
|||||||
if not checkConfig().localPluginFolder:
|
if not checkConfig().localPluginFolder:
|
||||||
print(downloadPath)
|
print(downloadPath)
|
||||||
sftpSession = createSFTPConnection()
|
sftpSession = createSFTPConnection()
|
||||||
#sftp_cdPluginDir(sftpSession)
|
|
||||||
sftp_upload_file(sftpSession, downloadPath)
|
sftp_upload_file(sftpSession, downloadPath)
|
||||||
|
|
||||||
|
|
||||||
|
15
src/plugin_remover.py
Normal file
15
src/plugin_remover.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import os
|
||||||
|
import re
|
||||||
|
from handle_config import checkConfig
|
||||||
|
from handle_sftp import createSFTPConnection, sftp_listAll
|
||||||
|
|
||||||
|
def removePlugin(pluginToRemove):
|
||||||
|
if not checkConfig().localPluginFolder:
|
||||||
|
sftp = createSFTPConnection()
|
||||||
|
pluginList = sftp_listAll(sftp)
|
||||||
|
else:
|
||||||
|
pluginList = os.listdir(checkConfig().pathToPluginFolder)
|
||||||
|
|
||||||
|
for plugin in pluginList:
|
||||||
|
#pluginVersion = re.search(pluginToRemove, pluginNameFull)
|
||||||
|
print(plugin)
|
@ -20,9 +20,9 @@ def addToPluginList(pluginId, versionId, plugin_is_outdated):
|
|||||||
|
|
||||||
def getFileName(pluginName):
|
def getFileName(pluginName):
|
||||||
pluginNameFull = pluginName
|
pluginNameFull = pluginName
|
||||||
pluginVersion = re.search(r'([\d.]+[.jar]+)', pluginNameFull) #errors out when for example .yaml file in plugins
|
pluginVersion = re.search(r'([\d.]+[.jar]+)', pluginNameFull)
|
||||||
try:
|
try:
|
||||||
pluginVersionFull = pluginVersion.group() # TODO fix this
|
pluginVersionFull = pluginVersion.group()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pluginVersionFull = pluginVersion
|
pluginVersionFull = pluginVersion
|
||||||
pluginNameOnlyy = pluginNameFull.replace(pluginVersionFull, '')
|
pluginNameOnlyy = pluginNameFull.replace(pluginVersionFull, '')
|
||||||
@ -62,9 +62,12 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
|||||||
print("Index / Name / Installed Version / Update available")
|
print("Index / Name / Installed Version / Update available")
|
||||||
|
|
||||||
for plugin in pluginList:
|
for plugin in pluginList:
|
||||||
|
try:
|
||||||
fileName = getFileName(plugin)
|
fileName = getFileName(plugin)
|
||||||
fileVersion = getFileVersion(plugin)
|
fileVersion = getFileVersion(plugin)
|
||||||
pluginId = getInstalledPlugin(fileName, fileVersion)
|
pluginId = getInstalledPlugin(fileName, fileVersion)
|
||||||
|
except TypeError:
|
||||||
|
continue
|
||||||
pluginIdStr = str(pluginId)
|
pluginIdStr = str(pluginId)
|
||||||
|
|
||||||
if fileVersion == '':
|
if fileVersion == '':
|
||||||
@ -100,11 +103,15 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
else:
|
else:
|
||||||
pluginList = os.listdir(checkConfig().pathToPluginFolder)
|
pluginList = os.listdir(checkConfig().pathToPluginFolder)
|
||||||
i = 0
|
i = 0
|
||||||
|
pluginsUpdated = 0
|
||||||
for plugin in pluginList:
|
for plugin in pluginList:
|
||||||
print(plugin)
|
print(plugin)
|
||||||
|
try:
|
||||||
fileName = getFileName(plugin)
|
fileName = getFileName(plugin)
|
||||||
fileVersion = getFileVersion(plugin)
|
fileVersion = getFileVersion(plugin)
|
||||||
pluginId = getInstalledPlugin(fileName, fileVersion)
|
pluginId = getInstalledPlugin(fileName, fileVersion)
|
||||||
|
except TypeError:
|
||||||
|
continue
|
||||||
pluginIdStr = str(pluginId)
|
pluginIdStr = str(pluginId)
|
||||||
|
|
||||||
if pluginId == None:
|
if pluginId == None:
|
||||||
@ -119,11 +126,13 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
sftp = createSFTPConnection()
|
sftp = createSFTPConnection()
|
||||||
sftp.remove(pluginPath)
|
sftp.remove(pluginPath)
|
||||||
getSpecificPackage(pluginId, checkConfig().sftp_folderPath)
|
getSpecificPackage(pluginId, checkConfig().sftp_folderPath)
|
||||||
|
pluginsUpdated += 1
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().pathToPluginFolder
|
pluginPath = checkConfig().pathToPluginFolder
|
||||||
pluginPath = f"{pluginPath}\\{plugin}"
|
pluginPath = f"{pluginPath}\\{plugin}"
|
||||||
os.remove(pluginPath)
|
os.remove(pluginPath)
|
||||||
getSpecificPackage(pluginId, checkConfig().pathToPluginFolder)
|
getSpecificPackage(pluginId, checkConfig().pathToPluginFolder)
|
||||||
|
pluginsUpdated += 1
|
||||||
break
|
break
|
||||||
|
|
||||||
if inputSelectedObject == 'all':
|
if inputSelectedObject == 'all':
|
||||||
@ -136,6 +145,7 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
sftp.remove(pluginPath)
|
sftp.remove(pluginPath)
|
||||||
print("Downloading new plugin...")
|
print("Downloading new plugin...")
|
||||||
getSpecificPackage(pluginId, checkConfig().sftp_folderPath)
|
getSpecificPackage(pluginId, checkConfig().sftp_folderPath)
|
||||||
|
pluginsUpdated += 1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
pluginPath = checkConfig().pathToPluginFolder
|
pluginPath = checkConfig().pathToPluginFolder
|
||||||
@ -144,7 +154,9 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
os.remove(pluginPath)
|
os.remove(pluginPath)
|
||||||
print("Downloading new plugin...")
|
print("Downloading new plugin...")
|
||||||
getSpecificPackage(pluginId, checkConfig().pathToPluginFolder)
|
getSpecificPackage(pluginId, checkConfig().pathToPluginFolder)
|
||||||
|
pluginsUpdated += 1
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
print(f"[{pluginsUpdated}/{i}] Plugins updated")
|
||||||
|
|
||||||
|
|
||||||
def getInstalledPlugin(localFileName, localFileVersion):
|
def getInstalledPlugin(localFileName, localFileVersion):
|
||||||
|
Loading…
Reference in New Issue
Block a user