<commit_before>import io
import socket
import struct
import time
import picamera
from openRetina import openRetina
ret = openRetina()
# Connect a client socket to my_server:8000 (change my_server to the
# hostname of your server)
client_socket = socket.socket()
client_socket.connect((ret.ip, 8000))
count = 0
# Make a file-like object out of the connection
connection = client_socket.makefile('wb')
try:
    with picamera.PiCamera() as camera:
        camera.resolution = (ret.w, ret.h)
        camera.framerate = ret.fps
        time.sleep(ret.sleep_time)

        # Note the start time and construct a stream to hold image data
        # temporarily (we could write it directly to connection but in this
        # case we want to find out the size of each capture first to keep
        # our protocol simple)
        start = time.time()
        stream = io.BytesIO()
        for foo in camera.capture_continuous(stream, 'bgr', use_video_port=True):
            # Write the length of the capture to the stream and flush to
            # ensure it actually gets sent
            connection.write(struct.pack('<L', stream.tell()))
            connection.flush()
            # Rewind the stream and send the image data over the wire
            stream.seek(0)
#             connection.write(stream.read())
            # If we've been capturing for more than 30 seconds, quit
            if time.time() - start > ret.T_SIM:
                finish = time.time()
                break
            # Reset the stream for the next capture
            stream.seek(0)
            stream.truncate()
            count += 1
    # Write a length of zero to the stream to signal we're done
    connection.write(struct.pack('<L', 0))
finally:<commit_msg> using the class : basic processing<commit_after>import io
import socket
import struct
import time
import picamera
from openRetina import openRetina
ret = openRetina()
# Connect a client socket to my_server:8000 (change my_server to the
# hostname of your server)
client_socket = socket.socket()
client_socket.connect((ret.ip, 8000))
count = 0
# Make a file-like object out of the connection
connection = client_socket.makefile('wb')
try:
    with picamera.PiCamera() as camera:
        camera.resolution = (ret.w, ret.h)
        camera.framerate = ret.fps
        time.sleep(ret.sleep_time)

        # Note the start time and construct a stream to hold image data
        # temporarily (we could write it directly to connection but in this
        # case we want to find out the size of each capture first to keep
        # our protocol simple)
        start = time.time()
        stream = io.BytesIO()
        for foo in camera.capture_continuous(stream, 'bgr', use_video_port=True):
            # Write the length of the capture to the stream and flush to
            # ensure it actually gets sent
            connection.write(struct.pack('<L', stream.tell()))
            connection.flush()
            # Rewind the stream and send the image data over the wire
            stream.seek(0)
            connection.write(stream.read())
            # If we've been capturing for more than 30 seconds, quit
            if time.time() - start > ret.T_SIM:
                finish = time.time()
                break
            # Reset the stream for the next capture
            stream.seek(0)
            stream.truncate()
            count += 1
    # Write a length of zero to the stream to signal we're done
    connection.write(struct.pack('<L', 0))
finally:
{'fraction_non_alphanumeric': 0.07885714285714286, 'fraction_numerical': 0.008571428571428572, 'mean_word_length': 2.347036328871893, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '6465294', 'n_tokens_mistral': 959, 'n_tokens_neox': 910, 'n_words': 370}