Ejemplo n.º 1
0
    def test_should_close_the_connection(self, mock_Serial):
        drip_governor = DripGovernor('COM4')
        my_mock_serial = mock_Serial.return_value

        drip_governor.close()

        my_mock_serial.close.assert_called_with()
    def test_should_close_the_connection(self, mock_Serial):
        drip_governor = DripGovernor('COM4')
        my_mock_serial = mock_Serial.return_value

        drip_governor.close()

        my_mock_serial.close.assert_called_with()
Ejemplo n.º 3
0
                        if TRACE:
                            print('Need to fast-forward to find new position: num_frames_to_discard=%d (%d-%d)' % (
                                num_frames_to_discard, new_frame_num, current_frame_num
                            ))
                        if num_frames_to_discard:
                            wave_file.readframes(num_frames_to_discard)
                    else:
                        if DEBUG:
                            print('WARNING: Was forced to rewind to seek to frame_num=%d' % new_frame_num)
                        wave_file.rewind()
                        wave_file.readframes(new_frame_num)
                    current_frame_num = new_frame_num
                    # Save the new start position to the cache (since we're likely to loop back to it)
                    frame_position_cache[current_frame_num] = wave_file.tell()
                # NOTE: Don't read and play frames yet; will be handled when loop continues
except StopIteration:
    log.info('Finished playing final cue; waiting for playback to complete.')
finally:
    # Stop audio interface
    outstream.stop_stream()
    instream.stop_stream()
    outstream.close()
    instream.close()
    pa.terminate()
    if drip_governor:
        drip_governor.stop_dripping()
        print('------Stop Dripping!-----')
        drip_governor.close()
    if DEBUG_STREAM:
        debug_outfile.close()