[r22417]Bugs 6099 & 6472: Don't leave zombies and report errors
Update spawnve() to subprocess.check_output() Pop an ErrorDialog if the system's open command fails in open_file_with_default_application() svn: r22419
This commit is contained in:
parent
30bd47f623
commit
724a534bf5
29316
po/gramps.pot
29316
po/gramps.pot
File diff suppressed because it is too large
Load Diff
@ -25,6 +25,7 @@ import constfunc
|
||||
import config
|
||||
import locale
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
#list of manuals on wiki, map locale code to wiki extension, add language codes
|
||||
#completely, or first part, so pt_BR if Brazilian portugeze wiki manual, and
|
||||
@ -88,7 +89,7 @@ def url(link, uistate=None):
|
||||
if not run_file(link):
|
||||
run_browser(link)
|
||||
|
||||
def run_file(file):
|
||||
def run_file(file_name):
|
||||
"""
|
||||
Open a file or url with the default application. This should work
|
||||
on GNOME, KDE, XFCE, ... as we use a freedesktop application
|
||||
@ -98,7 +99,10 @@ def run_file(file):
|
||||
else:
|
||||
prog = find_binary('xdg-open')
|
||||
if prog:
|
||||
os.spawnvpe(os.P_NOWAIT, prog, [prog, file], os.environ)
|
||||
try:
|
||||
subprocess.check_call([prog, file_name])
|
||||
except subprocess.CalledProcessError:
|
||||
return False
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -31,6 +31,7 @@ Utility functions that depend on GUI components or for GUI components
|
||||
#-------------------------------------------------------------------------
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from gen.ggettext import gettext as _
|
||||
import constfunc
|
||||
# gtk is not included here, because this file is currently imported
|
||||
@ -337,7 +338,6 @@ def open_file_with_default_application( file_path ):
|
||||
"""
|
||||
from QuestionDialog import ErrorDialog
|
||||
norm_path = os.path.normpath( file_path )
|
||||
|
||||
if not os.path.exists(norm_path):
|
||||
ErrorDialog(_("Error Opening File"), _("File does not exist"))
|
||||
return
|
||||
@ -347,17 +347,18 @@ def open_file_with_default_application( file_path ):
|
||||
os.startfile(norm_path)
|
||||
except WindowsError, msg:
|
||||
ErrorDialog(_("Error Opening File"), str(msg))
|
||||
return
|
||||
|
||||
if constfunc.mac():
|
||||
utility = '/usr/bin/open'
|
||||
else:
|
||||
if constfunc.mac():
|
||||
utility = '/usr/bin/open'
|
||||
else:
|
||||
utility = 'xdg-open'
|
||||
search = os.environ['PATH'].split(':')
|
||||
for lpath in search:
|
||||
prog = os.path.join(lpath, utility)
|
||||
if os.path.isfile(prog):
|
||||
os.spawnvpe(os.P_NOWAIT, prog, [prog, norm_path], os.environ)
|
||||
return
|
||||
utility = 'xdg-open'
|
||||
try:
|
||||
subprocess.check_output([utility, norm_path], stderr=subprocess.STDOUT)
|
||||
except subprocess.CalledProcessError as err:
|
||||
ErrorDialog(_("Error Opening File"), err.output)
|
||||
|
||||
return
|
||||
|
||||
def process_pending_events(max_count=10):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user