def METHOD_NAME(self, port_num, lpmode):
    # Check for invalid port_num
    if port_num < self.port_start or port_num > self.port_end:
        return False
    if port_num < 16:
        lpmode_path = self.BASE_CPLD1_PATH + "port" + str(port_num+1) + "_lpmode"
    else:
        lpmode_path = self.BASE_CPLD2_PATH + "port" + str(port_num+1) + "_lpmode"
    self.__port_to_is_lpmode = lpmode_path
    try:
        val_file = open(self.__port_to_is_lpmode, 'w')
        val_file.write('1' if lpmode else '0')
        val_file.close()
        return True
    except IOError as e:
        print("Error: unable to open file: %s" % str(e))
        val_file.close()
        return False