I would definitely expect an exception to be raised, but it's not happening. :-( Something seems to be going awry deeper in the call to readKey. Attached is a new foo.py that eliminates the pyatpi references. The same test procedure applies:

1) Run brltty in one terminal
2) Run foo.py in another
3) Kill brltty
4) foo.py seg faults

I'm not sure how to debug this.

Will

Samuel Thibault wrote:
Sébastien Hinderer, le Thu 09 Jul 2009 01:47:40 +0200, a écrit :
brlapi_readKey will return -1 and the brlapi_errno variable will contain
BRLAPI_ERROR_EOF, I think.

Yes.

Not sure how this works in Python,

That should be translated into the corresponding OperationError being
raised.

Samuel
_______________________________________________
This message was sent via the BRLTTY mailing list.
To post a message, send an e-mail to: [email protected]
For general information, go to: http://mielke.cc/mailman/listinfo/brltty

import os

import brlapi
import gobject

brlAPI = None
brlAPIRunning = False
brlAPISourceId = 0

def printBrailleEvent(command):
    print("BRAILLE EVENT: %s" % repr(command))

def brlAPIKeyReader(source, condition):
    """Method to read a key from the BrlAPI bindings.  This is a
    gobject IO watch handler.
    """
    global brlAPIRunning
    print "HERE"
    try:
        print os.fstat(brlAPI.fileDescriptor)
    except:
        print "BAD FILE DESCRIPTOR!!!"
        return False
    try:
        key = brlAPI.readKey(False)
        if key:
            printBrailleEvent(brlAPI.expandKeyCode(key))
    except:
        print "OOPS!"
        brlAPIRunning = False
    return brlAPIRunning

def init(tty=7):
    global brlAPI
    global brlAPIRunning
    global brlAPISourceId

    gobject.threads_init()
    brlAPI = brlapi.Connection()

    try:
        brlAPI.enterTtyModeWithPath()
        brlAPIRunning = True
    except:
        brlAPI.enterTtyMode(tty)
        brlAPIRunning = True

    if brlAPIRunning:
        brlAPISourceId = gobject.io_add_watch(brlAPI.fileDescriptor,
                                              gobject.IO_IN,
                                              brlAPIKeyReader)

if __name__ == "__main__":
    init()
    gobject.MainLoop().run()
_______________________________________________
This message was sent via the BRLTTY mailing list.
To post a message, send an e-mail to: [email protected]
For general information, go to: http://mielke.cc/mailman/listinfo/brltty

Reply via email to