This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository mum. See http://git.chorem.org/mum.git commit 51c4809f8e7a1ebb46c5aba2025953c95eda9d00 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Thu Mar 26 09:57:49 2015 +0100 sms_notif = ok + correction bug subscription dans bdd + affichage traceback --- app/app.py | 5 +- app/modules/storage_modules/shelve_db.py | 139 ++++++++++++++++--------------- 2 files changed, 75 insertions(+), 69 deletions(-) diff --git a/app/app.py b/app/app.py index 829f32f..92c5d26 100755 --- a/app/app.py +++ b/app/app.py @@ -184,8 +184,9 @@ if __name__ == '__main__': ml.load_all_detection_modules() ml.load_all_notification_modules() wsc = WebSocketContainer(ml.get_db()) - #dict_notif = ml.db.add_check('127.0.0.1', "ping", False) - #ml.run_notification_modules(dict_notif) + dict_notif = ml.db.add_check('127.0.0.1', "ping", False) + print dict_notif + ml.run_notification_modules(dict_notif) #process_monitoring.init(ml, wsc) port = int(os.environ.get('PORT', 1337)) run(host='0.0.0.0', port=port, debug=True, server=GeventWebSocketServer) diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index d24133a..a935b88 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -3,6 +3,7 @@ __author__ = 'aguilbaud' from datetime import datetime import json import shelve +import traceback import os.path @@ -80,8 +81,8 @@ class shelve_db: self.db["hosts"][addr_host]["status"] = {} # Create structure for archiving data self.db["hosts"][addr_host]["archive"] = {} - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -228,8 +229,8 @@ class shelve_db: res = None try: res = self.db['hosts'][args['addr_host']]['conf']['connections'] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -259,8 +260,8 @@ class shelve_db: dict_moni['time'] = datetime.now() dict_moni['freq'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod]['check_frequency'] res.append(dict_moni) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -275,8 +276,8 @@ class shelve_db: try: for addr_host in self.db['hosts']: res.append(addr_host) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -336,8 +337,8 @@ class shelve_db: elif self.db["hosts"][host]["monitoring"][mod]["state"] == "danger": info_host["danger"].append(mod) res.append(info_host) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -392,8 +393,8 @@ class shelve_db: res['activated_monitoring'][mod] = self.db['hosts'][addr_host]['conf']['monitoring'][mod]['activated'] res['custom_infos'] = self.db['hosts'][addr_host]['conf']['custom_info'] res['interventions'] = self.db['hosts'][addr_host]['conf']['interventions'] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -418,8 +419,8 @@ class shelve_db: for host in self.db['groups'][group_id]['hosts']: if self.db['groups'][group_id]['hosts'][host]['addr'] == addr_host: del self.db['groups'][group_id]['hosts'][host] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -433,8 +434,8 @@ class shelve_db: self.open_db() try: self.db["hosts"][addr_host]["detected"][name_part] = json_res_str - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -452,8 +453,8 @@ class shelve_db: nmap_detection = json.loads(self.db['hosts'][args['addr_host']]['detected']['nmap']) nmap_detection['os'] = args['new_os_name'].lower() self.db['hosts'][args['addr_host']]['detected']['nmap'] = json.dumps(nmap_detection) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -471,8 +472,8 @@ class shelve_db: self.open_db() try: self.db["hosts"][addr_host]["conf"]["custom_info"] = txt - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -495,8 +496,8 @@ class shelve_db: self.open_db() try: self.db["hosts"][addr_host]["conf"]["interventions"].append(intervention) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -547,8 +548,8 @@ class shelve_db: # if not, we have to remove it from the monitoring list self.db["hosts"][addr_host]["conf"]["monitoring"][mod_name]["activated"] = False self.rem_to_monitoring_list(args['addr_host'], mod_name) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -574,8 +575,8 @@ class shelve_db: res['minor_limit'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['minor_limit'] res['major_limit'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['major_limit'] res['freq'] = self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['check_frequency'] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -599,8 +600,8 @@ class shelve_db: self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['minor_limit'] = args['minor_limit'] self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['major_limit'] = args['major_limit'] self.db['hosts'][addr_host]['conf']['monitoring'][mod_name]['check_frequency'] = args['freq'] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -619,8 +620,8 @@ class shelve_db: try: for mod in args['priorities']: self.db['hosts'][addr_host]['conf']['connections'][mod]['priority'] = args['priorities'][mod] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -639,8 +640,8 @@ class shelve_db: for param in args['current_config'][modname]: self.db['hosts'][addr_host]['conf']['connections'][modname][param] = \ args['current_config']['ssh'][param] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -661,8 +662,8 @@ class shelve_db: dict_conn['priority'] = self.db['hosts'][addr_host]['conf']['connections'][conn]['priority'] dict_conn['args'] = self.db['hosts'][addr_host]['conf']['connections'][conn] res.append(dict_conn) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -733,8 +734,8 @@ class shelve_db: self.db['hosts'][addr_host]['archive'][mod_name] = \ self.update_stats(self.db['hosts'][addr_host]['archive'][mod_name], val) """ - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return dict_notif @@ -833,8 +834,8 @@ class shelve_db: if group not in self.db['hosts'][host]['conf']['groups']: self.db['groups'][group]['hosts'].append(host) self.db['hosts'][host]['conf']['groups'].append(group) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -857,8 +858,8 @@ class shelve_db: # deletion of the group if empty if len(self.db['groups'][group]['hosts']) == 0: del self.db['groups'][group] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -874,8 +875,10 @@ class shelve_db: try: for user in users: self.db['groups'][group]['subscribers'][user] = {} - except Exception as e: - print e.__str__() + self.db['groups'][group]['subscribers'][user]['major'] = {} + self.db['groups'][group]['subscribers'][user]['minor'] = {} + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -903,8 +906,8 @@ class shelve_db: try: for username in args['subscription']: self.db['groups'][group]['subscribers'][username] = args['subscription'][username] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -919,8 +922,8 @@ class shelve_db: self.open_db() try: del self.db['groups'][group]['subscribers'][username] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -945,8 +948,8 @@ class shelve_db: self.open_db() try: res = self.db['groups'][group]['subscribers'] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -966,8 +969,8 @@ class shelve_db: self.db['users'][username]['preferences']['major_notifications'] = {} self.db['users'][username]['account'] = {} self.db['users'][username]['settings'] = {} - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -982,8 +985,8 @@ class shelve_db: try: for user in self.db['users']: res.append(user) - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -1005,8 +1008,8 @@ class shelve_db: self.open_db() try: res['settings'] = self.db['users'][args['username']]['settings'] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res @@ -1026,9 +1029,9 @@ class shelve_db: """ self.open_db() try: - self.db['users'][args['username']]['settings'] = args['settings'] - except Exception as e: - print e.__str__() + self.db['users'][args['user']]['settings'] = args['settings'] + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -1052,8 +1055,8 @@ class shelve_db: for group in self.db['groups']: if username in self.db['groups'][group]['subscribers']: del self.db['groups'][group]['subscribers'][username] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -1069,8 +1072,10 @@ class shelve_db: try: for user in users: self.db['hosts'][addr_host]['conf']['subscribers'][user] = {} - except Exception as e: - print e.__str__() + self.db['hosts'][addr_host]['conf']['subscribers'][user]['minor'] = {} + self.db['hosts'][addr_host]['conf']['subscribers'][user]['major'] = {} + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -1098,8 +1103,8 @@ class shelve_db: try: for username in args['subscription']: self.db['hosts'][addr_host]['conf']['subscribers'][username] = args['subscription'][username] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -1114,8 +1119,8 @@ class shelve_db: self.open_db() try: del self.db['hosts'][addr_host]['conf']['subscribers'][username] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() @@ -1140,8 +1145,8 @@ class shelve_db: self.open_db() try: res = self.db['hosts'][addr_host]['conf']['subscribers'] - except Exception as e: - print e.__str__() + except Exception: + print traceback.format_exc() finally: self.close_db() return res \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.