Bug 1365577 - Don't print whitelist.json warning from histogram_tools.py outside of client builds r=chutten
☠☠ backed out by f1342f98acb1 ☠ ☠
authorRaajit Raj <raajit.raj@gmail.com>
Fri, 26 May 2017 00:26:32 +0530
changeset 360673 66138e53fec2
parent 360672 87e59d65e1b2
child 360674 ae7d78d08816
push id43431
push userchutten@mozilla.com
push dateThu, 25 May 2017 19:07:31 +0000
treeherderautoland@66138e53fec2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1365577
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1365577 - Don't print whitelist.json warning from histogram_tools.py outside of client builds r=chutten MozReview-Commit-ID: EuTcD7PoUIf
toolkit/components/telemetry/histogram_tools.py
--- a/toolkit/components/telemetry/histogram_tools.py
+++ b/toolkit/components/telemetry/histogram_tools.py
@@ -69,30 +69,31 @@ def exponential_buckets(dmin, dmax, n_bu
         ret_array[bucket_index] = current
     return ret_array
 
 always_allowed_keys = ['kind', 'description', 'cpp_guard', 'expires_in_version',
                        'alert_emails', 'keyed', 'releaseChannelCollection',
                        'bug_numbers', 'record_in_processes']
 
 whitelists = None
-try:
-    whitelist_path = os.path.join(os.path.abspath(os.path.realpath(os.path.dirname(__file__))),
-                                  'histogram-whitelists.json')
-    with open(whitelist_path, 'r') as f:
-        try:
-            whitelists = json.load(f)
-            for name, whitelist in whitelists.iteritems():
-                whitelists[name] = set(whitelist)
-        except ValueError, e:
-            raise ParserError('Error parsing whitelist: %s' % whitelist_path)
-except IOError:
-    whitelists = None
-    print('Unable to parse whitelist: %s.\nAssuming all histograms are acceptable.' %
-          whitelist_path)
+
+def load_whitelist():
+    try:
+        whitelist_path = os.path.join(os.path.abspath(os.path.realpath(os.path.dirname(__file__))),
+                                      'histogram-whitelists.json')
+        with open(whitelist_path, 'r') as f:
+            try:
+                whitelists = json.load(f)
+                for name, whitelist in whitelists.iteritems():
+                    whitelists[name] = set(whitelist)
+            except ValueError, e:
+                raise ParserError('Error parsing whitelist: %s' % whitelist_path)
+    except IOError:
+        whitelists = None
+        raise ParserError('Unable to parse whitelist: %s.' % whitelist_path)
 
 
 class Histogram:
     """A class for representing a histogram definition."""
 
     def __init__(self, name, definition, strict_type_checks=False):
         """Initialize a histogram named name with the given definition.
 definition is a dict-like object that must contain at least the keys:
@@ -589,16 +590,19 @@ try:
 except ImportError:
     pass
 
 
 def from_files(filenames, strict_type_checks=True):
     """Return an iterator that provides a sequence of Histograms for
 the histograms defined in filenames.
     """
+    if strict_type_checks:
+        load_whitelist()
+
     all_histograms = OrderedDict()
     for filename in filenames:
         parser = FILENAME_PARSERS[os.path.basename(filename)]
         histograms = parser(filename, strict_type_checks)
 
         # OrderedDicts are important, because then the iteration order over
         # the parsed histograms is stable, which makes the insertion into
         # all_histograms stable, which makes ordering in generated files