<commit_before>import errno
import os
import shlex
import signal
import subprocess
import tempfile
import time

import config
from fishbox import wiring


def lock_exists():
    return os.path.isfile(config.LOCKFILE)


def lock_data():
    if not lock_exists():
        return {'running': False}

    with open(config.LOCKFILE, 'r') as f:
        pid, starttime, runtime = (int(line) for line in f)
        return {'running': True,
                'pid': pid,
                'starttime': starttime,
                'runtime': runtime,
                'curtime': int(time.time())
                }


_raspistill = None
_imgfile = None


def start_img_stream(width=648):
    global _raspistill, _imgfile

    stop_img_stream()

    height = int(width / 4 * 3)  # maintain 4:3 aspect ratio
    #txtsize = max(16, int(height/20))

    _imgfile = tempfile.NamedTemporaryFile('rb')

    cmdargs = ['raspistill',<commit_msg>Docstring for get_image()<commit_after>import errno
import os
import shlex
import signal
import subprocess
import tempfile
import time

import config
from fishbox import wiring


def lock_exists():
    return os.path.isfile(config.LOCKFILE)


def lock_data():
    if not lock_exists():
        return {'running': False}

    with open(config.LOCKFILE, 'r') as f:
        pid, starttime, runtime = (int(line) for line in f)
        return {'running': True,
                'pid': pid,
                'starttime': starttime,
                'runtime': runtime,
                'curtime': int(time.time())
                }


_raspistill = None
_imgfile = None


def start_img_stream(width=648):
    ''' Starts capturing a stream of images at the given width.
        Sets global _raspistill object to be the running subprocess
        if successful.

        Raises OSError if "raspistill" binary not found, etc.
    '''
    global _raspistill, _imgfile

    stop_img_stream()

    height = int(width / 4 * 3)  # maintain 4:3 aspect ratio
    #txtsize = max(16, int(height/20))

    _imgfile = tempfile.NamedTemporaryFile('rb')

    cmdargs = ['raspistill',
{'fraction_non_alphanumeric': 0.10028929604628736, 'fraction_numerical': 0.010607521697203472, 'mean_word_length': 2.5899653979238755, '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': '5797356', 'n_tokens_mistral': 671, 'n_tokens_neox': 623, 'n_words': 192}