Silence error box for browser launch

svn: r23004
This commit is contained in:
John Ralls 2013-09-02 21:02:33 +00:00
parent 4a91ff8238
commit 1424d3d20f
2 changed files with 10 additions and 10 deletions

View File

@ -87,7 +87,7 @@ def url(link, uistate=None):
page = uistate.viewmanager.goto_page(cat_num, None) page = uistate.viewmanager.goto_page(cat_num, None)
page.open(link) page.open(link)
return return
if not open_file_with_default_application(link): if not open_file_with_default_application(link, display_error=False):
run_browser(link) run_browser(link)
def run_browser(url): def run_browser(url):

View File

@ -337,11 +337,11 @@ def display_error_dialog (index, errorstrings):
if errorstrings: if errorstrings:
if isinstance(errorstrings, dict): if isinstance(errorstrings, dict):
try: try:
error = errorstrings[resp] error = errorstrings[index]
except KeyError: except KeyError:
pass pass
else: else:
error = errorstrings error = errorstrings
ErrorDialog(_("Error from external program"), error) ErrorDialog(_("Error from external program"), error)
@ -362,10 +362,10 @@ def poll_external ((proc, errorstrings)):
return True return True
if resp != 0: if resp != 0:
display_error(resp, errorstrings) display_error_dialog(resp, errorstrings)
return False return False
def open_file_with_default_application(uri): def open_file_with_default_application(uri, display_error=True):
""" """
Launch a program to open an arbitrary file. The file will be opened using Launch a program to open an arbitrary file. The file will be opened using
whatever program is configured on the host as the default program for that whatever program is configured on the host as the default program for that
@ -376,7 +376,6 @@ def open_file_with_default_application(uri):
@type file_path: string @type file_path: string
@return: nothing @return: nothing
""" """
from QuestionDialog import ErrorDialog
from urlparse import urlparse from urlparse import urlparse
from time import sleep from time import sleep
errstrings = None errstrings = None
@ -385,7 +384,7 @@ def open_file_with_default_application(uri):
if (not urlcomp.scheme or urlcomp.scheme == 'file'): if (not urlcomp.scheme or urlcomp.scheme == 'file'):
norm_path = os.path.normpath(urlcomp.path) norm_path = os.path.normpath(urlcomp.path)
if not os.path.exists(norm_path): if not os.path.exists(norm_path):
display_error(0, _("File does not exist")) display_error_dialog(0, _("File does not exist"))
return False return False
else: else:
norm_path = uri norm_path = uri
@ -394,7 +393,7 @@ def open_file_with_default_application(uri):
try: try:
os.startfile(norm_path) os.startfile(norm_path)
except WindowsError, msg: except WindowsError, msg:
display_error(0, str(msg)) display_error_dialog(0, str(msg))
return False return False
return True return True
@ -417,7 +416,8 @@ def open_file_with_default_application(uri):
if resp == 0: if resp == 0:
return True return True
display_error(resp, errstrings) if display_error:
display_error_dialog(resp, errstrings)
return False return False
def process_pending_events(max_count=10): def process_pending_events(max_count=10):