Back to index

python3.2  3.2.2
Classes | Functions | Variables
test.test_winsound Namespace Reference

Classes

class  BeepTest
class  MessageBeepTest
class  PlaySoundTest

Functions

def has_sound
def _get_cscript_path
def _have_soundcard
def test_main

Variables

tuple winsound = support.import_module('winsound')
tuple ctypes = support.import_module('ctypes')
 __have_soundcard_cache = None

Function Documentation

Return the full path to cscript.exe or None.

Definition at line 229 of file test_winsound.py.

00229 
00230 def _get_cscript_path():
00231     """Return the full path to cscript.exe or None."""
00232     for dir in os.environ.get("PATH", "").split(os.pathsep):
00233         cscript_path = os.path.join(dir, "cscript.exe")
00234         if os.path.exists(cscript_path):
00235             return cscript_path

Here is the call graph for this function:

Here is the caller graph for this function:

Return True iff this computer has a soundcard.

Definition at line 237 of file test_winsound.py.

00237 
00238 def _have_soundcard():
00239     """Return True iff this computer has a soundcard."""
00240     global __have_soundcard_cache
00241     if __have_soundcard_cache is None:
00242         cscript_path = _get_cscript_path()
00243         if cscript_path is None:
00244             # Could not find cscript.exe to run our VBScript helper. Default
00245             # to True: most computers these days *do* have a soundcard.
00246             return True
00247 
00248         check_script = os.path.join(os.path.dirname(__file__),
00249                                     "check_soundcard.vbs")
00250         p = subprocess.Popen([cscript_path, check_script],
00251                              stdout=subprocess.PIPE)
00252         __have_soundcard_cache = not p.wait()
00253         p.stdout.close()
00254     return __have_soundcard_cache
00255 

Here is the call graph for this function:

Here is the caller graph for this function:

Find out if a particular event is configured with a default sound

Definition at line 14 of file test_winsound.py.

00014 
00015 def has_sound(sound):
00016     """Find out if a particular event is configured with a default sound"""
00017     try:
00018         # Ask the mixer API for the number of devices it knows about.
00019         # When there are no devices, PlaySound will fail.
00020         if ctypes.windll.winmm.mixerGetNumDevs() is 0:
00021             return False
00022 
00023         key = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER,
00024                 "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound))
00025         value = winreg.EnumValue(key, 0)[1]
00026         if value is not "":
00027             return True
00028         else:
00029             return False
00030     except WindowsError:
00031         return False

Here is the caller graph for this function:

Definition at line 256 of file test_winsound.py.

00256 
00257 def test_main():
00258     support.run_unittest(BeepTest, MessageBeepTest, PlaySoundTest)


Variable Documentation

Definition at line 236 of file test_winsound.py.

Definition at line 11 of file test_winsound.py.

Definition at line 10 of file test_winsound.py.