Repository: ioos/compliance-checker

Issue:
JSON output issue in 3.0.3 with ERDDAP URLs
I've been testing the new Compliance Checker release with ERDDAP (on Windows), and I see some different results in the output when using ERDDAP URLs with the JSON output format than OPeNDAP.

I made a test script that illustrates the issue: https://gist.github.com/mwengren/68f61b0e70868a57336b81f863d7dbc9

Or, I think you can see the same issue (in my environment at least) by running these commands:
```
compliance-checker -t cf -f json http://coastwatch.pfeg.noaa.gov/erddap/griddap/osuSstAnom

compliance-checker -t cf -f json http://ona.coas.oregonstate.edu:8080/thredds/dodsC/NANOOS/OCOS
```

The issue is that when I try to hit the ERDDAP URL, it includes what looks like a debug line in stdout:
```
Using cached standard name table v29 from C:\Users\Micah.Wengren\.local\share\compliance-checker\cf-standard-name-table-test-29.xml
{
  "cf": {
    "scored_points": 168,
    "low_count": 0,
...
```

When I try to parse this into JSON using subprocess.Popen (see the Gist), if fails because it can't parse the first line. 

I'm using 3.0.3:
```
$ compliance-checker --version
IOOS compliance checker version 3.0.3
```

Also, not sure if it matters, but I'm using Python 2.7 for these tests.


Discussion:

Resolving patch:
diff --git a/compliance_checker/cf/cf.py b/compliance_checker/cf/cf.py
--- a/compliance_checker/cf/cf.py
+++ b/compliance_checker/cf/cf.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
-from __future__ import unicode_literals, division
+from __future__ import unicode_literals, division, print_function
 from compliance_checker.base import BaseCheck, BaseNCCheck, Result, TestCtx
 from compliance_checker.cf.appendix_d import dimless_vertical_coordinates
 from compliance_checker.cf.appendix_f import grid_mapping_dict
@@ -11,6 +11,7 @@
 import numpy as np
 import os
 import re
+import sys
 
 import logging
 
@@ -132,7 +133,7 @@ def _find_cf_standard_name_table(self, ds):
 
         # If the packaged version is what we're after, then we're good
         if version == self._std_names._version:
-            print("Using packaged standard name table v{0}".format(version))
+            print("Using packaged standard name table v{0}".format(version), file=sys.stderr)
             return False
 
         # Try to download the version specified
@@ -142,15 +143,15 @@ def _find_cf_standard_name_table(self, ds):
             # Did we already download this before?
             if not os.path.isfile(location):
                 util.download_cf_standard_name_table(version, location)
-                print("Using downloaded standard name table v{0}".format(version))
+                print("Using downloaded standard name table v{0}".format(version), file=sys.stderr)
             else:
-                print("Using cached standard name table v{0} from {1}".format(version, location))
+                print("Using cached standard name table v{0} from {1}".format(version, location), file=sys.stderr)
 
             self._std_names = util.StandardNameTable(location)
             return True
         except Exception:
             # There was an error downloading the CF table. That's ok, we'll just use the packaged version
-            print("Error fetching standard name table. Using packaged v{0}".format(self._std_names._version))
+            print("Error fetching standard name table. Using packaged v{0}".format(self._std_names._version), file=sys.stderr)
             return False
 
     def _find_coord_vars(self, ds, refresh=False):
diff --git a/compliance_checker/cf/util.py b/compliance_checker/cf/util.py
--- a/compliance_checker/cf/util.py
+++ b/compliance_checker/cf/util.py
@@ -1,7 +1,9 @@
+from __future__ import print_function
 import io
 import itertools
 import requests
 import os
+import sys
 from copy import deepcopy
 from collections import defaultdict
 from lxml import etree
@@ -327,7 +329,7 @@ def download_cf_standard_name_table(version, location=None):
     url = "http://cfconventions.org/Data/cf-standard-names/{0}/src/cf-standard-name-table.xml".format(version)
     r = requests.get(url, allow_redirects=True)
     if r.status_code == 200:
-        print("Downloading cf-standard-names table version {0} from: {1}".format(version, url))
+        print("Downloading cf-standard-names table version {0} from: {1}".format(version, url), file=sys.stderr)
         with open(location, 'wb') as f:
             f.write(r.content)
     else:


Test patch: