File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,14 @@ in progress
77===========
88
99
10+ 2021-06-03 0.23.0
11+ =================
12+
13+ - [http] Rename ``http.py `` module to ``http_urllib.py `` to reduce conflicts with stdlib.
14+ For backward compatibility reasons, it is still available by the same name, so no
15+ configurations will break.
16+
17+
10182021-06-03 0.22.0
1119=================
1220
Original file line number Diff line number Diff line change @@ -552,18 +552,28 @@ def load_services(services):
552552
553553 # Load built-in service module.
554554 else :
555+ # Backward-compatibility patch for honoring the renaming of the `http.py` module.
556+ if module == "http" :
557+ module = "http_urllib"
558+ logger .debug ('Trying to load built-in service "{}" from "{}"' .format (service , module ))
555559 modulefile_candidates = [ resource_filename ('mqttwarn.services' , module + '.py' ) ]
556560
561+ success = False
557562 for modulefile in modulefile_candidates :
558563 if not os .path .isfile (modulefile ):
559564 continue
560565 logger .debug ('Trying to load service "{}" from file "{}"' .format (service , modulefile ))
561566 try :
562567 service_plugins [service ]['module' ] = load_module_from_file (modulefile )
563568 logger .info ('Successfully loaded service "{}"' .format (service ))
569+ success = True
564570 except Exception as ex :
565571 logger .exception ('Unable to load service "{}" from file "{}": {}' .format (service , modulefile , ex ))
566572
573+ if not success :
574+ logger .critical ('Unable to load service "{}"' .format (service ))
575+ sys .exit (1 )
576+
567577
568578def connect ():
569579 """
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ def plugin(srv, item):
5959 try :
6060 params [key ] = params [key ].format (** item .data ).encode ('utf-8' )
6161 except Exception as e :
62- srv .logging .debug ("Parameter %s cannot be formatted: %s " % ( key , e ) )
62+ srv .logging .exception ("Parameter %s cannot be formatted" % key )
6363 return False
6464
6565 message = item .message
@@ -82,6 +82,7 @@ def plugin(srv, item):
8282
8383 resp = urllib .request .urlopen (request , timeout = timeout )
8484 data = resp .read ()
85+ #srv.logging.debug("HTTP response:\n%s" % data)
8586 except Exception as e :
8687 srv .logging .warn ("Cannot GET %s: %s" % (resource , e ))
8788 return False
@@ -112,7 +113,7 @@ def plugin(srv, item):
112113 srv .logging .debug ("before send" )
113114 resp = urllib .request .urlopen (request , timeout = timeout )
114115 data = resp .read ()
115- # print "POST returns ", data
116+ #srv.logging.debug("HTTP response:\n%s" % data)
116117 except Exception as e :
117118 srv .logging .warn ("Cannot POST %s: %s" % (url , e ))
118119 return False
You can’t perform that action at this time.
0 commit comments