mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Do not use deprecated platform module
Since bootstrap.py needs to restrict itself to stdlib python, we read from /etc/os-release than trying to install the distro package.
This commit is contained in:
@@ -16,18 +16,33 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import platform
|
|
||||||
|
|
||||||
# Support only Ubuntu 18.04+
|
|
||||||
distro, version, _ = platform.linux_distribution()
|
def get_os_release_variable(key):
|
||||||
if distro != 'Ubuntu':
|
"""
|
||||||
print('The Littlest JupyterHub currently supports Ubuntu Linux only')
|
Return value for key from /etc/os-release
|
||||||
sys.exit(1)
|
|
||||||
elif float(version) < 18.04:
|
/etc/os-release is a bash file, so should use bash to parse it.
|
||||||
print('The Littlest JupyterHub requires Ubuntu 18.04 or higher')
|
|
||||||
sys.exit(1)
|
Returns empty string if key is not found.
|
||||||
|
"""
|
||||||
|
return subprocess.check_output([
|
||||||
|
'/bin/bash', '-c',
|
||||||
|
"source /etc/os-release && echo $\{{key}\}".format(key=key)
|
||||||
|
]).split()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
# Support only Ubuntu 18.04+
|
||||||
|
distro = get_os_release_variable('ID')
|
||||||
|
version = float(get_os_release_variable('VERSION_ID'))
|
||||||
|
if distro != 'ubuntu':
|
||||||
|
print('The Littlest JupyterHub currently supports Ubuntu Linux only')
|
||||||
|
sys.exit(1)
|
||||||
|
elif float(version) < 18.04:
|
||||||
|
print('The Littlest JupyterHub requires Ubuntu 18.04 or higher')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
install_prefix = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh')
|
install_prefix = os.environ.get('TLJH_INSTALL_PREFIX', '/opt/tljh')
|
||||||
hub_prefix = os.path.join(install_prefix, 'hub')
|
hub_prefix = os.path.join(install_prefix, 'hub')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user