Commit 32604e99 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Handle missing winsound module not in startup

parent 33041619
......@@ -165,15 +165,6 @@ class GajimApplication(Gtk.Application):
from common import check_paths
if os.name == 'nt':
try:
import winsound # windows-only built-in module for playing wav
except Exception:
pritext = _('Gajim needs pywin32 to run')
sectext = _('Please make sure that Pywin32 is installed on your '
'system. You can get it at %s') % \
'http://sourceforge.net/project/showfiles.php?group_id=78018'
if pritext:
dlg = Gtk.MessageDialog(None,
Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL,
......
......@@ -52,8 +52,16 @@ from string import Template
from common.i18n import Q_
from common.i18n import ngettext
if os.name == 'nt':
try:
HAS_WINSOUND = True
import winsound # windows-only built-in module for playing wav
except ImportError:
HAS_WINSOUND = False
print('Gajim is not able to playback sound because'
'pywin32 is missing', file=sys.stderr)
try:
import winsound # windows-only built-in module for playing wav
import wave # posix-only fallback wav playback
import ossaudiodev as oss
except Exception:
......@@ -739,12 +747,12 @@ def play_sound_file(path_to_soundfile):
path_to_soundfile = check_soundfile_path(path_to_soundfile)
if path_to_soundfile is None:
return
elif os.name == 'nt':
elif os.name == 'nt' and HAS_WINSOUND:
try:
winsound.PlaySound(path_to_soundfile,
winsound.SND_FILENAME|winsound.SND_ASYNC)
except Exception:
pass
log.exception('Sound Playback Error')
elif os.name == 'posix':
if gajim.config.get('soundplayer') == '':
def _oss_play():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment