mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
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:
11
tljh/apt.py
11
tljh/apt.py
@@ -3,6 +3,7 @@ Utilities for working with the apt package manager
|
||||
"""
|
||||
import os
|
||||
import subprocess
|
||||
from tljh import utils
|
||||
|
||||
|
||||
def trust_gpg_key(key):
|
||||
@@ -14,7 +15,7 @@ def trust_gpg_key(key):
|
||||
# If gpg2 doesn't exist, install it.
|
||||
if not os.path.exists('/usr/bin/gpg2'):
|
||||
install_packages(['gnupg2'])
|
||||
subprocess.check_output(['apt-key', 'add', '-'], input=key, stderr=subprocess.STDOUT)
|
||||
utils.run_subprocess(['apt-key', 'add', '-'], input=key)
|
||||
|
||||
|
||||
def add_source(name, source_url, section):
|
||||
@@ -32,7 +33,7 @@ def add_source(name, source_url, section):
|
||||
f.seek(0)
|
||||
f.write(line)
|
||||
f.truncate()
|
||||
subprocess.check_output(['apt-get', 'update', '--yes'], stderr=subprocess.STDOUT)
|
||||
utils.run_subprocess(['apt-get', 'update', '--yes'])
|
||||
|
||||
|
||||
def install_packages(packages):
|
||||
@@ -41,9 +42,9 @@ def install_packages(packages):
|
||||
"""
|
||||
# Check if an apt-get update is required
|
||||
if len(os.listdir('/var/lib/apt/lists')) == 0:
|
||||
subprocess.check_output(['apt-get', 'update', '--yes'], stderr=subprocess.STDOUT)
|
||||
subprocess.check_output([
|
||||
utils.run_subprocess(['apt-get', 'update', '--yes'])
|
||||
utils.run_subprocess([
|
||||
'apt-get',
|
||||
'install',
|
||||
'--yes'
|
||||
] + packages, stderr=subprocess.STDOUT)
|
||||
] + packages)
|
||||
|
||||
Reference in New Issue
Block a user