Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
bug 761809 - fix mozinstall on windows. r=jhammel
Browse files Browse the repository at this point in the history
  • Loading branch information
escapewindow committed Jun 21, 2012
1 parent 9238b1d commit deefc89
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
6 changes: 1 addition & 5 deletions mozharness/base/python.py
Expand Up @@ -162,11 +162,7 @@ def install_module(self, module, module_url=None, install_method=None):
elif install_method == 'easy_install':
# Allow easy_install to be overridden by
# self.config['exes']['easy_install']
easy_install = self.query_exe('easy_install', default=self.query_python_path('easy_install'))
if isinstance(easy_install, list):
command = easy_install[:]
else:
command = [easy_install]
command = self.query_exe('easy_install', default=self.query_python_path('easy_install'), return_type="list")
else:
self.fatal("install_module() doesn't understand an install_method of %s!" % install_method)

Expand Down
22 changes: 20 additions & 2 deletions mozharness/base/script.py
Expand Up @@ -321,19 +321,37 @@ def query_env(self, partial_env=None, replace_dict=None,
self.env = env
return env

def query_exe(self, exe_name, exe_dict='exes', default=None):
def query_exe(self, exe_name, exe_dict='exes', default=None,
return_type=None, error_level=FATAL):
"""One way to work around PATH rewrites.
By default, return exe_name, and we'll fall through to searching
os.environ["PATH"].
However, if self.config[exe_dict][exe_name] exists, return that.
This lets us override exe paths via config file.
'return_type' can be None (don't do anything to the value),
'list' (return a list), or 'string' (return a string).
If we need runtime setting, we can build in self.exes support later.
"""
if default is None:
default = exe_name
return self.config.get(exe_dict, {}).get(exe_name, default)
exe = self.config.get(exe_dict, {}).get(exe_name, default)
if isinstance(exe, list):
exe = exe[:]
elif not isinstance(exe, str):
self.log("query_exe: %s is not a string or list: %s!" % (exe_name, str(exe)), level=error_level)
return exe
if return_type == "list":
if isinstance(exe, str):
exe = [exe]
elif return_type == "string":
if isinstance(exe, list):
exe = subprocess.list2cmdline(exe)
elif return_type is not None:
self.log("Unknown return_type type %s requested in query_exe!" % return_type, level=error_level)
return exe

def run_command(self, command, cwd=None, error_list=None, parse_at_end=False,
halt_on_failure=False, success_codes=None,
Expand Down
14 changes: 8 additions & 6 deletions mozharness/mozilla/testing/testbase.py
Expand Up @@ -182,17 +182,19 @@ def preflight_install(self):
def install(self):
""" Dependent on mozinstall """
# install the application
mozinstall = self.query_exe("mozinstall", default=self.query_python_path("mozinstall"))
if isinstance(mozinstall, list):
cmd = mozinstall[:]
else:
cmd = [mozinstall]
cmd = self.query_exe("mozinstall", default=self.query_python_path("mozinstall"), return_type="list")
# Remove the below when we no longer need to support mozinstall 0.3
self.info("Detecting whether we're running mozinstall >=1.0...")
output = self.get_output_from_command(cmd + ['-h'])
if '--source' in output:
cmd.append('--source')
# End remove
dirs = self.query_abs_dirs()
target_dir = dirs.get('abs_app_install_dir',
os.path.join(dirs['abs_work_dir'],
'application'))
self.mkdir_p(target_dir)
cmd.extend(['--source', self.installer_path,
cmd.extend([self.installer_path,
'--destination', target_dir])
# TODO we'll need some error checking here
self.binary_path = self.get_output_from_command(cmd)

0 comments on commit deefc89

Please sign in to comment.