<commit_before>#!/usr/bin/env python

import socket
from thread import *

MY_TCP_IP = ''
MY_TCP_PORT = 5001
BUFFER_SIZE = 3

LIGHT = 'L'

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((MY_TCP_IP, MY_TCP_PORT))
s.listen(1)

def recvfromclient(conn, addr):
	global LIGHT
	while True:
		data = conn.recv(BUFFER_SIZE)
		if not data: break
		print 'Received', data, 'from', addr
		if data == 'REQ':
			VAL = input('Enter the light value: ')
			conn.send(str(VAL))
		elif data == 'ON':
			LIGHT = 'H'
			print "Light:", LIGHT
			conn.send('OK')
		elif data == 'OFF':
			LIGHT = 'L'
			print "Light:", LIGHT
			conn.send('OK')
		else:
			conn.send('NOK')
		break
	conn.close()

while 1:
	conn, addr = s.accept()
	recvfromclient(conn,addr)

s.close()<commit_msg>Implemented random readings for testing<commit_after>#!/usr/bin/env python

import socket
import random
from thread import *

MY_TCP_IP = ''
MY_TCP_PORT = 5001
BUFFER_SIZE = 3

LIGHT = 'L'

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((MY_TCP_IP, MY_TCP_PORT))
s.listen(1)

def recvfromclient(conn, addr):
	global LIGHT
	while True:
		data = conn.recv(BUFFER_SIZE)
		if not data: break
		print 'Received', data, 'from', addr
		if data == 'REQ':
			conn.send(str(random.randint(1,1000)))
		elif data == 'ON':
			LIGHT = 'H'
			print "Light:", LIGHT
			conn.send('OK')
		elif data == 'OFF':
			LIGHT = 'L'
			print "Light:", LIGHT
			conn.send('OK')
		else:
			conn.send('NOK')
		break
	conn.close()

while 1:
	conn, addr = s.accept()
	recvfromclient(conn,addr)

s.close()
{'fraction_non_alphanumeric': 0.15434083601286175, 'fraction_numerical': 0.012218649517684888, 'mean_word_length': 3.8322981366459627, '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': '3461950', 'n_tokens_mistral': 676, 'n_tokens_neox': 607, 'n_words': 152}