def launch_commandline(cli, name=None, in_terminal=False): " Raises SpawnError " argv = desktop_parse.parse_argv(cli) pretty.print_error(__name__, "Launch commandline is deprecated ") pretty.print_debug(__name__, "Launch commandline (in_terminal=", in_terminal, "):", argv, sep="") if in_terminal: return spawn_in_terminal(argv) return spawn_async(argv)
def argv_for_commandline(cli): return desktop_parse.parse_argv(cli)
def launch_app_info(app_info, gfiles=[], in_terminal=None, timestamp=None, desktop_file=None, launch_cb=None, screen=None): """ Launch @app_info, opening @gfiles @in_terminal: override Terminal flag @timestamp: override timestamp @desktop_file: specify location of desktop file @launch_cb: Called once per launched process, like ``spawn_app`` Will pass on exceptions from spawn_app """ desktop_file = desktop_file or _file_for_app_info(app_info) desktop_info = _info_for_desktop_file(desktop_file) if not desktop_file or not desktop_info: # Allow in-memory app_info creations (without id or desktop file) desktop_file = "" desktop_info = create_desktop_info(app_info.get_commandline() or "", app_info.get_name(), "", "", False, False) # in this case, the command line is already primarily escaped argv = desktop_parse.parse_argv(desktop_info["Exec"]) else: # In the normal case, we must first escape one round argv = desktop_parse.parse_unesc_argv(desktop_info["Exec"]) assert argv and argv[0] # Now Resolve the %f etc format codes multiple_needed, missing_format, launch_argv = \ replace_format_specs(argv, desktop_file, desktop_info, gfiles) if not multiple_needed: # Launch 1 process launch_records = [(launch_argv, gfiles)] else: # Launch one process per file launch_records = [(launch_argv, [gfiles[0]])] for f in gfiles[1:]: _ignore1, _ignore2, launch_argv = \ replace_format_specs(argv, desktop_file, desktop_info, [f]) launch_records.append((launch_argv, [f])) notify = desktop_info["StartupNotify"] workdir = desktop_info["Path"] or None if in_terminal is None: in_terminal = desktop_info["Terminal"] if in_terminal: term = terminal.get_configured_terminal() notify = notify or term["startup_notify"] for argv, gfiles in launch_records: if in_terminal: term = terminal.get_configured_terminal() targv = list(term["argv"]) if term["exearg"]: targv.append(term["exearg"]) argv = targv + argv ret = spawn_app(app_info, argv, gfiles, workdir, notify, timestamp=timestamp, launch_cb=launch_cb, screen=screen) if not ret: return False return True
def launch_app_info(app_info, gfiles=[], in_terminal=None, timestamp=None, desktop_file=None, launch_cb=None): """ Launch @app_info, opening @gfiles @in_terminal: override Terminal flag @timestamp: override timestamp @desktop_file: specify location of desktop file @launch_cb: Called once per launched process, like ``spawn_app`` Will pass on exceptions from spawn_app """ desktop_file = desktop_file or _file_for_app_info(app_info) desktop_info = _info_for_desktop_file(desktop_file) if not desktop_file or not desktop_info: # Allow in-memory app_info creations (without id or desktop file) desktop_file = "" desktop_info = create_desktop_info(app_info.get_commandline() or "", app_info.get_name(), "", "", False, False) # in this case, the command line is already primarily escaped argv = desktop_parse.parse_argv(desktop_info["Exec"]) else: # In the normal case, we must first escape one round argv = desktop_parse.parse_unesc_argv(desktop_info["Exec"]) assert argv and argv[0] # Now Resolve the %f etc format codes multiple_needed, missing_format, launch_argv = \ replace_format_specs(argv, desktop_file, desktop_info, gfiles) if not multiple_needed: # Launch 1 process launch_records = [(launch_argv, gfiles)] else: # Launch one process per file launch_records = [(launch_argv, [gfiles[0]])] for f in gfiles[1:]: _ignore1, _ignore2, launch_argv = \ replace_format_specs(argv, desktop_file, desktop_info, [f]) launch_records.append((launch_argv, [f])) notify = desktop_info["StartupNotify"] workdir = desktop_info["Path"] or None if in_terminal is None: in_terminal = desktop_info["Terminal"] if in_terminal: term = terminal.get_configured_terminal() notify = notify or term["startup_notify"] for argv, gfiles in launch_records: if in_terminal: term = terminal.get_configured_terminal() targv = list(term["argv"]) if term["exearg"]: targv.append(term["exearg"]) argv = targv + argv ret = spawn_app(app_info, argv, gfiles, workdir, notify, timestamp=timestamp, launch_cb=launch_cb) if not ret: return False return True