<commit_before>import os, io, time
from serial import Serial, SerialException


class Peripherals:

	devices = {}

	@classmethod
	def init(cls):
		devPath = "/dev/"
		teensyBaseName = "tty.usbmodem"
		teensyBaseName = "ttyACM"

		for file in os.listdir(devPath):

			if file.startswith(teensyBaseName):
				device = devPath + file
				try:
					teensy = Teensy(device)
					try:
						response = teensy.sendCommand("i", seperator="|")
						cls.devices[response[0]] = teensy
						time.sleep(1)
					except:
						print "Error sending data"
						#raise
				except:
					print "Error opening Serial"
					#raise



class Teensy:

	def __init__(self, device):
		self.initSerial(device)

	def __del__(self):
		if self.serial is not None:
			self.serial.close()
			print "Teensy close"

	def initSerial(self, device):
		self.serial = Serial(device, 115200, timeout=1)
		self.io = io.TextIOWrapper(io.BufferedRWPair(self.serial, self.serial))

	def sendCommand(self, strCommand, seperator=None):
		try:
			self.io.flush()
			self.io.write(unicode(strCommand))
			self.io.flush()
			response = self.io.readline().strip()
			if seperator is not None:
				response = response.split(seperator)
			return response
		except:
			return None<commit_msg>Start Cleanup, NumPy Smooth<commit_after>import os, io, time
from serial import Serial, SerialException


class Peripherals:

	devices = {}

	@classmethod
	def init(cls):
		devPath = "/dev/"
		teensyBaseName = "tty.usbmodem"
		teensyBaseName = "ttyACM"

		for file in os.listdir(devPath):

			if file.startswith(teensyBaseName):
				device = devPath + file
				try:
					teensy = Teensy(device)
					try:
						response = teensy.sendCommand("i", seperator="|")
						cls.devices[response[0]] = teensy
						time.sleep(1)
					except:
						print "Error sending data"
						#raise
				except:
					print "Error opening Serial"
					#raise



class Teensy:

	def __init__(self, device):
		self.initSerial(device)

	def __del__(self):
		if self.serial is not None:
			self.serial.close()
			print "Teensy close"

	def initSerial(self, device):
		self.serial = Serial(device, 115200, timeout=1)
		self.io = io.TextIOWrapper(io.BufferedRWPair(self.serial, self.serial))

	def sendCommand(self, strCommand, seperator=None):
		try:
			self.io.flush()
			self.io.write(unicode(strCommand))
			self.io.flush()
			response = self.io.readline().strip()
			print "Resp: ", response
			if seperator is not None:
				response = response.split(seperator)
			return response
		except:
			return None
{'fraction_non_alphanumeric': 0.11687797147385103, 'fraction_numerical': 0.0071315372424722665, 'mean_word_length': 3.3760831889081455, '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': '2513404', 'n_tokens_mistral': 1069, 'n_tokens_neox': 861, 'n_words': 207}