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