<commit_before>#!/usr/bin/python

import os
import uuid
import subprocess
import sys

def get_cid_path():
    filename = 'amara-dev-manage-%s' % (uuid.uuid1().hex[:10],)
    return os.path.abspath(os.path.join(
        os.path.dirname(__file__), 'cidfiles', filename))

def get_cid(cidpath):
    return open(cidpath).read().strip()

def run_manage(manage_args, docker_args=None, settings='docker_dev_settings'):
    cidpath = get_cid_path()
    unisubs_root = os.path.abspath(os.path.join(
        os.path.dirname(__file__), '..'))
    volume_arg = '%s:/opt/apps/unisubs' % (unisubs_root,)
    run_cmd = [
        '/usr/bin/docker', 'run',
        '-i', '-t',
        '-cidfile=%s' % cidpath,
        '-e', 'DJANGO_SETTINGS_MODULE=%s' % settings,
        '-v', volume_arg,
        '-w', '/opt/apps/unisubs/',
    ]
    if docker_args:
        run_cmd.extend(docker_args)
    run_cmd.extend([
        'amara-dev',
        '/opt/ve/unisubs/bin/python',
        '/opt/apps/unisubs/manage.py',
    ] + manage_args)
    subprocess.check_call(run_cmd)
    cid = get_cid(cidpath)
    with open("/dev/null", "w") as dev_null:
        subprocess.check_call(['/usr/bin/docker', 'stop', cid],
                              stdout=dev_null)
        subprocess.check_call(['/usr/bin/docker', 'wait', cid],
                              stdout=dev_null)
        subprocess.check_call(['/usr/bin/docker', 'rm', cid],
                              stdout=dev_null)
    os.unlink(cidpath)

if __name__ == '__main__':
    run_manage(sys.argv[1:])<commit_msg>Use the shell to find docker<commit_after>#!/usr/bin/python

import os
import uuid
import subprocess
import sys

def get_cid_path():
    filename = 'amara-dev-manage-%s' % (uuid.uuid1().hex[:10],)
    return os.path.abspath(os.path.join(
        os.path.dirname(__file__), 'cidfiles', filename))

def get_cid(cidpath):
    return open(cidpath).read().strip()

def run_manage(manage_args, docker_args=None, settings='docker_dev_settings'):
    cidpath = get_cid_path()
    unisubs_root = os.path.abspath(os.path.join(
        os.path.dirname(__file__), '..'))
    volume_arg = '%s:/opt/apps/unisubs' % (unisubs_root,)
    run_cmd = [
        'docker', 'run',
        '-i', '-t',
        '-cidfile=%s' % cidpath,
        '-e', 'DJANGO_SETTINGS_MODULE=%s' % settings,
        '-v', volume_arg,
        '-w', '/opt/apps/unisubs/',
    ]
    if docker_args:
        run_cmd.extend(docker_args)
    run_cmd.extend([
        'amara-dev',
        '/opt/ve/unisubs/bin/python',
        '/opt/apps/unisubs/manage.py',
    ] + manage_args)
    subprocess.check_call(" ".join(run_cmd), shell=True)
    cid = get_cid(cidpath)
    with open("/dev/null", "w") as dev_null:
        subprocess.check_call("docker stop %s" % cid, shell=True,
                              stdout=dev_null)
        subprocess.check_call("docker wait %s" % cid, shell=True,
                              stdout=dev_null)
        subprocess.check_call("docker rm %s" % cid, shell=True,
                              stdout=dev_null)
    os.unlink(cidpath)

if __name__ == '__main__':
    run_manage(sys.argv[1:])
{'fraction_non_alphanumeric': 0.1628131021194605, 'fraction_numerical': 0.002569043031470777, 'mean_word_length': 2.4688195991091315, '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': '6937625', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1128, 'n_words': 176}