Schrolli91 / BOSWatch

Python Script to process input data from rtl_fm and multimon-NG - multiple Plugin support
https://bwcc.boswatch.de
GNU General Public License v2.0
132 stars 59 forks source link

Fehler im Pluginloader wenn Plugin nicht ladbar #52

Closed Schrolli91 closed 9 years ago

Schrolli91 commented 9 years ago

Mir ist heute folgendes aufgefallen, wenn ein Plugin beim import einen Fehler wirft, wird es komischerweise trotzdem irgendwie in die globals.pluginList[ ] mit richtigen Namen aufgenommen, aber auf das zuvor geladene Plugin referenziert. Sprich das zuvor geladene Plugin wird 2 mal ausgeführt, siehe Logfile (MySQL)

Er schreibt call MySQL tatsächlich führt er in diesem Fall dann aber das httpRequest Plugin aus...

...
09.07.2015 07:51:13 - pluginLoader    [DEBUG   ] Search in plugin folder
09.07.2015 07:51:13 - pluginLoader    [DEBUG   ] Plugin [DISABLED] BosMon 
09.07.2015 07:51:13 - pluginLoader    [DEBUG   ] Plugin [DISABLED] eMail 
09.07.2015 07:51:13 - pluginLoader    [DEBUG   ] Plugin [DISABLED] firEmergency 
09.07.2015 07:51:13 - pluginLoader    [DEBUG   ] Plugin [ENABLED ] httpRequest
09.07.2015 07:51:13 - pluginLoader    [DEBUG   ] Plugin [DISABLED] jsonSocket 
09.07.2015 07:51:13 - pluginLoader    [DEBUG   ] Plugin [ENABLED ] MySQL
09.07.2015 07:51:13 - pluginLoader    [DEBUG   ] Plugin [DISABLED] template 
09.07.2015 07:51:13 - pluginLoader    [DEBUG   ] load plugin: httpRequest
09.07.2015 07:51:13 - pluginLoader    [DEBUG   ] call httpRequest.onLoad()
09.07.2015 07:51:13 - pluginLoader    [DEBUG   ] load plugin: MySQL
09.07.2015 07:51:13 - pluginLoader    [ERROR   ] cannot load plugin: MySQL
09.07.2015 07:51:13 - pluginLoader    [DEBUG   ] cannot load plugin: MySQL
Traceback (most recent call last):
  File "C:\Users\123\Documents\BOSWatch\includes\pluginLoader.py", line 108, in loadPlugin
    return imp.load_module(plugin["name"], *plugin["info"])
  File "C:\Users\123\Documents\BOSWatch/plugins\MySQL\MySQL.py", line 16, in <module>
    import mysql
ImportError: No module named mysql
09.07.2015 07:51:13 - pluginLoader    [ERROR   ] error loading plugin: MySQL
09.07.2015 07:51:13 - pluginLoader    [DEBUG   ] error loading plugin: MySQL
Traceback (most recent call last):
  File "C:\Users\123\Documents\BOSWatch\includes\pluginLoader.py", line 32, in loadPlugins
    plugin = loadPlugin(i)
  File "C:\Users\123\Documents\BOSWatch\includes\pluginLoader.py", line 108, in loadPlugin
    return imp.load_module(plugin["name"], *plugin["info"])
  File "C:\Users\123\Documents\BOSWatch/plugins\MySQL\MySQL.py", line 16, in <module>
    import mysql
