How to use the pfio.InitError function in pfio

To help you get started, we’ve selected a few pfio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thomasmacpherson / piface / python / piface / emulator.py View on Github external
def __init__(self, spi_liststore_lock):
        gtk.gdk.threads_init() # init the gdk threads
        threading.Thread.__init__(self)

        self.spi_liststore_lock = spi_liststore_lock

        # a bit of spaghetti set up
        emulator_parts.pfio = pfio
        emulator_parts.rpi_emulator = self
        self.spi_visualiser_section = emulator_parts.SpiVisualiserFrame(self)
        global pfio_connect
        try:
            pfio.init()
            pfio_connect = True
        except pfio.InitError:
            print "Could not connect to the SPI module (check privileges). Starting emulator assuming that the PiFace is not connected."
            pfio_connect = False
            emulator_parts.pfio = None

        self.emu_window = gtk.Window()
        self.emu_window.connect("delete-event", gtk.main_quit)
        self.emu_window.set_title(WINDOW_TITLE)

        # emu screen
        self.emu_screen = emulator_parts.EmulatorScreen(EMU_WIDTH, EMU_HEIGHT, EMU_SPEED)
        self.emu_screen.show()

        # board connected msg
        if pfio_connect:
            msg = "Pi Face detected!"
        else: