def launch_project(app, filename, data_dir): logger.info('launch_project: {} {} {}'.format(app, filename, data_dir)) app_profiles = read_json(app_profiles_file) fullpath = os.path.join(data_dir, filename) cmd = app_profiles[app]['cmd'].format(fullpath=fullpath, filename=filename) _, _, rc = run_print_output_error(cmd) return rc
def launch_project(app, filename, data_dir, background=False): # This is necessary to support the new official names # TODO: once the apps have been renamed this will not be necessary name_translation = { 'make-art': 'kano-draw', 'terminal-quest': 'linux-story' } app_tr = name_translation.get(app, app) logger.info("launch_project: {} {} {}".format(app_tr, filename, data_dir)) app_profiles = read_json(app_profiles_file) # XML file with complete pathname fullpath = os.path.join(data_dir, filename) # Prepare the command line to open the app with the new project try: cmd = (app_profiles[app_tr]['cmd'].format(fullpath=fullpath, filename=filename)) except KeyError as exc: logger.warn("Can't find app '{}' in the app profiles - [{}]".format( app_tr, exc)) raise ValueError(_("App '{}' not available").format(app_tr)) # Try to load the project if the app is already running, via a signal. _, _, rc = run_cmd('/usr/bin/kano-signal launch-share {}'.format(fullpath)) if rc: # Likely the app is not running and the signal could not be sent, so start it now logger.warn( "Error sending launch signal, starting the app now, rc={}".format( rc)) if background: # TODO: After migrating to launching apps via systemd, shares for make-snake # stopped launching from KW. Created a special case here to avoid # fixing the make-snake cmd through systemd temporarily. FIX THIS. if app == 'make-snake': run_bg(cmd) else: run_cmd('systemd-run --user {cmd}'.format(cmd=cmd)) else: _, _, rc = run_print_output_error(cmd) return rc else: logger.info("Sent signal to app: {} to open : {}".format( app_tr, fullpath)) return 0
def launch_project(app, filename, data_dir, background=False): # This is necessary to support the new official names # TODO: once the apps have been renamed this will not be necessary name_translation = { 'make-art': 'kano-draw', 'terminal-quest': 'linux-story' } app_tr = name_translation.get(app, app) logger.info("launch_project: {} {} {}".format(app_tr, filename, data_dir)) app_profiles = read_json(app_profiles_file) # XML file with complete pathname fullpath = os.path.join(data_dir, filename) # Prepare the command line to open the app with the new project try: cmd = (app_profiles[app_tr]['cmd'] .format(fullpath=fullpath, filename=filename)) except KeyError as exc: logger.warn( "Can't find app '{}' in the app profiles - [{}]" .format(app_tr, exc) ) raise ValueError(_("App '{}' not available").format(app_tr)) # Try to load the project if the app is already running, via a signal. _, _, rc = run_cmd('/usr/bin/kano-signal launch-share {}'.format(fullpath)) if rc: # Likely the app is not running and the signal could not be sent, so start it now logger.warn("Error sending launch signal, starting the app now, rc={}".format(rc)) if background: # TODO: After migrating to launching apps via systemd, shares for make-snake # stopped launching from KW. Created a special case here to avoid # fixing the make-snake cmd through systemd temporarily. FIX THIS. if app == 'make-snake': run_bg(cmd) else: run_cmd('systemd-run --user {cmd}'.format(cmd=cmd)) else: _, _, rc = run_print_output_error(cmd) return rc else: logger.info("Sent signal to app: {} to open : {}".format(app_tr, fullpath)) return 0
def expand_rootfs(): cmd = '/usr/bin/expand-rootfs' _, _, rc = run_print_output_error(cmd) return rc == 0
def visible_run(cmd): if visible: return run_print_output_error(cmd) else: return run_cmd_log(cmd)