<commit_before><commit_msg>Added/cleaned Jeff's gpio class, need to init pins still<commit_after>import logging
"""

Usable GPIO pins are as follows

160,161,162,163,164,165,166,57

#EMBED ANY REFERENCE TO THIS IN A TRY STATEMENT
##ValueError will be generated if there is an invalid gpioPin



#MUST MODIFY WATCHDOG TO MONITOR AND CHANGE INDICATORS 

create 8 pin objects:

	reset pin (166)
	connection LED (163)
	warning LED (164)
	batt LED (165)
	relay 1 (57)
	relay 2 (160)
	relay 3 (161)
	relay 4 (162)


"""



gpio_list = [57,160,161,162,163,164,165,166]

class GpioPin():

    def __init__(self, gpioPin, direction = 'out'):
        self._state = 'undefined'
        self._direction = direction

        if gpioPin in gpio_list:
            self._gpioPin = gpioPin
        else:
            logging.warning("GPIO PIN SETUP FAILED\r\nGPIO pin {} does not exist".format(str(gpioPin)))
            logging.warning("GPIO pin must be one of the following {}".format(str(gpio_list)))
            raise ValueError("invalid GPIO pin number")


    def setup(self):
        #exporting the GPIO pin so it can be accessed
        with open('/sys/class/gpio/export','w') as export_file:
            export_file.write(str(self._gpioPin))
        #setting the pin direction
        with open('/sys/class/gpio/gpio{}/direction'.format(str(self._gpioPin)),'w') as direction_file:
            direction_file.write(self._direction)


    def changeState(self,state):
        if self._direction == "out":
            with open('/sys/class/gpio/gpio{}/value'.format(str(self._gpioPin)),'w') as value_file:
                value_file.write(str(state))
        else:
            raise ValueError("pin must be an output to change it's state")

        self._state = state








{'fraction_non_alphanumeric': 0.1111111111111111, 'fraction_numerical': 0.04195011337868481, 'mean_word_length': 2.862144420131291, 'pattern_counts': {'":': 1, '<': 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': '4596898', 'n_tokens_mistral': 619, 'n_tokens_neox': 541, 'n_words': 162}