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:
		| @@ -6,6 +6,7 @@ from plugin_updatechecker import updateInstalledPackage, checkInstalledPackage | ||||
| from handle_config import checkConfig | ||||
| from utilities import getHelp, check_requirements | ||||
| from handle_sftp import createSFTPConnection, sftp_showPlugins | ||||
| from plugin_remover import removePlugin | ||||
|  | ||||
| def createInputLists(): | ||||
|     global COMMANDLIST | ||||
| @@ -14,7 +15,8 @@ def createInputLists(): | ||||
|         'update', | ||||
|         'check', | ||||
|         'exit', | ||||
|         'help' | ||||
|         'help', | ||||
|         'remove' | ||||
|     ] | ||||
|     global INPUTSELECTEDOBJECT | ||||
|     INPUTSELECTEDOBJECT = [ | ||||
| @@ -46,9 +48,8 @@ def handleInput(inputCommand, inputSelectedObject, inputParams): | ||||
|         if inputCommand == 'help': | ||||
|             getHelp() | ||||
|             break | ||||
|         if inputCommand == 'sftp': | ||||
|             sftp = createSFTPConnection() | ||||
|             sftp_showPlugins(sftp) | ||||
|         if inputCommand == 'remove': | ||||
|             removePlugin(inputSelectedObject) | ||||
|             break | ||||
|         else: | ||||
|             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: | ||||
|         print(downloadPath) | ||||
|         sftpSession = createSFTPConnection() | ||||
|         #sftp_cdPluginDir(sftpSession) | ||||
|         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): | ||||
|     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: | ||||
|         pluginVersionFull = pluginVersion.group() # TODO fix this | ||||
|         pluginVersionFull = pluginVersion.group() | ||||
|     except AttributeError: | ||||
|         pluginVersionFull = pluginVersion | ||||
|     pluginNameOnlyy = pluginNameFull.replace(pluginVersionFull, '') | ||||
| @@ -62,9 +62,12 @@ def checkInstalledPackage(inputSelectedObject="all"): | ||||
|     print("Index / Name / Installed Version / Update available") | ||||
|  | ||||
|     for plugin in pluginList: | ||||
|         fileName = getFileName(plugin) | ||||
|         fileVersion = getFileVersion(plugin) | ||||
|         pluginId = getInstalledPlugin(fileName, fileVersion) | ||||
|         try: | ||||
|             fileName = getFileName(plugin) | ||||
|             fileVersion = getFileVersion(plugin) | ||||
|             pluginId = getInstalledPlugin(fileName, fileVersion) | ||||
|         except TypeError: | ||||
|             continue | ||||
|         pluginIdStr = str(pluginId) | ||||
|  | ||||
|         if fileVersion == '': | ||||
| @@ -100,11 +103,15 @@ def updateInstalledPackage(inputSelectedObject='all'): | ||||
|     else: | ||||
|         pluginList = os.listdir(checkConfig().pathToPluginFolder) | ||||
|     i = 0 | ||||
|     pluginsUpdated = 0 | ||||
|     for plugin in pluginList: | ||||
|         print(plugin) | ||||
|         fileName = getFileName(plugin) | ||||
|         fileVersion = getFileVersion(plugin) | ||||
|         pluginId = getInstalledPlugin(fileName, fileVersion) | ||||
|         try: | ||||
|             fileName = getFileName(plugin) | ||||
|             fileVersion = getFileVersion(plugin) | ||||
|             pluginId = getInstalledPlugin(fileName, fileVersion) | ||||
|         except TypeError: | ||||
|             continue | ||||
|         pluginIdStr = str(pluginId) | ||||
|  | ||||
|         if pluginId == None: | ||||
| @@ -119,11 +126,13 @@ def updateInstalledPackage(inputSelectedObject='all'): | ||||
|                 sftp = createSFTPConnection() | ||||
|                 sftp.remove(pluginPath) | ||||
|                 getSpecificPackage(pluginId, checkConfig().sftp_folderPath) | ||||
|                 pluginsUpdated += 1 | ||||
|             else: | ||||
|                 pluginPath = checkConfig().pathToPluginFolder | ||||
|                 pluginPath = f"{pluginPath}\\{plugin}" | ||||
|                 os.remove(pluginPath) | ||||
|                 getSpecificPackage(pluginId, checkConfig().pathToPluginFolder) | ||||
|                 pluginsUpdated += 1 | ||||
|             break | ||||
|  | ||||
|         if inputSelectedObject == 'all': | ||||
| @@ -136,6 +145,7 @@ def updateInstalledPackage(inputSelectedObject='all'): | ||||
|                     sftp.remove(pluginPath) | ||||
|                     print("Downloading new plugin...") | ||||
|                     getSpecificPackage(pluginId, checkConfig().sftp_folderPath) | ||||
|                     pluginsUpdated += 1 | ||||
|  | ||||
|                 else: | ||||
|                     pluginPath = checkConfig().pathToPluginFolder | ||||
| @@ -144,7 +154,9 @@ def updateInstalledPackage(inputSelectedObject='all'): | ||||
|                     os.remove(pluginPath) | ||||
|                     print("Downloading new plugin...") | ||||
|                     getSpecificPackage(pluginId, checkConfig().pathToPluginFolder) | ||||
|                     pluginsUpdated += 1 | ||||
|         i = i + 1 | ||||
|     print(f"[{pluginsUpdated}/{i}] Plugins updated") | ||||
|  | ||||
|  | ||||
| def getInstalledPlugin(localFileName, localFileVersion): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Neocky
					Neocky