[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 config
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
#list of manuals on wiki, map locale code to wiki extension, add language codes
|
#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
|
#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):
|
if not run_file(link):
|
||||||
run_browser(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
|
Open a file or url with the default application. This should work
|
||||||
on GNOME, KDE, XFCE, ... as we use a freedesktop application
|
on GNOME, KDE, XFCE, ... as we use a freedesktop application
|
||||||
@ -98,7 +99,10 @@ def run_file(file):
|
|||||||
else:
|
else:
|
||||||
prog = find_binary('xdg-open')
|
prog = find_binary('xdg-open')
|
||||||
if prog:
|
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 True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ Utility functions that depend on GUI components or for GUI components
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import subprocess
|
||||||
from gen.ggettext import gettext as _
|
from gen.ggettext import gettext as _
|
||||||
import constfunc
|
import constfunc
|
||||||
# gtk is not included here, because this file is currently imported
|
# 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
|
from QuestionDialog import ErrorDialog
|
||||||
norm_path = os.path.normpath( file_path )
|
norm_path = os.path.normpath( file_path )
|
||||||
|
|
||||||
if not os.path.exists(norm_path):
|
if not os.path.exists(norm_path):
|
||||||
ErrorDialog(_("Error Opening File"), _("File does not exist"))
|
ErrorDialog(_("Error Opening File"), _("File does not exist"))
|
||||||
return
|
return
|
||||||
@ -347,16 +347,17 @@ def open_file_with_default_application( file_path ):
|
|||||||
os.startfile(norm_path)
|
os.startfile(norm_path)
|
||||||
except WindowsError, msg:
|
except WindowsError, msg:
|
||||||
ErrorDialog(_("Error Opening File"), str(msg))
|
ErrorDialog(_("Error Opening File"), str(msg))
|
||||||
else:
|
return
|
||||||
|
|
||||||
if constfunc.mac():
|
if constfunc.mac():
|
||||||
utility = '/usr/bin/open'
|
utility = '/usr/bin/open'
|
||||||
else:
|
else:
|
||||||
utility = 'xdg-open'
|
utility = 'xdg-open'
|
||||||
search = os.environ['PATH'].split(':')
|
try:
|
||||||
for lpath in search:
|
subprocess.check_output([utility, norm_path], stderr=subprocess.STDOUT)
|
||||||
prog = os.path.join(lpath, utility)
|
except subprocess.CalledProcessError as err:
|
||||||
if os.path.isfile(prog):
|
ErrorDialog(_("Error Opening File"), err.output)
|
||||||
os.spawnvpe(os.P_NOWAIT, prog, [prog, norm_path], os.environ)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def process_pending_events(max_count=10):
|
def process_pending_events(max_count=10):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user