<commit_before># -*- encoding: utf-8

import os
import shutil
import sys

import click
import docker
import requests

from . import Site


@click.group()
def cli():
    pass


@cli.command('build', help='(re)build the HTML for the website')
def build():
    """
    Take the content folder and build it.
    """
    site = Site.from_folder('content')
    site.build()


@cli.command('clean', help='remove the generated HTML')
def clean():
    """
    Delete the output folder, if it exists.
    """
    try:
        shutil.rmtree('output')
    except FileNotFoundError:
        pass


@cli.command('serve', help='serve the generated website on a local port')
@click.option('--port', default=9000, help='port for the web server',
              type=click.IntRange(1024, 65535))
def serve(port):
    """
    Start a local web server for the site.
    """
    site = Site.from_folder('content')
    site.build()

    # Set up the Docker API
    client = docker.from_env()

    # Check that Docker is available
    try:
        client.info()
    except requests.exceptions.ConnectionError:
        sys.exit('Unable to connect to Docker.')

    # Start the container
    try:
        client.containers.run(
            image='httpd',
            detach=True,
            ports={port: 80},
            read_only=True,
            volumes={
                os.path.abspath(site.out_path): {
                    'bind': '/usr/local/apache2/htdocs',
                    'mode': 'ro',
                },
            },
        )
    except docker.errors.APIError as err:
        sys.exit('Error starting the Docker container:\n%s' % err)

    print('Web server running on http://localhost:%d/' % port)


@cli.command('publish', help='build the HTML for publication')
def publish():<commit_msg>Fix some small issues with the Docker command<commit_after># -*- encoding: utf-8

import os
import shutil
import sys

import click
import docker
import requests

from . import Site


@click.group()
def cli():
    pass


@cli.command('build', help='(re)build the HTML for the website')
def build():
    """
    Take the content folder and build it.
    """
    site = Site.from_folder('content')
    site.build()


@cli.command('clean', help='remove the generated HTML')
def clean():
    """
    Delete the output folder, if it exists.
    """
    try:
        shutil.rmtree('output')
    except FileNotFoundError:
        pass


@cli.command('serve', help='serve the generated website on a local port')
@click.option('--port', default=9000, help='port for the web server',
              type=click.IntRange(1024, 65535))
def serve(port):
    """
    Start a local web server for the site.
    """
    site = Site.from_folder('content')
    site.build()

    # Set up the Docker API
    client = docker.from_env()

    # Check that Docker is available
    try:
        client.info()
    except requests.exceptions.ConnectionError:
        sys.exit('Unable to connect to Docker.')

    # Start the container
    try:
        client.containers.run(
            image='httpd',
            detach=True,
            ports={80: port},
            volumes={
                os.path.abspath(site.out_path): {
                    'bind': '/usr/local/apache2/htdocs',
                    'mode': 'ro',
                },
            },
        )
    except docker.errors.APIError as err:
        sys.exit('Error starting the Docker container:\n%s' % err)

    print('Web server running on http://localhost:%d/' % port)


@cli.command('publish', help='build the HTML for publication')
def publish():
{'fraction_non_alphanumeric': 0.12717086834733893, 'fraction_numerical': 0.009523809523809525, 'mean_word_length': 2.2912442396313364, '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': '321193', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1013, 'n_words': 309}