Disable TLS warnings
[infoex-autowx.git] / infoex-autowx.py
index b979287e1a38b12d6796a3b590098ee894ba44c8..af1ae31344a9c2074fe040b550356cadb182d123 100755 (executable)
@@ -29,6 +29,8 @@ import logging
 import os
 import sys
 import time
 import os
 import sys
 import time
+import urllib3
+import importlib.util
 
 from ftplib import FTP
 from argparse import ArgumentParser
 
 from ftplib import FTP
 from argparse import ArgumentParser
@@ -41,11 +43,13 @@ import zeep
 import zeep.cache
 import zeep.transports
 
 import zeep.cache
 import zeep.transports
 
-__version__ = '3.1.0'
+__version__ = '3.1.1'
 
 LOG = logging.getLogger(__name__)
 LOG.setLevel(logging.NOTSET)
 
 
 LOG = logging.getLogger(__name__)
 LOG.setLevel(logging.NOTSET)
 
+urllib3.disable_warnings()
+
 def get_parser():
     """Return OptionParser for this program"""
     parser = ArgumentParser()
 def get_parser():
     """Return OptionParser for this program"""
     parser = ArgumentParser()
@@ -228,8 +232,6 @@ def main():
                                               station)
     elif station['provider'] == 'python':
         try:
                                               station)
     elif station['provider'] == 'python':
         try:
-            import importlib.util
-
             spec = importlib.util.spec_from_file_location('custom_wx',
                                                           station['path'])
             mod = importlib.util.module_from_spec(spec)
             spec = importlib.util.spec_from_file_location('custom_wx',
                                                           station['path'])
             mod = importlib.util.module_from_spec(spec)
@@ -418,6 +420,7 @@ def setup_infoex_counterparts_mapping(provider):
 def get_nrcs_data(begin, end, station):
     """get the data we're after from the NRCS WSDL"""
     transport = zeep.transports.Transport(cache=zeep.cache.SqliteCache())
 def get_nrcs_data(begin, end, station):
     """get the data we're after from the NRCS WSDL"""
     transport = zeep.transports.Transport(cache=zeep.cache.SqliteCache())
+    transport.session.verify = False
     client = zeep.Client(wsdl=station['source'], transport=transport)
     remote_data = {}
 
     client = zeep.Client(wsdl=station['source'], transport=transport)
     remote_data = {}
 
@@ -474,11 +477,19 @@ def get_mesowest_data(begin, end, station):
 
     try:
         observations = json['STATION'][0]['OBSERVATIONS']
 
     try:
         observations = json['STATION'][0]['OBSERVATIONS']
-    except KeyError:
-        LOG.error("Unexpected JSON in MesoWest response")
+    except KeyError as exc:
+        LOG.error("Unexpected JSON in MesoWest response: '%s'", exc)
         sys.exit(1)
         sys.exit(1)
-    except ValueError:
-        LOG.error("Bad JSON in MesoWest response")
+    except IndexError as exc:
+        LOG.error("Unexpected JSON in MesoWest response: '%s'", exc)
+        try:
+            LOG.error("Detailed MesoWest response: '%s'",
+                      json['SUMMARY']['RESPONSE_MESSAGE'])
+        except KeyError:
+            pass
+        sys.exit(1)
+    except ValueError as exc:
+        LOG.error("Bad JSON in MesoWest response: '%s'", exc)
         sys.exit(1)
 
     pos = len(observations['date_time']) - 1
         sys.exit(1)
 
     pos = len(observations['date_time']) - 1