Bug 882461 - add mozbase packages to sys.path in automation, r=jhammel

This commit is contained in:
Andrew Halberstadt
2013-06-17 13:22:39 -07:00
parent 24f40e484e
commit dae19acbd0
2 changed files with 12 additions and 24 deletions

View File

@@ -30,17 +30,12 @@ import automationutils
here = os.path.dirname(__file__)
mozbase = os.path.realpath(os.path.join(os.path.dirname(here), 'mozbase'))
try:
import mozcrash
except:
deps = ['mozcrash',
'mozfile',
'mozlog']
for dep in deps:
module = os.path.join(mozbase, dep)
if module not in sys.path:
sys.path.append(module)
if os.path.isdir(mozbase):
for package in os.listdir(mozbase):
sys.path.append(os.path.join(mozbase, package))
import mozcrash
# ---------------------------------------------------------------
_DEFAULT_PREFERENCE_FILE = os.path.join(SCRIPT_DIR, 'prefs_general.js')

View File

@@ -11,7 +11,6 @@ from optparse import OptionParser
from subprocess import Popen, PIPE, STDOUT
from tempfile import mkdtemp, gettempdir
from threading import Timer
import mozinfo
import random
import socket
import time
@@ -27,19 +26,13 @@ HARNESS_TIMEOUT = 5 * 60
here = os.path.dirname(__file__)
mozbase = os.path.realpath(os.path.join(os.path.dirname(here), 'mozbase'))
# hand enumerate our own deps
modules = [('mozcrash', ['mozcrash', 'mozfile', 'mozlog']),
('manifestparser', ['manifestdestiny'])]
if os.path.isdir(mozbase):
for package in os.listdir(mozbase):
sys.path.append(os.path.join(mozbase, package))
for module, deps in modules:
try:
globals()[module] = __import__(module)
except ImportError:
for dep in deps:
module_path = os.path.join(mozbase, dep)
if module_path not in sys.path:
sys.path.append(module_path)
globals()[module] = __import__(module)
import manifestparser
import mozcrash
import mozinfo
# ---------------------------------------------------------------
#TODO: replace this with json.loads when Python 2.6 is required.