Fixed array was not created

Changes:
- fixed array would not be created for a plugin when plugin would throw a type- or valueerror
- deleted testing prints
- minor code cleanup
This commit is contained in:
Neocky 2021-03-16 21:10:09 +01:00
parent 430dbcd8d2
commit 76e1d7f5fd
2 changed files with 9 additions and 15 deletions

View File

@ -74,6 +74,7 @@ def checkInstalledPackage(inputSelectedObject="all"):
fileVersion = getFileVersion(plugin) fileVersion = getFileVersion(plugin)
pluginId = getInstalledPlugin(fileName, fileVersion) pluginId = getInstalledPlugin(fileName, fileVersion)
except TypeError: except TypeError:
i += 1
continue continue
pluginIdStr = str(pluginId) pluginIdStr = str(pluginId)
@ -114,7 +115,7 @@ def checkInstalledPackage(inputSelectedObject="all"):
print(f"{pluginLatestVersion}".ljust(12), end='') print(f"{pluginLatestVersion}".ljust(12), end='')
print(f" {pluginIsOutdated}".ljust(5)) print(f" {pluginIsOutdated}".ljust(5))
i = i + 1 i += 1
except TypeError: except TypeError:
print(oColors.brightRed + "Aborted checking for plugins." + oColors.standardWhite) print(oColors.brightRed + "Aborted checking for plugins." + oColors.standardWhite)
print(oColors.brightYellow + f"Old packages: [{oldPackages}/{i}]" + oColors.standardWhite) print(oColors.brightYellow + f"Old packages: [{oldPackages}/{i}]" + oColors.standardWhite)
@ -139,18 +140,18 @@ def updateInstalledPackage(inputSelectedObject='all'):
fileVersion = getFileVersion(plugin) fileVersion = getFileVersion(plugin)
pluginId = getInstalledPlugin(fileName, fileVersion) pluginId = getInstalledPlugin(fileName, fileVersion)
latestVersion = getLatestPluginVersion(pluginId) latestVersion = getLatestPluginVersion(pluginId)
print(fileName)
print(fileVersion)
except TypeError: except TypeError:
i += 1
continue continue
except ValueError: except ValueError:
i += 1
continue continue
pluginIdStr = str(pluginId) pluginIdStr = str(pluginId)
if pluginId == None: 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
print(INSTALLEDPLUGINLIST[i])
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}]".ljust(8), end='')
@ -257,12 +258,10 @@ def updateInstalledPackage(inputSelectedObject='all'):
def getInstalledPlugin(localFileName, localFileVersion): def getInstalledPlugin(localFileName, localFileVersion):
url = "https://api.spiget.org/v2/search/resources/" + localFileName + "?field=name&sort=-downloads" url = "https://api.spiget.org/v2/search/resources/" + localFileName + "?field=name&sort=-downloads"
packageName = doAPIRequest(url) packageName = doAPIRequest(url)
#i = 1
plugin_match_found = False plugin_match_found = False
pluginID = None pluginID = None
for ressource in packageName: for ressource in packageName:
if plugin_match_found == True: if plugin_match_found == True:
plugin_match_found = False
break break
pID = ressource["id"] pID = ressource["id"]
url2 = f"https://api.spiget.org/v2/resources/{pID}/versions?size=100&sort=-name" url2 = f"https://api.spiget.org/v2/resources/{pID}/versions?size=100&sort=-name"
@ -276,19 +275,14 @@ def getInstalledPlugin(localFileName, localFileVersion):
plugin_latest_version = getLatestPluginVersion(pID) plugin_latest_version = getLatestPluginVersion(pID)
plugin_is_outdated = compareVersions(plugin_latest_version, updateVersion) plugin_is_outdated = compareVersions(plugin_latest_version, updateVersion)
addToPluginList(pID, updateId, plugin_latest_version , plugin_is_outdated) addToPluginList(pID, updateId, plugin_latest_version , plugin_is_outdated)
print("in if") return pluginID
print(plugin_match_found)
return pluginID # just testing
#break
else: # TODO fix duplicate entrys when update all else:
if plugin_match_found != True: if plugin_match_found != True:
pID = None pID = None
updateId = None updateId = None
plugin_latest_version = None plugin_latest_version = None
plugin_is_outdated = None plugin_is_outdated = None
addToPluginList(pID, updateId, plugin_latest_version , plugin_is_outdated) addToPluginList(pID, updateId, plugin_latest_version , plugin_is_outdated)
print("in else")
print(plugin_match_found)
return pluginID return pluginID