import warnings
try:
    import visa
    import time
    VISA_AVAILABLE = True
except ImportError:
    warnings.warn('Could not import `visa`.')
    VISA_AVAILABLE = False


class AgilentOscope(object):
    def __init__(self, address=None):
        self.rm = visa.ResourceManager()
        if address is None:
            address = self.rm.list_resources()[0]
        self.device = self.rm.get_instrument(address)

    def read_ac_vrms(self):
        time.sleep(.75)
        self.device.write("AUTOSCALE")
        time.sleep(.75)
        self.device.write("MEASURE:VRMS? DISPLAY,AC")
        time.sleep(.75)
        return float(self.device.read())


# `VisaIOError`:
#  - Oscilloscope unplugged while running without restarting.
#  - Oscilloscope not plugged in after reboot.


def get_oscope_reading():
    import PyZenity

    response = None
    while response is None:
        response = PyZenity.GetText()
    return float(response)

@@ -932,8 +932,882 @@
 sponse)%0A
+%0A%0Adef check_text_entry_dialog(*args, **kwargs):%0A    from pygtkhelpers.ui.extra_dialogs import text_entry_dialog%0A%0A    validate = kwargs.pop('validate', lambda x: True)%0A    while True:%0A        response = text_entry_dialog(*args, **kwargs)%0A        # Cancel calibration%0A        if response is None:%0A            return%0A        # Check that it is a valid voltage%0A        elif validate(response):%0A            return response%0A%0A%0Adef read_oscope():%0A    title = 'Feedback calibration wizard'%0A    question = 'What is the current RMS output voltage?'%0A%0A    def is_float(v):%0A        try:%0A            float(v)%0A            return True%0A        except:%0A            return False%0A%0A    response = check_text_entry_dialog(question, title=title,%0A                                       validate=is_float)%0A    if response is None:%0A        raise StopIteration%0A    else:%0A        return float(response)%0A

Add read_oscope