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

import pexpect
import os
import random
import time
import RPi.GPIO as GPIO

#Setup
GPIO.cleanup()
path = "/home/pi/Videos/"
channel = 18
lights = [3, 5, 7, 11, 13, 15, 19, 31]


def play_video():
	video = random.choice(os.listdir(path))
	vidpath = path + video
	child = pexpect.spawn('omxplayer -o local %s' % vidpath)
	while child.isalive():
		if GPIO.input(channel) == 1:
			time.sleep(1)
			if GPIO.input(channel) == 1:
				child.sendline('q')
				lights_up()
				break
	lights_up(False)


def lights_up(all=True):
	if all == True:
		GPIO.output(lights, GPIO.LOW)
	else:
		for l in lights:
				GPIO.output(l, GPIO.LOW)
				time.sleep(1)


def lights_down(all=True):
	if all == True:
		GPIO.output(lights, GPIO.HIGH)
	else:
		for l in reversed(lights):
				GPIO.output(l, GPIO.HIGH)
				time.sleep(1)


def pressed(c):
	if GPIO.input(channel) == 0:
		lights_down(False)
		time.sleep(1)
		play_video()


if __name__ == "__main__":
	GPIO.setmode(GPIO.BOARD)
	GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	GPIO.setup(lights, GPIO.OUT)
	GPIO.add_event_detect(channel, GPIO.FALLING,  bouncetime=200)
	GPIO.add_event_callback(channel, pressed)
	lights_up()
	while True:
		time.sleep(1)
		
		
<commit_msg>remove callback on start play<commit_after>#! /usr/bin/env python

import pexpect
import os
import random
import time
import RPi.GPIO as GPIO

#Setup
GPIO.cleanup()
path = "/home/pi/Videos/"
channel = 18
lights = [3, 5, 7, 11, 13, 15, 19, 31]


def play_video():
	video = random.choice(os.listdir(path))
	vidpath = path + video
	child = pexpect.spawn('omxplayer -o local %s' % vidpath)
	while child.isalive():
		if GPIO.input(channel) == 1:
			time.sleep(1)
			if GPIO.input(channel) == 1:
				child.sendline('q')
				lights_up()
				break
	lights_up(False)
	time.sleep(15)


def lights_up(all=True):
	if all == True:
		GPIO.output(lights, GPIO.LOW)
	else:
		for l in lights:
				GPIO.output(l, GPIO.LOW)
				time.sleep(1)


def lights_down(all=True):
	if all == True:
		GPIO.output(lights, GPIO.HIGH)
	else:
		for l in reversed(lights):
				GPIO.output(l, GPIO.HIGH)
				time.sleep(1)


def pressed(c):
	GPIO.remove_event_callback(c)
	if GPIO.input(channel) == 0:
		lights_down(False)
		time.sleep(1)
		play_video()
		GPIO.add_event_callback(channel, pressed)


if __name__ == "__main__":
	GPIO.setmode(GPIO.BOARD)
	GPIO.setup(channel, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	GPIO.setup(lights, GPIO.OUT)
	GPIO.add_event_detect(channel, GPIO.FALLING,  bouncetime=200)
	GPIO.add_event_callback(channel, pressed)
	lights_up()
	while True:
		time.sleep(1)
		
		

{'fraction_non_alphanumeric': 0.14280230326295584, 'fraction_numerical': 0.02072936660268714, 'mean_word_length': 3.9543726235741445, 'pattern_counts': {'":': 2, '<': 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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6279091', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1028, 'n_words': 232}