<commit_before>#!/usr/bin/python2
#Original Author: <NAME>
#Original Date: Mar 23 2016
#Last Modified By: <NAME>
#Last Modified On: Mar 23 2016
#import needed STL modules
import sys
#import pySerial
import serial
#import abstract relay
import abstractrelay
class Relay(abstractrelay.Relay):
	def __init__(self, port="/dev/ttyUSB0"):
		self.s = serial.Serial(port="/dev/ttyUSB0")
		self.status = [False, False, False, False]
	def sendCmd(self, relay, status):
		assert type(relay) == int
		assert relay >= 1
		assert relay <= 4
		assert type(status) == bool
		self.status[relay-1] = status
		s.write(bytearray((255,relay,int(status))))
		s.flush()
	def enable(self, relay):
		self.sendCmd(relay, True)
	def disable(self, relay):
		self.sendCmd(relay, False)
if __name__ == "__main__":
	relay = Relay()
	if len(sys.argv) == 3:
		num = int(sys.argv[1])
		state = ('n' in sys.argv[2].lower())
		relay.sendCmd(num,state)
	elif len(sys.argv) == 2:
		state = ('n' in sys.argv[1].lower())
		for i in xrange(1,5):
			relay.sendCmd(i,state)
	else:
		print "Usage: ",sys.argv[0]," <relay number> <on/off>"
		print "       ",sys.argv[0]," <on/off>"
<commit_msg>Added status flags to usbrelay<commit_after>#!/usr/bin/python2
#Original Author: <NAME>
#Original Date: Mar 23 2016
#Last Modified By: <NAME>
#Last Modified On: Mar 23 2016
#import needed STL modules
import sys
#import pySerial
import serial
#import abstract relay
import abstractrelay
class Relay(abstractrelay.Relay):
	def __init__(self, port="/dev/ttyUSB0"):
		self.s = serial.Serial(port="/dev/ttyUSB0")
		self.status = [False, False, False, False]
	def sendCmd(self, relay, status):
		assert type(relay) == int
		assert relay >= 1
		assert relay <= 4
		assert type(status) == bool
		self.status[relay-1] = status
		s.write(bytearray((255,relay,int(status))))
		s.flush()
	def enable(self, relay):
		self.logger
		self.sendCmd(relay, True)
	def disable(self, relay):
		self.sendCmd(relay, False)
if __name__ == "__main__":
	relay = Relay()
	if len(sys.argv) == 3:
		num = int(sys.argv[1])
		state = ('n' in sys.argv[2].lower())
		relay.sendCmd(num,state)
	elif len(sys.argv) == 2:
		state = ('n' in sys.argv[1].lower())
		for i in xrange(1,5):
			relay.sendCmd(i,state)
	else:
		print "Usage: ",sys.argv[0]," <relay number> <on/off>"
		print "       ",sys.argv[0]," <on/off>"

{'fraction_non_alphanumeric': 0.16616573636753973, 'fraction_numerical': 0.025762129669386003, 'mean_word_length': 4.406032482598608, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 15, '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': '4469244', 'n_tokens_mistral': 955, 'n_tokens_neox': 875, 'n_words': 231}