# 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_avatar/paths.py
# AVATAR_DEFAULT_LOC = os.path.join(get_home(), '.character-content')


import os
from kano.logging import logger
from kano.utils import (read_json, write_json, get_date_now, ensure_dir,
                        chown_path, get_user_unsudoed, run_bg, is_running,
                        list_dir)
from .paths import profile_file, profile_dir, kanoprofile_dir, bin_dir
from kano_avatar.paths import AVATAR_DEFAULT_LOC
        environment = 'dojo'
    return environment


def set_environment(environment, sync=False):
    """ Set the avatar in the local profile structure and optionally sync
    :param environment: Environment name to be used
    :param sync: (Optional) sync to World
    :returns: True iff an update has happenned internally, False iff the
              internal structures were up to date
    :rtype: Boolean
    """
    profile = load_profile()
    needs_update = True
    if 'environment' in profile:
        if profile['environment'] == environment:
            needs_update = False

    if needs_update:
        profile['environment'] = environment
        save_profile(profile, skip_kdesk_refresh=True)
        if sync:
            sync_profile()
    return needs_update


def sync_profile():
    """ Sync the local profile data with kano_world, without blocking
    """
    logger.info("sync_profile")

# 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_avatar/paths.py
# AVATAR_DEFAULT_LOC = os.path.join(get_home(), '.character-content')


# Path: kano_profile/profile.py
import os
from kano.logging import logger
from kano.utils import (read_json, write_json, get_date_now, ensure_dir,
                        chown_path, get_user_unsudoed, run_bg, is_running,
                        list_dir)
from .paths import profile_file, profile_dir, kanoprofile_dir, bin_dir
from kano_avatar.paths import AVATAR_DEFAULT_LOC

        environment = 'dojo'
    return environment


def set_environment(environment, sync=False):
    """ Set the avatar in the local profile structure and optionally sync
    :param environment: Environment name to be used
    :param sync: (Optional) sync to World
    :returns: True iff an update has happenned internally, False iff the
              internal structures were up to date
    :rtype: Boolean
    """
    profile = load_profile()
    needs_update = True
    if 'environment' in profile:
        if profile['environment'] == environment:
            needs_update = False

    if needs_update:
        profile['environment'] = environment
        save_profile(profile, skip_kdesk_refresh=True)
        if sync:
            sync_profile()
    return needs_update


def sync_profile():
    """ Sync the local profile data with kano_world, without blocking
    """
    logger.info("sync_profile")

    cmd = '{bin_dir}/kano-sync --sync -s'.format(bin_dir=bin_dir)