def run(args): app_id = args[0] kano_apps = "/usr/bin/python /usr/bin/kano-apps" if is_running(kano_apps): pkill(kano_apps) return app_id
def save_app_state_with_dialog(app_name, data): logger.debug('save_app_state_with_dialog {}'.format(app_name)) old_level, _, old_xp = calculate_kano_level() old_badges = calculate_badges() save_app_state(app_name, data) new_level, _, new_xp = calculate_kano_level() new_badges = calculate_badges() # TODO: This function needs a bit of refactoring in the future # The notifications no longer need to be concatenated to a string # new level new_level_str = '' if old_level != new_level: new_level_str = 'level:{}'.format(new_level) # A new level has been reached, update the desktop profile icon if os.path.exists('/usr/bin/kdesk') and not is_running('kano-sync'): logger.info('refreshing kdesk due to new experience level') run_bg('kdesk -a profile') # new items new_items_str = '' badge_changes = compare_badges_dict(old_badges, new_badges) if badge_changes: for category, subcats in badge_changes.iteritems(): for subcat, items in subcats.iteritems(): for item, rules in items.iteritems(): new_items_str += ' {}:{}:{}'.format(category, subcat, item) # Check if XP has changed, if so play sound in the backgrond if old_xp != new_xp: sound_cmd = 'aplay /usr/share/kano-media/sounds/kano_xp.wav > /dev/null 2>&1 &' run_bg(sound_cmd) if not new_level_str and not new_items_str: return if is_gui(): fifo = open( os.path.join(os.path.expanduser('~'), '.kano-notifications.fifo'), 'w' ) with fifo: for notification in (new_level_str + ' ' + new_items_str).split(' '): if len(notification) > 0: logger.debug( "Showing the {} notification".format(notification) ) fifo.write('{}\n'.format(notification)) cmd = '{bin_dir}/kano-sync --sync -s'.format(bin_dir=bin_dir) run_bg(cmd)
def save_profile(data): ''' Write profile data to file :param data: JSON serialisable data about the profile ''' logger.debug('save_profile') data.pop('cpu_id', None) data.pop('mac_addr', None) data['save_date'] = get_date_now() ensure_dir(profile_dir) write_json(profile_file, data) if 'SUDO_USER' in os.environ: chown_path(kanoprofile_dir) chown_path(profile_dir) chown_path(profile_file) if os.path.exists('/usr/bin/kdesk') and not is_running('kano-sync'): logger.info('refreshing kdesk from save_profile') run_bg('kdesk -a profile')
def save_profile(data, skip_kdesk_refresh=False): ''' Write profile data to file :param data: JSON serialisable data about the profile ''' logger.debug('save_profile') data.pop('cpu_id', None) data.pop('mac_addr', None) data['save_date'] = get_date_now() ensure_dir(profile_dir) write_json(profile_file, data) if 'SUDO_USER' in os.environ: chown_path(kanoprofile_dir) chown_path(profile_dir) chown_path(profile_file) if (not skip_kdesk_refresh and os.path.exists('/usr/bin/kdesk') and not is_running('kano-sync')): logger.info("refreshing kdesk from save_profile") run_bg('kdesk -a profile')