зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1168409 - part 1 - avoid importing buildconfig in histogram_tools.py; r=gfritzsche
histogram_tools.py is used by in-tree and out-of-tree consumers, so we need to be aware of that when using build-time-only modules like buildconfig.
This commit is contained in:
Родитель
1bc8d0eab9
Коммит
87ed663512
|
@ -2,15 +2,28 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import buildconfig
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
# Need to update sys.path to be able to find usecounters.
|
||||
sys.path.append(os.path.join(buildconfig.topsrcdir, 'dom/base/'))
|
||||
# histogram_tools.py is used by scripts from a mozilla-central build tree
|
||||
# and also by outside consumers, such as the telemetry server. We need
|
||||
# to ensure that importing things works in both contexts. Therefore,
|
||||
# unconditionally importing things that are local to the build tree, such
|
||||
# as buildconfig, is a no-no.
|
||||
try:
|
||||
import buildconfig
|
||||
|
||||
# Need to update sys.path to be able to find usecounters.
|
||||
sys.path.append(os.path.join(buildconfig.topsrcdir, 'dom/base/'))
|
||||
except ImportError:
|
||||
# Must be in an out-of-tree usage scenario. Trust that whoever is
|
||||
# running this script knows we need the usecounters module and has
|
||||
# ensured it's in our sys.path.
|
||||
pass
|
||||
|
||||
import usecounters
|
||||
|
||||
from collections import OrderedDict
|
||||
|
|
Загрузка…
Ссылка в новой задаче