()
Check if TLJH is installable in current host system and exit with a clear
    error message otherwise.
Check if TLJH is installable in current host system and exit with a clear
    error message otherwise.
Check if TLJH is installable in current host system and exit with a clear error message otherwise .
def ensure_host_system_can_install_tljh():
    """
    Check if TLJH is installable in current host system and exit with a clear
    error message otherwise.
    """

    def get_os_release_variable(key):
        """
        Return value for key from /etc/os-release

        /etc/os-release is a bash file, so should use bash to parse it.

        Returns empty string if key is not found.
        """
        return (
            subprocess.check_output(
                [
                    "/bin/bash",
                    "-c",
                    "source /etc/os-release && echo ${{{key}}}".format(key=key),
                ]
            )
            .decode()
            .strip()
        )

    # Require 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)

    # Require Python 3.6+
    if sys.version_info < (3, 6):
        print("bootstrap.py must be run with at least Python 3.6")
        sys.exit(1)

    # Require systemd (systemctl is a part of systemd)
    if not shutil.which("systemd") or not shutil.which("systemctl"):
        print("Systemd is required to run TLJH")
        # Provide additional information about running in docker containers
        if os.path.exists("/.dockerenv"):
            print("Running inside a docker container without systemd isn't supported")
            print(
                "We recommend against running a production TLJH instance inside a docker container"
            )
            print(
                "For local development, see http://tljh.jupyter.org/en/latest/contributing/dev-setup.html"
            )
        sys.exit(1)
def ensure_host_system_can_install_tljh ( ) : def get_os_release_variable ( key ) : """
        Return value for key from /etc/os-release

        /etc/os-release is a bash file, so should use bash to parse it.

        Returns empty string if key is not found.
        """ return ( subprocess . check_output ( [ "/bin/bash" , "-c" , "source /etc/os-release && echo ${{{key}}}" . format ( key = key ) , ] ) . decode ( ) . strip ( ) ) # Require 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 ) # Require Python 3.6+ if sys . version_info < ( 3 , 6 ) : print ( "bootstrap.py must be run with at least Python 3.6" ) sys . exit ( 1 ) # Require systemd (systemctl is a part of systemd) if not shutil . which ( "systemd" ) or not shutil . which ( "systemctl" ) : print ( "Systemd is required to run TLJH" ) # Provide additional information about running in docker containers if os . path . exists ( "/.dockerenv" ) : print ( "Running inside a docker container without systemd isn't supported" ) print ( "We recommend against running a production TLJH instance inside a docker container" ) print ( "For local development, see http://tljh.jupyter.org/en/latest/contributing/dev-setup.html" ) sys . exit ( 1 )