<commit_before>import os
from config import CONFIG


def configure_git():
    resp1 = os.system("git config --global user.email \"%s\"" % CONFIG["email"])
    resp2 = os.system("git config --global user.name \"%s\"" % CONFIG["name"])

    if resp1 + resp2 == 0:
        print("git configuration .... OK")
    else:
        print("git configuration .... KO")


def install_packages():
    """
    Install useful packages
    :return:
    """
    utils_packages = ("build-essential", "git", "tree", "git-flow", "vim", "maven", "supervisor", "php", "libapache2-mod-php", "apache2", "php-mcrypt",
                      "mysql-server", "php-mysql", "phpmyadmin", "php-mbstring", "php-gettext", "php-sqlite3", "atool", "ipython", "python3-setuptools", "python3-mysqldb", "php-gettext", "php-xdebug", "libapache2-mod-php7.0",
                      "ssh", "gimp", "curl", "terminator", "zsh", "npm", "vsftpd")

    status = []

    install_ok = 0  # number of installed packages

    total = len(utils_packages)  # number of packages to install

    print("---- Starting packages installation  ----")
    for package in utils_packages:
        resp = os.system("sudo apt-get install %s -y" % package)

        # set installation status
        if resp != 0:
            status.append("Install %s .... KO" % package)
        else:
            install_ok += 1
            status.append("Install %s .... OK" % package)

    # Extra installation
    # - pip installation
    total += 1
    resp = os.system("sudo easy_install3 pip")
    if resp != 0:
        status.append("Install pip .... KO")
    else:
        install_ok += 1
        os.system("sudo pip install --upgrade pip")
        status.append("Install pip .... OK")

    print("---- End of packages installation  ----")

    for s in status:
        print(s)
    print("Report: %d/%d packages installed" % (install_ok, total))


# Installing JDK7 JDK8
def install_oracle_jdk():
    """
    Install oracle version of JDK7 and JDK8
    :return:
    """
    os.system("sudo apt-get install -y software-properties-common")
    os.system("sudo add-apt-repository ppa:webupd8team/java")
    os.system("sudo apt-get update")
    os.system("sudo apt-get install -y oracle-java7-installer oracle-java8-installer")

    print("Installing Java7 OK ...")


def install_npm_modules():
    """
    Install some npm modules
    :return:
    """
    os.system("sudo ln -sf /usr/bin/nodejs /usr/bin/node")
    modules = ["npm", "yo", "gulp-cli", "bower", "generator-angular"]

    for mod in modules:
        os.system("sudo npm install -g %s" % mod)


def configure_hosts():
    """<commit_msg>updating npm installation<commit_after>import os
from config import CONFIG


def configure_git():
    resp1 = os.system("git config --global user.email \"%s\"" % CONFIG["email"])
    resp2 = os.system("git config --global user.name \"%s\"" % CONFIG["name"])

    if resp1 + resp2 == 0:
        print("git configuration .... OK")
    else:
        print("git configuration .... KO")


def install_packages():
    """
    Install useful packages
    :return:
    """
    utils_packages = ("build-essential", "git", "tree", "git-flow", "vim", "maven", "supervisor", "php", "libapache2-mod-php", "apache2", "php-mcrypt",
                      "mysql-server", "php-mysql", "phpmyadmin", "php-mbstring", "php-gettext", "php-sqlite3", "atool", "ipython", "python3-setuptools", "python3-mysqldb", "php-gettext", "php-xdebug", "libapache2-mod-php7.0",
                      "ssh", "gimp", "curl", "terminator", "zsh", "npm", "vsftpd")

    status = []

    install_ok = 0  # number of installed packages

    total = len(utils_packages)  # number of packages to install

    print("---- Starting packages installation  ----")
    for package in utils_packages:
        resp = os.system("sudo apt-get install %s -y" % package)

        # set installation status
        if resp != 0:
            status.append("Install %s .... KO" % package)
        else:
            install_ok += 1
            status.append("Install %s .... OK" % package)

    # Extra installation
    # - pip installation
    total += 1
    resp = os.system("sudo easy_install3 pip")
    if resp != 0:
        status.append("Install pip .... KO")
    else:
        install_ok += 1
        os.system("sudo pip install --upgrade pip")
        status.append("Install pip .... OK")

    print("---- End of packages installation  ----")

    for s in status:
        print(s)
    print("Report: %d/%d packages installed" % (install_ok, total))


# Installing JDK7 JDK8
def install_oracle_jdk():
    """
    Install oracle version of JDK7 and JDK8
    :return:
    """
    os.system("sudo apt-get install -y software-properties-common")
    os.system("sudo add-apt-repository ppa:webupd8team/java")
    os.system("sudo apt-get update")
    os.system("sudo apt-get install -y oracle-java7-installer oracle-java8-installer")

    print("Installing Java7 OK ...")


def install_npm_modules():
    """
    Install some npm modules
    :return:
    """
    os.system("sudo ln -sf /usr/bin/nodejs /usr/bin/node")
    modules = ["npm", "yo", "gulp-cli", "bower", "generator-angular"]

    for mod in modules:
        os.system("sudo npm install -g %s" % mod)
    
    os.system("sudo apt remove nodejs npm")
    os.system("curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -")
    os.system("sudo apt-get install -y nodejs")


def configure_hosts():
    """
{'fraction_non_alphanumeric': 0.16277787984567335, 'fraction_numerical': 0.010472166084879662, 'mean_word_length': 2.530479896238651, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1238873', 'n_tokens_mistral': 1812, 'n_tokens_neox': 1675, 'n_words': 464}