Provide much better error messages

- When processes fail, they actually print a failure message
  on the user's terminal
- Regardless of success or failure, we print all output to
  /opt/tljh/installer.log

This should make debugging people's issues *much* easier, since
we can actually see the output of failing commands rather than
having to guess.
This commit is contained in:
yuvipanda
2019-05-19 13:45:57 -07:00
parent 190b61d953
commit 7071332445
5 changed files with 99 additions and 29 deletions

View File

@@ -9,6 +9,7 @@ import contextlib
import tempfile
import requests
from distutils.version import LooseVersion as V
from tljh import utils
def md5_file(fname):
@@ -68,22 +69,22 @@ def fix_permissions(prefix):
Run after each install command.
"""
subprocess.check_call(
utils.run_subprocess(
["chown", "-R", "{}:{}".format(os.getuid(), os.getgid()), prefix]
)
subprocess.check_call(["chmod", "-R", "o-w", prefix])
utils.run_subprocess(["chmod", "-R", "o-w", prefix])
def install_miniconda(installer_path, prefix):
"""
Install miniconda with installer at installer_path under prefix
"""
subprocess.check_output([
utils.run_subprocess([
'/bin/bash',
installer_path,
'-u', '-b',
'-p', prefix
], stderr=subprocess.STDOUT)
])
# fix permissions on initial install
# a few files have the wrong ownership and permissions initially
# when the installer is run as root
@@ -128,10 +129,10 @@ def ensure_pip_packages(prefix, packages):
abspath = os.path.abspath(prefix)
pip_executable = [os.path.join(abspath, 'bin', 'python'), '-m', 'pip']
subprocess.check_output(pip_executable + [
utils.run_subprocess(pip_executable + [
'install',
'--no-cache-dir',
] + packages, stderr=subprocess.STDOUT)
] + packages)
fix_permissions(prefix)
@@ -144,9 +145,9 @@ def ensure_pip_requirements(prefix, requirements_path):
abspath = os.path.abspath(prefix)
pip_executable = [os.path.join(abspath, 'bin', 'python'), '-m', 'pip']
subprocess.check_output(pip_executable + [
utils.run_subprocess(pip_executable + [
'install',
'-r',
requirements_path
], stderr=subprocess.STDOUT)
])
fix_permissions(prefix)