Example #1
0
    def getContent(self, path):
        tokens = path.split("/")
        numTokens = len(tokens)

        if numTokens == 0 or len(tokens[0]) != 0:
            return None

        if numTokens == 2:
            return self.getFullStatus()

        pinName = tokens[1]
        try:
            [pin] = [pin for pin in self.pins if pin.name == pinName]
        except:
            error.handleGenericException()
            return None

        if numTokens > 2:
            if not pin.output:
                return None

            try:
                value = int(tokens[2])
                gpio.setPinValue(pin, value)
            except:
                error.handleGenericException()
                return None

        return self._getPinInfo(pin)