# Path: kano_profile/paths.py
# TRACKER_UUIDS_PATH = os.path.join(kanoprofile_dir, 'tracker', 'uuids')
# PAUSED_SESSIONS_FILE = os.path.join(kanoprofile_dir, '.paused_sessions')


import json
import os
from kano.utils import read_json, write_json, get_date_now, ensure_dir, \
    chown_path, run_print_output_error, run_bg, run_cmd
from kano.logging import logger
from kano_profile.paths import apps_dir, xp_file, kanoprofile_dir, \
    app_profiles_file
    from kano.utils.misc import is_installed
    from kano.utils.shell import run_cmd
    logger.debug(msg)
    data = load_app_state(app_name)
    if data.get(variable, 0) < value:
        data[variable] = value

        save_app_state(app_name, data)


def increment_app_state_variable(app_name, variable, value):
    logger.debug(
        "increment_app_state_variable {} {} {}".format(
            app_name, variable, value))

    data = load_app_state(app_name)
    if variable not in data:
        data[variable] = 0
    data[variable] += value

    save_app_state(app_name, data)


def get_app_list():
    if not os.path.exists(apps_dir):
        return []
    else:
        return [p for p in os.listdir(apps_dir)
                if os.path.isdir(os.path.join(apps_dir, p))]


def get_gamestate_variables(app_name):

# Path: kano_profile/paths.py
# TRACKER_UUIDS_PATH = os.path.join(kanoprofile_dir, 'tracker', 'uuids')
# PAUSED_SESSIONS_FILE = os.path.join(kanoprofile_dir, '.paused_sessions')


# Path: kano_profile/apps.py
import json
import os
from kano.utils import read_json, write_json, get_date_now, ensure_dir, \
    chown_path, run_print_output_error, run_bg, run_cmd
from kano.logging import logger
from kano_profile.paths import apps_dir, xp_file, kanoprofile_dir, \
    app_profiles_file
    from kano.utils.misc import is_installed
    from kano.utils.shell import run_cmd

    logger.debug(msg)
    data = load_app_state(app_name)
    if data.get(variable, 0) < value:
        data[variable] = value

        save_app_state(app_name, data)


def increment_app_state_variable(app_name, variable, value):
    logger.debug(
        "increment_app_state_variable {} {} {}".format(
            app_name, variable, value))

    data = load_app_state(app_name)
    if variable not in data:
        data[variable] = 0
    data[variable] += value

    save_app_state(app_name, data)


def get_app_list():
    if not os.path.exists(apps_dir):
        return []
    else:
        return [p for p in os.listdir(apps_dir)
                if os.path.isdir(os.path.join(apps_dir, p))]


def get_gamestate_variables(app_name):

    allrules = read_json(xp_file)