Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix KeyError in onHeartbeat function #56

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 28 additions & 23 deletions plugin.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@

# pp-manager - PythonPlugin Manager
#
# Author: ycahome, 2018
#
# Since (2018-02-23): Initial Version
#
#


"""
Expand Down Expand Up @@ -276,6 +274,9 @@ def onStart(self):









Expand Down Expand Up @@ -333,6 +334,7 @@ def onStart(self):




# Reading exception file and populating array of values
exceptionFile = str(os.getcwd()) + "/plugins/PP-MANAGER/exceptions.txt"
Domoticz.Debug("Checking for Exception file on:" + exceptionFile)
Expand Down Expand Up @@ -457,7 +459,12 @@ def onHeartbeat(self):
for (path, dirs, files) in os.walk(path):
for dir in dirs:
if str(dir) != "":
self.UpdatePythonPlugin(self.plugindata[Parameters["Mode2"]][0], self.plugindata[Parameters["Mode2"]][1], str(dir))
if str(dir) in self.plugindata:
self.UpdatePythonPlugin(self.plugindata[Parameters["Mode2"]][0], self.plugindata[Parameters["Mode2"]][1], str(dir))
elif str(dir) == "PP-MANAGER":
Domoticz.Debug("PP-Manager Folder found. Skipping!!")
else:
Domoticz.Log("Plugin:" + str(dir) + " cannot be managed with PP-Manager!!.")
i += 1
if i >= 1:
break
Expand All @@ -469,14 +476,22 @@ def onHeartbeat(self):
for (path, dirs, files) in os.walk(path):
for dir in dirs:
if str(dir) != "":
self.CheckForUpdatePythonPlugin(self.plugindata[Parameters["Mode2"]][0], self.plugindata[Parameters["Mode2"]][1], str(dir))
if str(dir) in self.plugindata:
self.CheckForUpdatePythonPlugin(self.plugindata[Parameters["Mode2"]][0], self.plugindata[Parameters["Mode2"]][1], str(dir))
elif str(dir) == "PP-MANAGER":
Domoticz.Debug("PP-Manager Folder found. Skipping!!")
else:
Domoticz.Log("Plugin:" + str(dir) + " cannot be managed with PP-Manager!!.")
i += 1
if i >= 1:
break

if Parameters["Mode4"] == 'SelectedNotify':
Domoticz.Log("Collecting Updates for Plugin:" + pluginKey)
self.CheckForUpdatePythonPlugin(self.plugindata[Parameters["Mode2"]][0], self.plugindata[Parameters["Mode2"]][1], Parameters["Mode2"])
if pluginKey in self.plugindata:
self.CheckForUpdatePythonPlugin(self.plugindata[Parameters["Mode2"]][0], self.plugindata[Parameters["Mode2"]][1], Parameters["Mode2"])
else:
Domoticz.Log("Plugin:" + pluginKey + " not found in plugindata. Skipping update check.")

#-------------------------------------
if Parameters["Mode4"] == 'Selected':
Expand All @@ -485,7 +500,9 @@ def onHeartbeat(self):

#if Parameters["Mode2"] == "Idle":
#Domoticz.Log("Plugin Idle. No actions to be performed!!!")







Expand Down Expand Up @@ -533,7 +550,6 @@ def InstallPythonPlugin(self, ppAuthor, ppRepository, ppKey, ppBranch):




# UpdatePyhtonPlugin function
def UpdatePythonPlugin(self, ppAuthor, ppRepository, ppKey):
Domoticz.Debug("UpdatePythonPlugin called")
Expand Down Expand Up @@ -588,7 +604,6 @@ def UpdatePythonPlugin(self, ppAuthor, ppRepository, ppKey):




# UpdateNotifyPyhtonPlugin function
def CheckForUpdatePythonPlugin(self, ppAuthor, ppRepository, ppKey):
Domoticz.Debug("CheckForUpdatePythonPlugin called")
Expand Down Expand Up @@ -643,7 +658,6 @@ def CheckForUpdatePythonPlugin(self, ppAuthor, ppRepository, ppKey):
return None



# fnSelectedNotify function
def fnSelectedNotify(self, pluginText):
Domoticz.Debug("fnSelectedNotify called")
Expand Down Expand Up @@ -731,7 +745,7 @@ def parseFileForSecurityIssues(self, pyfilename, pypluginid):
# for rex in range(0,len(regexFound)):
# if ((str(text).strip() not in self.SecPolUserList["Global"]) and (str(text).strip() not in self.SecPolUserList[pypluginid]) and (str(text).strip() != "") and (mid(text,0,1) != "#")):
# Domoticz.Error("Security Finding(IMP):-->" + str(text) + "<-- LINE: " + str(lineNum) + " FILE:" + pyfilename)
#Domoticz.Error("Security Finding(IPr):" + regexFound[rex] + " LINE: " + str(lineNum) + " FILE:" + pyfilename)
#Domoticz.Error("Security Finding(IPr):" + regexFound[rex] + " LINE: " + str(lineNum) + " FILE:" + pyfilename)
# ips["IP" + str(lineNum)] = (regexFound[rex], "Import")

#rex = 0
Expand All @@ -743,7 +757,7 @@ def parseFileForSecurityIssues(self, pyfilename, pypluginid):
# for rex in range(0,len(regexFound)):
# if ((str(text).strip() not in self.SecPolUserList["Global"]) and (str(text).strip() not in self.SecPolUserList[pypluginid]) and (str(text).strip() != "") and (mid(text,0,1) != "#")):
# Domoticz.Error("Security Finding(SUB):-->" + str(text) + "<-- LINE: " + str(lineNum) + " FILE:" + pyfilename)
#Domoticz.Error("Security Finding(IPr):" + regexFound[rex] + " LINE: " + str(lineNum) + " FILE:" + pyfilename)
#Domoticz.Error("Security Finding(IPr):" + regexFound[rex] + " LINE: " + str(lineNum) + " FILE:" + pyfilename)
# ips["IP" + str(lineNum)] = (regexFound[rex], "Subprocess")

#rex = 0
Expand All @@ -756,7 +770,7 @@ def parseFileForSecurityIssues(self, pyfilename, pypluginid):
# for rex in range(0,len(regexFound)):
# if ((str(text).strip() not in self.SecPolUserList[pypluginid]) and (str(text).strip() != "") and (mid(text,0,1) != "#")):
# Domoticz.Error("Security Finding(HTTP):-->" + str(text) + "<-- LINE: " + str(lineNum) + " FILE:" + pyfilename)
#Domoticz.Error("Security Finding(IPr):" + regexFound[rex] + " LINE: " + str(lineNum) + " FILE:" + pyfilename)
#Domoticz.Error("Security Finding(IPr):" + regexFound[rex] + " LINE: " + str(lineNum) + " FILE:" + pyfilename)
# ips["IP" + str(lineNum)] = (regexFound[rex], "HTTP Address")


Expand All @@ -769,16 +783,8 @@ def parseFileForSecurityIssues(self, pyfilename, pypluginid):


















Expand Down Expand Up @@ -823,4 +829,3 @@ def mid(s, offset, amount):
#Domoticz.Debug("mid called")
return s[offset:offset+amount]