Handle missing winsound module not in startup
This commit is contained in:
parent
33041619ee
commit
32604e99bf
|
@ -165,15 +165,6 @@ class GajimApplication(Gtk.Application):
|
||||||
|
|
||||||
from common import check_paths
|
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:
|
if pritext:
|
||||||
dlg = Gtk.MessageDialog(None,
|
dlg = Gtk.MessageDialog(None,
|
||||||
Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL,
|
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 Q_
|
||||||
from common.i18n import ngettext
|
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:
|
try:
|
||||||
import winsound # windows-only built-in module for playing wav
|
|
||||||
import wave # posix-only fallback wav playback
|
import wave # posix-only fallback wav playback
|
||||||
import ossaudiodev as oss
|
import ossaudiodev as oss
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -739,12 +747,12 @@ def play_sound_file(path_to_soundfile):
|
||||||
path_to_soundfile = check_soundfile_path(path_to_soundfile)
|
path_to_soundfile = check_soundfile_path(path_to_soundfile)
|
||||||
if path_to_soundfile is None:
|
if path_to_soundfile is None:
|
||||||
return
|
return
|
||||||
elif os.name == 'nt':
|
elif os.name == 'nt' and HAS_WINSOUND:
|
||||||
try:
|
try:
|
||||||
winsound.PlaySound(path_to_soundfile,
|
winsound.PlaySound(path_to_soundfile,
|
||||||
winsound.SND_FILENAME|winsound.SND_ASYNC)
|
winsound.SND_FILENAME|winsound.SND_ASYNC)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
log.exception('Sound Playback Error')
|
||||||
elif os.name == 'posix':
|
elif os.name == 'posix':
|
||||||
if gajim.config.get('soundplayer') == '':
|
if gajim.config.get('soundplayer') == '':
|
||||||
def _oss_play():
|
def _oss_play():
|
||||||
|
|
Loading…
Reference in New Issue