<commit_before>#!/usr/bin/env python

# Force Python 2 to use float division even for ints
from __future__ import division
from __future__ import print_function

import logging
import os
import re
import sys

import stacktrain.core.cond_sleep as cs
import stacktrain.core.download as dl
import stacktrain.core.keycodes as kc
import stacktrain.config.general as conf
import stacktrain.distros.distro as distro

logger = logging.getLogger(__name__)

conf.base_install_scripts = "scripts.ubuntu_base"
conf.distro = "ubuntu"

# -----------------------------------------------------------------------------
# Installation from ISO image
# -----------------------------------------------------------------------------


class ISOImage(distro.GenericISOImage):

    def __init__(self, arch="amd64"):
        super(ISOImage, self).__init__()
        self.arch = arch
        if arch == "amd64":
            self.release_name = "ubuntu-16.04-amd64"
            self.url = ("http://releases.ubuntu.com/16.04/"
                        "ubuntu-16.04.5-server-amd64.iso")
            self.md5 = "24636fd103a2a43c95659f1c3c63718e"
            # ostype used by VirtualBox to choose icon and flags (64-bit,
            # IOAPIC)
            conf.vbox_ostype = "Ubuntu_64"
        elif arch == "i386":
            self.url = ("http://releases.ubuntu.com/16.04/"
                        "ubuntu-16.04.5-server-i386.iso")
            self.release_name = "ubuntu-16.04-i386"
            self.md5 = "9ba5fefe27685ae69f991c45396080af"
            conf.vbox_ostype = "Ubuntu"
        else:
            logger.error("Unknown arch: %s. Aborting.", arch)
            sys.exit(1)


    # Fallback function to find current ISO image in case the file in ISO_URL
    # is neither on the disk nor at the configured URL. This mechanism was
    # added because old Ubuntu ISOs are removed from the server as soon as a
    # new ISO appears.

    def update_iso_image_variables(self):

        # Get matching line from distro repo's MD5SUMS file, e.g.
        # "9e5fecc94b3925bededed0fdca1bd417 *ubuntu-14.04.3-server-amd64.iso"
        md5_url = os.path.join(self.url_base, "MD5SUMS")
        logger.debug("About to download MD5SUM from %s", md5_url)
        try:
            txt = dl.downloader.download(md5_url)
        except EnvironmentError:
            logger.error("Can't find newer ISO image. Aborting.")
            sys.exit(1)
<commit_msg>Update Ubuntu LTS ISO to 16.04.6<commit_after>#!/usr/bin/env python

# Force Python 2 to use float division even for ints
from __future__ import division
from __future__ import print_function

import logging
import os
import re
import sys

import stacktrain.core.cond_sleep as cs
import stacktrain.core.download as dl
import stacktrain.core.keycodes as kc
import stacktrain.config.general as conf
import stacktrain.distros.distro as distro

logger = logging.getLogger(__name__)

conf.base_install_scripts = "scripts.ubuntu_base"
conf.distro = "ubuntu"

# -----------------------------------------------------------------------------
# Installation from ISO image
# -----------------------------------------------------------------------------


class ISOImage(distro.GenericISOImage):

    def __init__(self, arch="amd64"):
        super(ISOImage, self).__init__()
        self.arch = arch
        if arch == "amd64":
            self.release_name = "ubuntu-16.04-amd64"
            self.url = ("http://releases.ubuntu.com/16.04/"
                        "ubuntu-16.04.6-server-amd64.iso")
            self.md5 = "ac8a79a86a905ebdc3ef3f5dd16b7360"
            # ostype used by VirtualBox to choose icon and flags (64-bit,
            # IOAPIC)
            conf.vbox_ostype = "Ubuntu_64"
        elif arch == "i386":
            self.url = ("http://releases.ubuntu.com/16.04/"
                        "ubuntu-16.04.6-server-i386.iso")
            self.release_name = "ubuntu-16.04-i386"
            self.md5 = "1817138b1a181507c5ebd5ec8a3f40ba"
            conf.vbox_ostype = "Ubuntu"
        else:
            logger.error("Unknown arch: %s. Aborting.", arch)
            sys.exit(1)


    # Fallback function to find current ISO image in case the file in ISO_URL
    # is neither on the disk nor at the configured URL. This mechanism was
    # added because old Ubuntu ISOs are removed from the server as soon as a
    # new ISO appears.

    def update_iso_image_variables(self):

        # Get matching line from distro repo's MD5SUMS file, e.g.
        # "9e5fecc94b3925bededed0fdca1bd417 *ubuntu-14.04.3-server-amd64.iso"
        md5_url = os.path.join(self.url_base, "MD5SUMS")
        logger.debug("About to download MD5SUM from %s", md5_url)
        try:
            txt = dl.downloader.download(md5_url)
        except EnvironmentError:
            logger.error("Can't find newer ISO image. Aborting.")
            sys.exit(1)

{'fraction_non_alphanumeric': 0.15289511642283124, 'fraction_numerical': 0.049660004121162164, 'mean_word_length': 1.985239852398524, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7584665', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1433, 'n_words': 379}