<commit_before>import os

import docker
import logging

from ...log import log_to_client
from ...subprocess import check_output_demoted
from ...compiler.spec_assembler import get_specs

def _exec_in_container(client, container, command, *args):
    exec_instance = client.exec_create(container['Id'],
                                       ' '.join([command] + list(args)))
    return client.exec_start(exec_instance['Id'])

def get_dusty_images():
    """Returns all images listed in dusty specs (apps + bundles), in the form repository:tag.  Tag will be set to latest
    if no tag is specified in the specs"""
    specs = get_specs()
    dusty_image_names = [spec['image'] for spec in specs['apps'].values() + specs['services'].values() if 'image' in spec]
    dusty_images = set([name  if ':' in name else "{}:latest".format(name) for name in dusty_image_names])
    return dusty_images

def get_dusty_container_name(service_name):
    return 'dusty_{}_1'.format(service_name)

def _get_set_envs():
    env = {}
    environment_variables = os.environ
    if 'DOCKER_HOST' in environment_variables:
        env['DOCKER_HOST'] = environment_variables['DOCKER_HOST']
    if 'DOCKER_CERT_PATH' in environment_variables:
        env['DOCKER_CERT_PATH'] = environment_variables['DOCKER_CERT_PATH']
    if 'DOCKER_TLS_VERIFY' in environment_variables:
        env['DOCKER_TLS_VERIFY'] = environment_variables['DOCKER_TLS_VERIFY']
    return env

def get_docker_env():
    env = _get_set_envs()
    if len(env.keys()) < 3:
        output = check_output_demoted(['boot2docker', 'shellinit'])
        for line in output.splitlines():
            if not line.strip().startswith('export'):
                continue
            k, v = line.strip().split()[1].split('=')
            env[k] = v<commit_msg>switch stuff up<commit_after>import os

import docker
import logging

from ...log import log_to_client
from ...subprocess import check_output_demoted
from ...compiler.spec_assembler import get_specs

def _exec_in_container(client, container, command, *args):
    exec_instance = client.exec_create(container['Id'],
                                       ' '.join([command] + list(args)))
    return client.exec_start(exec_instance['Id'])

def get_dusty_images():
    """Returns all images listed in dusty specs (apps + bundles), in the form repository:tag.  Tag will be set to latest
    if no tag is specified in the specs"""
    specs = get_specs()
    dusty_image_names = [spec['image'] for spec in specs['apps'].values() + specs['services'].values() if 'image' in spec]
    dusty_images = set([name  if ':' in name else "{}:latest".format(name) for name in dusty_image_names])
    return dusty_images

def get_dusty_container_name(service_name):
    return 'dusty_{}_1'.format(service_name)

def _get_set_envs():
    env = {}
    environment_variables = os.environ
    for key in ('DOCKER_HOST', 'DOCKER_CERT_PATH', 'DOCKER_TLS_VERIFY'):
        if key in environment_variables:
            env[key] = environment_variables[key]
    return env

def get_docker_env():
    env = _get_set_envs()
    if len(env.keys()) < 3:
        output = check_output_demoted(['boot2docker', 'shellinit'], redirect_stderr=True)
        for line in output.splitlines():
            if not line.strip().startswith('export'):
                continue
            k, v = line.strip().split()[1].split('=')
            env[k] = v
{'fraction_non_alphanumeric': 0.1200822078684674, 'fraction_numerical': 0.002348796241926013, 'mean_word_length': 3.4711286089238844, 'pattern_counts': {'":': 0, '<': 5, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4916415', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1036, 'n_words': 268}