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

@ -7,7 +7,7 @@ from plugin.plugin_downloader import searchPackage, getSpecificPackage
from plugin.plugin_updatechecker import updateInstalledPackage, checkInstalledPackage
from plugin.plugin_remover import removePlugin
from serverjar.serverjar_checker import checkInstalledServerjar, updateServerjar
from serverjar.serverjar_paper import papermc_downloader
from serverjar.serverjar_paper import papermc_downloader
def createInputLists():

View File

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