Just in case you are interested, here's a modified version of launch_app(). I've only tested it with windows.
Spoiler:
Code:
def launch_app(self, external_app_path, app_args, path_to_file=None):
external_app_path = os.path.expandvars(external_app_path)
if path_to_file != None:
path_to_file = path_to_file.encode('utf-8')
if DEBUG:
print('Open: ', external_app_path, '(file): ', path_to_file, ' (args): ', app_args)
if isosx:
# For OSX we will not support optional command line arguments currently
if external_app_path.lower().endswith(".app"):
args = 'open -a '
else:
args = ''
args += '"%s"' % external_app_path
if path_to_file != None:
args += ' "%s"' % path_to_file
subprocess.Popen(args, shell=True)
else:
# For Windows/Linux merge any optional command line args with the app/file paths
app_args_list = []
if app_args:
app_args_list = app_args.split(',')
app_args_list.insert(0, external_app_path)
if path_to_file != None:
app_args_list.append(path_to_file)
if iswindows:
if path_to_file != None:
# Add to the recently opened files list to support windows jump lists etc.
from win32com.shell import shell, shellcon
shell.SHAddToRecentDocs(shellcon.SHARD_PATHA, path_to_file)
# As of v1.5.3 will no longer use subprocess because it does not work
# for users who have non-ascii library paths
# However we need a special case for Sigil which has issues with C runtime paths
DETACHED_PROCESS = 0x00000008
if external_app_path.lower().endswith('sigil.exe'):
clean_env = dict(os.environ)
del clean_env['PATH']
subprocess.Popen(app_args_list, creationflags=DETACHED_PROCESS, env=clean_env)
else:
from win32process import CreateProcess, STARTUPINFO
import _subprocess
cmd_line = '"%s"'%app_args_list[0]
for app_arg in app_args_list[1:]:
cmd_line += ' "%s"'%app_arg
si = STARTUPINFO()
si.dwFlags |= _subprocess.STARTF_USESTDHANDLES
print("OW cmd_line:%s"%cmd_line)
CreateProcess(None, cmd_line, None, None, False, DETACHED_PROCESS, None, None, si)
else: #Linux
clean_env = dict(os.environ)
clean_env['LD_LIBRARY_PATH'] = ''
subprocess.Popen(app_args_list, env=clean_env)