<commit_before># encoding: utf-8

"""
This executable will install Navitia2 on an existing prepared debian8 image.
The resulting container can be commited with a default name.
"""


def absjoin(*p):
    return os.path.abspath(os.path.join(*p))

import os.path
ROOT = absjoin(__file__, '..', '..', '..')
import sys
import time
sys.path[0] = ROOT

from clingon import clingon
clingon.DEBUG = True

from navitia_docker_manager import DIM, FFD, utils

Dockerfile = """
FROM navitia/debian8:latest

"""

FINAL_IMAGE_NAME = 'navitia/debian8_simple'
CONTAINER_NAME = 'navitia_simple'


@clingon.clize
def factory(data_folder='', port='', folder='', commit=False):
    if DIM.DockerImageManager('', image_name=FINAL_IMAGE_NAME).exists:
        print("image {} already exists".format(FINAL_IMAGE_NAME))
        return
    drp = DIM.DockerRunParameters(
        hostname='navitia',
        volumes=(data_folder + ':/srv/ed/data',),
        ports=(port + ':80',)
    )
    df = DIM.DockerFile(
        Dockerfile=Dockerfile,
        parameters=drp
    )
    dim = DIM.DockerImageManager(df, parameters=drp)
    dim.build()
    dcm = dim.create_container(CONTAINER_NAME, start=True)
    ffd = FFD.FabricForDocker(dcm, user='navitia', platform='simple', distrib='debian8')
    time.sleep(5)
    with utils.chdir(folder):
        ffd.execute('deploy_from_scratch')
    if commit:
        dcm.stop().commit(FINAL_IMAGE_NAME).remove_container()
        dim.remove_image()<commit_msg>surround operation in try/finally<commit_after># encoding: utf-8

"""
This executable will install Navitia2 on an existing prepared debian8 image.
The resulting container can be commited with a default name.
"""


def absjoin(*p):
    return os.path.abspath(os.path.join(*p))

import os.path
ROOT = absjoin(__file__, '..', '..', '..')
import sys
import time
sys.path[0] = ROOT

from clingon import clingon
clingon.DEBUG = True

from navitia_docker_manager import DIM, FFD, utils

Dockerfile = """
FROM navitia/debian8:latest

"""

FINAL_IMAGE_NAME = 'navitia/debian8_simple'
CONTAINER_NAME = 'navitia_simple'


@clingon.clize
def factory(data_folder='', port='', folder='', commit=False):
    if DIM.DockerImageManager('', image_name=FINAL_IMAGE_NAME).exists:
        print("image {} already exists".format(FINAL_IMAGE_NAME))
        return
    drp = DIM.DockerRunParameters(
        hostname='navitia',
        volumes=(data_folder + ':/srv/ed/data',),
        ports=(port + ':80',)
    )
    df = DIM.DockerFile(
        Dockerfile=Dockerfile,
        parameters=drp
    )
    dim = DIM.DockerImageManager(df, parameters=drp)
    try:
        dim.build()
        dcm = dim.create_container(CONTAINER_NAME, start=True)
        ffd = FFD.FabricForDocker(dcm, user='navitia', platform='simple', distrib='debian8')
        time.sleep(5)
        with utils.chdir(folder):
            ffd.execute('deploy_from_scratch')
        if commit:
            dcm.stop().commit(FINAL_IMAGE_NAME).remove_container()
    finally:
        if commit:
            dim.remove_image()
{'fraction_non_alphanumeric': 0.13130979874628834, 'fraction_numerical': 0.006598482349059716, 'mean_word_length': 3.532137518684604, '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': '1850961', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1027, 'n_words': 208}