ImportError: No module named mysql
09.07.2015 07:51:13 - pluginLoader    [DEBUG   ] call MySQL.onLoad()
09.07.2015 07:51:13 - boswatch        [WARNING ] !!! Test-Mode: rtl_fm not started !!!
09.07.2015 07:51:13 - boswatch        [WARNING ] !!! Test-Mode: multimon-ng not started !!!
09.07.2015 07:51:13 - boswatch        [DEBUG   ] start testing
09.07.2015 07:51:13 - boswatch        [INFO    ] Testdata: # Testdata for the BOSWatch Test Mode function
09.07.2015 07:51:14 - boswatch        [INFO    ] Testdata: POCSAG512: Address: 1000512  Function: 1  Alpha:   BOSWatch-Test ÖÄÜß: okay
09.07.2015 07:51:14 - decoder         [DEBUG   ] recieved POCSAG
09.07.2015 07:51:14 - poc             [DEBUG   ] POCSAG Bitrate: 512
09.07.2015 07:51:14 - poc             [INFO    ] POCSAG512: 1000512 2 BOSWatch-Test ÖÄÜß: okay 
09.07.2015 07:51:14 - alarmHandler    [DEBUG   ] [  ALARM  ]
09.07.2015 07:51:14 - alarmHandler    [DEBUG   ] call Plugin: httpRequest
09.07.2015 07:51:14 - configHandler   [DEBUG   ] read [httpRequest] from config file
09.07.2015 07:51:14 - configHandler   [DEBUG   ]  - fms_url = www.google.de?ric=%RIC%&subric=%TIME%&msg=%MSG%
09.07.2015 07:51:14 - configHandler   [DEBUG   ]  - zvei_url = www.google.de?ric=%RIC%&subric=%TIME%&msg=%MSG%
09.07.2015 07:51:14 - configHandler   [DEBUG   ]  - poc_url = www.google.de?ric=%RIC%&subric=%TIME%&msg=%MSG%
09.07.2015 07:51:14 - wildcardHandler [DEBUG   ] wildcards been replaced
09.07.2015 07:51:14 - httpRequest     [DEBUG   ] send POC HTTP request
09.07.2015 07:51:15 - httpRequest     [DEBUG   ] HTTP response: 200 - OK
09.07.2015 07:51:15 - httpRequest     [DEBUG   ] close HTTP-Connection
09.07.2015 07:51:15 - alarmHandler    [DEBUG   ] return from: httpRequest
09.07.2015 07:51:15 - alarmHandler    [DEBUG   ] call Plugin: MySQL
09.07.2015 07:51:15 - configHandler   [DEBUG   ] read [httpRequest] from config file
09.07.2015 07:51:15 - configHandler   [DEBUG   ]  - fms_url = www.google.de?ric=%RIC%&subric=%TIME%&msg=%MSG%
09.07.2015 07:51:15 - configHandler   [DEBUG   ]  - zvei_url = www.google.de?ric=%RIC%&subric=%TIME%&msg=%MSG%
09.07.2015 07:51:15 - configHandler   [DEBUG   ]  - poc_url = www.google.de?ric=%RIC%&subric=%TIME%&msg=%MSG%
09.07.2015 07:51:15 - wildcardHandler [DEBUG   ] wildcards been replaced
09.07.2015 07:51:15 - httpRequest     [DEBUG   ] send POC HTTP request
09.07.2015 07:51:15 - httpRequest     [DEBUG   ] HTTP response: 200 - OK
09.07.2015 07:51:15 - httpRequest     [DEBUG   ] close HTTP-Connection
09.07.2015 07:51:15 - alarmHandler    [DEBUG   ] return from: MySQL
09.07.2015 07:51:15 - alarmHandler    [DEBUG   ] [END ALARM]
....
Schrolli91 commented 9 years ago

Habs gefixt, kanns nochmal jemand gegenchecken, ob jetzt alles läuft, bitte?

Problem war: Konnte das Plugin nicht importiert werden, kam zwar eine Fehlermeldung, danach wurde aber einfach weitergemacht:

allerdings mit den Daten vom letzten importierten Plugin, da durch den fehlerhaften Import die Daten des Plugins nicht überschrieben wurden. Daher hat er, zwar mit richtigen Namen aber falscher Plugin Referenz, dass vorherige nochmal in die Liste aufgenommen.

Behoben durch setzen eines else: in der Try:Exception:-Klausel. Jetzt wird der onLoad() Aufruf, sowie sowie die Aufnahme in die Liste nur durchgeführt wenn das Plugin auch fehlerfrei importiert werden konnte.

Schrolli91 commented 9 years ago

da noch niemand gemauelt hat, gehe ich davon aus, es passt alles. Ansonsten Bug Issue... closed