INNER CODE UNIT · Python

__init__

geerlingguy/raspberry-pi-dramble · testing/presentation/ansible-encounters/callback_plugins/tones.py:41

    def __init__(self):

        super(CallbackModule, self).__init__()

        self.synthesizer = distutils.spawn.find_executable('play')

        # plugin disable itself if play is not present
        # ansible will not call any callback if disabled is set to True
        if not self.synthesizer:
            self.disabled = True
            self._display.warning("Unable to find 'play' executable, plugin %s disabled" % os.path.basename(__file__))

    def tone(self, tone, length, delay):
        cmd = [self.synthesizer]
        if tone:
            time.sleep(delay)
            cmd.extend(('-q', '-n', 'synth', length, 'sin', tone))
        subprocess.call(cmd)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…