From 01465eb769dbd39c2a5c398302cd490fe39609a4 Mon Sep 17 00:00:00 2001 From: Neocky Date: Thu, 18 Mar 2021 23:42:02 +0100 Subject: [PATCH] Added new progress bar and some formating Changes: - added simple progress bar when checking/updating plugins - misc code cleanup - changed logo --- src/__main__.py | 7 ++----- src/plugin/plugin_updatechecker.py | 15 +++++++-------- src/utils/consoleoutput.py | 10 +++++++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/__main__.py b/src/__main__.py index 00bc0a4..77a4580 100644 --- a/src/__main__.py +++ b/src/__main__.py @@ -1,10 +1,7 @@ -from utils.consoleoutput import consoleTitle, clearConsole, printMainMenu, oColors -from utils.utilities import getHelp, check_requirements +from utils.consoleoutput import consoleTitle, clearConsole, printMainMenu +from utils.utilities import check_requirements from handlers.handle_input import createInputLists, getInput from handlers.handle_config import checkConfig -from plugin.plugin_downloader import searchPackage, getSpecificPackage -from plugin.plugin_updatechecker import updateInstalledPackage, checkInstalledPackage -from plugin.plugin_remover import removePlugin def mainFunction(): diff --git a/src/plugin/plugin_updatechecker.py b/src/plugin/plugin_updatechecker.py index 29ed690..219655b 100644 --- a/src/plugin/plugin_updatechecker.py +++ b/src/plugin/plugin_updatechecker.py @@ -97,8 +97,9 @@ def checkInstalledPackage(inputSelectedObject="all"): oldPackages = 0 print(f"Checking: {inputSelectedObject}") print("Index | Name | Installed V. | Latest V. | Update available") + print("─────────────────────────────────────────────────────────────────────────────────────") try: - for plugin in track(pluginList, description="Checking plugins" ,transient=True, complete_style="cyan"): + for plugin in track(pluginList, description="Checking for updates" ,transient=True, complete_style="cyan"): try: fileName = getFileName(plugin) fileVersion = getFileVersion(plugin) @@ -109,7 +110,6 @@ def checkInstalledPackage(inputSelectedObject="all"): pluginIdStr = str(pluginId) if fileVersion == '': fileVersion = 'N/A' - try: pluginLatestVersion = INSTALLEDPLUGINLIST[i][2] except IndexError: @@ -146,7 +146,7 @@ def checkInstalledPackage(inputSelectedObject="all"): i += 1 except TypeError: - print(oColors.brightRed + "Aborted checking for plugins." + oColors.standardWhite) + print(oColors.brightRed + "Aborted checking for updates." + oColors.standardWhite) print(oColors.brightYellow + f"Old packages: [{oldPackages}/{i}]" + oColors.standardWhite) @@ -162,8 +162,9 @@ def updateInstalledPackage(inputSelectedObject='all'): indexNumberUpdated = 0 print(f"Updating: {inputSelectedObject}") print("Index | Name | Old V. | New V.") + print("───────────────────────────────────────────────────────────") try: - for plugin in pluginList: + for plugin in track(pluginList, description="Updating" ,transient=True, complete_style="red"): try: fileName = getFileName(plugin) fileVersion = getFileVersion(plugin) @@ -177,10 +178,9 @@ def updateInstalledPackage(inputSelectedObject='all'): continue pluginIdStr = str(pluginId) - if pluginId == None: + if pluginId == None or pluginId == '': print(oColors.brightRed + "Couldn't find plugin id. Sorry :(" + oColors.standardWhite) continue - if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE): if INSTALLEDPLUGINLIST[i][3] == True: print(f" [{indexNumberUpdated+1}]".ljust(8), end='') @@ -190,7 +190,7 @@ def updateInstalledPackage(inputSelectedObject='all'): print(f"{latestVersion}".ljust(8)) if not checkConfig().localPluginFolder: - if checkConfig().sftp_pathToSeperateDownloadPath is True: + if checkConfig().sftp_seperateDownloadPath is True: pluginPath = checkConfig().sftp_pathToSeperateDownloadPath else: pluginPath = checkConfig().sftp_folderPath @@ -243,7 +243,6 @@ def updateInstalledPackage(inputSelectedObject='all'): pluginPath = checkConfig().sftp_pathToSeperateDownloadPath else: pluginPath = checkConfig().sftp_folderPath - pluginPath = checkConfig().sftp_folderPath pluginPath = f"{pluginPath}/{plugin}" sftp = createSFTPConnection() indexNumberUpdated += 1 diff --git a/src/utils/consoleoutput.py b/src/utils/consoleoutput.py index 835f5de..eb2013f 100644 --- a/src/utils/consoleoutput.py +++ b/src/utils/consoleoutput.py @@ -18,6 +18,7 @@ class oColors: brightRed = "\033[91m" brightGreen = "\033[92m" darkMagenta = "\033[35m" + brightBlack = "\033[90m" def printLogo(): @@ -72,9 +73,12 @@ def printLogo(): oColors.standardWhite) print() print() - print(oColors.brightYellow + " [" + oColors.darkMagenta + "By Neocky" + - oColors.brightYellow + "] " + oColors.standardWhite) - print() + print(oColors.brightBlack + " ┌────────────────────────────────────┐" + oColors.standardWhite) + print(oColors.brightBlack + " │ [" + oColors.brightMagenta + "By Neocky" +oColors.brightBlack + + "] │ " + oColors.standardWhite) + print(oColors.brightBlack + " │ " + oColors.brightMagenta + "https://github.com/Neocky/pluGET" + oColors.brightBlack + + " │ " + oColors.standardWhite) + print(oColors.brightBlack + " └────────────────────────────────────┘" + oColors.standardWhite) def printHorizontalLine():