Skip to content

Commit

Permalink
Merge pull request #5835 from drew2a/fix/5832
Browse files Browse the repository at this point in the history
Add try-except block to dependency message box
  • Loading branch information
drew2a committed Dec 11, 2020
2 parents ca9a886 + 0a84950 commit 9eb7397
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/tribler-core/tribler_core/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,28 @@ def _show_system_popup(title, text):
:param text: the pop-up body
"""
sep = "*" * 80
print('\n'.join([sep, title, sep, text, sep]), file=sys.stderr)

# pylint: disable=import-outside-toplevel, import-error, broad-except
print('\n'.join([sep, title, sep, text, sep]), file=sys.stderr) # noqa: T001

system = platform.system()
if system == 'Windows':
import win32api
win32api.MessageBox(0, text, title)
elif system == 'Linux':
import subprocess
subprocess.Popen(['xmessage', '-center', text])
elif system == 'Darwin':
import subprocess
subprocess.Popen(['/usr/bin/osascript', '-e', text])
else:
print(f'cannot create native pop-up for system {system}')
try:
if system == 'Windows':
import win32api
win32api.MessageBox(0, text, title)
elif system == 'Linux':
import subprocess
subprocess.Popen(['xmessage', '-center', text])
elif system == 'Darwin':
import subprocess
subprocess.Popen(['/usr/bin/osascript', '-e', text])
else:
print(f'cannot create native pop-up for system {system}') # noqa: T001
except Exception as exception:
# Use base Exception, because code above can raise many
# non-obvious types of exceptions:
# (SubprocessError, ImportError, win32api.error, FileNotFoundError)
print(f'Error while showing a message box: {exception}') # noqa: T001


def check_for_missing_dependencies(scope='both'):
Expand Down

0 comments on commit 9eb7397

Please sign in to comment.