<commit_before>"""
Fabric tools for managing Debian/Ubuntu packages
"""
from fabric.api import *


def is_installed(pkg_name):
    """
    Check if .deb package is installed
    """
    with settings(hide('running', 'stdout', 'stderr', 'warnings'), warn_only=True):
        res = run("dpkg -s %(pkg_name)s" % locals())
        return res.succeeded


def install_package(pkg_name, update=False):
    """
    Install .deb package
    """
    if update:
        sudo("aptitude -q -q update")   # quietly update package list
    options = "--assume-yes"
    sudo('aptitude install %(options)s %(pkg_name)s' % locals())


def install_packages(pkg_list, update=False):
    """
    Install several .deb packages
    """
    if update:
        sudo("aptitude -q -q update")   # quietly update package list
    pkg_names = ' '.join(pkg_list)
    options = "--assume-yes"
    sudo('aptitude install %(options)s %(pkg_names)s' % locals())<commit_msg>Added preseeding of packages for unattended install.<commit_after>"""
Fabric tools for managing Debian/Ubuntu packages
"""
from fabric.api import *


def is_installed(pkg_name):
    """
    Check if .deb package is installed
    """
    with settings(hide('running', 'stdout', 'stderr', 'warnings'), warn_only=True):
        res = run("dpkg -s %(pkg_name)s" % locals())
        return res.succeeded


def install_package(pkg_name, update=False):
    """
    Install .deb package
    """
    if update:
        sudo("aptitude -q -q update")   # quietly update package list
    options = "--assume-yes"
    sudo('aptitude install %(options)s %(pkg_name)s' % locals())


def install_packages(pkg_list, update=False):
    """
    Install several .deb packages
    """
    if update:
        sudo("aptitude -q -q update")   # quietly update package list
    pkg_names = ' '.join(pkg_list)
    options = "--assume-yes"
    sudo('aptitude install %(options)s %(pkg_names)s' % locals())


def preseed_package(pkg_name, preseed):
    """
    Enable unattended package installation by preseeding debconf parameters
    """
    for q_name, _ in preseed.items():
        q_type, q_answer = _
        sudo('echo "%(pkg_name)s %(q_name)s %(q_type)s %(q_answer)s" | debconf-set-selections' % locals())
{'fraction_non_alphanumeric': 0.14202247191011236, 'fraction_numerical': 0.0, 'mean_word_length': 3.2319391634980987, 'pattern_counts': {'":': 0, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3658504', 'n_tokens_mistral': 734, 'n_tokens_neox': 691, 'n_words': 189}