From cc126d97c6175f95bc94b88ef090661e7b739d7c Mon Sep 17 00:00:00 2001 From: Agnibho Mondal Date: Thu, 26 Oct 2023 23:57:38 +0530 Subject: [PATCH] Check plugin functions --- plugin.py | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/plugin.py b/plugin.py index 3b86520..a6b94b2 100644 --- a/plugin.py +++ b/plugin.py @@ -40,49 +40,55 @@ class Plugin(): def commands(self): cmds=[] for i in self.plugins: - cmds.append([i, self.get_name(i)]) + if(hasattr(i, "run") and callable(i.run)): + cmds.append([i, self.get_name(i)]) return(cmds) def new(self, prescription): for i in self.plugins: try: - msg=i.new(prescription) - if(msg): - QMessageBox.information(None, "Information", msg) + if(hasattr(i, "new") and callable(i.new)): + msg=i.new(prescription) + if(msg): + QMessageBox.information(None, "Information", msg) except Exception as e: print(e) def open(self, prescription): for i in self.plugins: try: - msg=i.open(prescription) - if(msg): - QMessageBox.information(None, "Information", msg) + if(hasattr(i, "open") and callable(i.open)): + msg=i.open(prescription) + if(msg): + QMessageBox.information(None, "Information", msg) except Exception as e: print(e) def save(self, prescription): for i in self.plugins: try: - msg=i.save(prescription) - if(msg): - QMessageBox.information(None, "Information", msg) + if(hasattr(i, "save") and callable(i.save)): + msg=i.save(prescription) + if(msg): + QMessageBox.information(None, "Information", msg) except Exception as e: print(e) def refresh(self, prescription): for i in self.plugins: try: - msg=i.refresh(prescription) - if(msg): - QMessageBox.information(None, "Information", msg) + if(hasattr(i, "refresh") and callable(i.refresh)): + msg=i.refresh(prescription) + if(msg): + QMessageBox.information(None, "Information", msg) except Exception as e: print(e) def run(self, module, prescription): try: - msg=module.run(prescription) - if(msg): - QMessageBox.information(None, "Information", msg) + if(hasattr(module, "run") and callable(module.run)): + msg=module.run(prescription) + if(msg): + QMessageBox.information(None, "Information", msg) except Exception as e: print(e) -- 2.39.5