<commit_before>import json
import sys
import time
import os
import RPi.GPIO as GPIO
from tqdm import tqdm


# GPIO/BOARD | Relay IN | Rotors | Zone
# 22/15	     | R2 IN2   | 1      | B
# 18/12	     | R1 IN2   | 2      | A
# 23/16	     | R1 IN3   | 3      | D
# 17/11	     | R1 IN4   | 4      | C
# 27/13	     | R2 IN1   | 5      | E

class SprinklerControl:
    """ TODO """

    def __init__(self):
        """Initialize a Synology Surveillance API."""
        print 'Start RPI GPIO'
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BOARD)
        chan_list = []
        for zone in self._get_zones_definition():
            chan_list.append(zone["boardOut"])
            GPIO.setup(chan_list, GPIO.OUT, initial=1)
            print "setup GPIO " + str(chan_list)
            zone["value"] = not GPIO.input(int(zone["boardOut"]))
            break

    def _get_zones_definition(self):
        json_data = {}
        data_tpl = os.path.join(os.path.abspath(os.path.dirname(__file__))) + '/data.json'
        with open(data_tpl) as data_file:
            json_data = json.load(data_file)
        return json_data["zones"]

    def get_zone(self, zoneId):
        zoneData = {}
        for zone in self._get_zones_definition():
            if zone["id"] == int(zoneId):
                #GPIO.setup(zone["boardOut"], GPIO.OUT)
                zone["value"] = not GPIO.input(int(zone["boardOut"]))
                zoneData = zone
                break
        return zoneData


    def set_zone(self, zoneId, state):
        zoneData = {}
        for zone in self._get_zones_definition():
            if zone["id"] == int(zoneId):
                #GPIO.setup(zone["boardOut"], GPIO.OUT)
                GPIO.output(zone["boardOut"], int(state))<commit_msg>Fix setup GPIO<commit_after>import json
import sys
import time
import os
import RPi.GPIO as GPIO
from tqdm import tqdm


# GPIO/BOARD | Relay IN | Rotors | Zone
# 22/15	     | R2 IN2   | 1      | B
# 18/12	     | R1 IN2   | 2      | A
# 23/16	     | R1 IN3   | 3      | D
# 17/11	     | R1 IN4   | 4      | C
# 27/13	     | R2 IN1   | 5      | E

class SprinklerControl:
    """ TODO """

    def __init__(self):
        """Initialize a Synology Surveillance API."""
        print 'Start RPI GPIO'
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BOARD)
        #chan_list = []
        for zone in self._get_zones_definition():
            #chan_list.append(zone["boardOut"])
            GPIO.setup(zone["boardOut"], GPIO.OUT, initial=1)
            print "setup GPIO " + str(zone["boardOut"])
            zone["value"] = not GPIO.input(int(zone["boardOut"]))

    def _get_zones_definition(self):
        json_data = {}
        data_tpl = os.path.join(os.path.abspath(os.path.dirname(__file__))) + '/data.json'
        with open(data_tpl) as data_file:
            json_data = json.load(data_file)
        return json_data["zones"]

    def get_zone(self, zoneId):
        zoneData = {}
        for zone in self._get_zones_definition():
            if zone["id"] == int(zoneId):
                #GPIO.setup(zone["boardOut"], GPIO.OUT)
                zone["value"] = not GPIO.input(int(zone["boardOut"]))
                zoneData = zone
                break
        return zoneData


    def set_zone(self, zoneId, state):
        zoneData = {}
        for zone in self._get_zones_definition():
            if zone["id"] == int(zoneId):
                #GPIO.setup(zone["boardOut"], GPIO.OUT)
                GPIO.output(zone["boardOut"], int(state))
{'fraction_non_alphanumeric': 0.1282997445359069, 'fraction_numerical': 0.02043712744819756, 'mean_word_length': 1.9317803660565724, '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': '3868983', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1129, 'n_words': 260}