def initialize_display(): def writeProperty(name, value): sys.stdout.write(f'{name:>20}:\t{value}\n') writeProperty('BrlAPI Version', '.'.join(map(str, brlapi.getLibraryVersion()))) try: # to specify explicit key: # brl = brlapi.Connection(b'127.0.0.1:0', b'/etc/brlapi.key') brl = brlapi.Connection() try: disp_ncol, disp_nrow = brl.displaySize writeProperty('File Descriptor', brl.fileDescriptor) writeProperty('Server Host', brl.host.decode('utf-8')) writeProperty('Authorization', brl.auth.decode('utf-8')) writeProperty('Driver Name', brl.driverName.decode('utf-8')) writeProperty('Model Identifier', brl.modelIdentifier.decode('utf-8')) writeProperty('Display Size', f'{disp_nrow} x {disp_ncol}') brl.enterTtyMode(brl.fileDescriptor) return brl except Exception as e: print('Exception on info display: {}'.format(e)) except brlapi.ConnectionError as e: if e.brlerrno == brlapi.ERROR_CONNREFUSED: logger.error('Connection to %s refused. BRLTTY is too busy...' % e.host) elif e.brlerrno == brlapi.ERROR_AUTHENTICATION: logger.error( 'Authentication with %s failed. Please check the permissions of %s' % (e.host, e.auth)) elif e.brlerrno == brlapi.ERROR_LIBCERR and ( e.libcerrno == errno.ECONNREFUSED or e.libcerrno == errno.ENOENT): logger.error('Connection to %s failed. Is BRLTTY really running?' % (e.host)) else: logger.error('Connection to BRLTTY at %s failed: ' % (e.host)) print(e) print(e.brlerrno) print(e.libcerrno)
library = loadLibrary(getLibraryDirectory(), "brlapi") import brlapi if __name__ == "__main__": import errno def writeProperty(name, value): try: value = value.decode("utf-8") except AttributeError: pass sys.stdout.write(name + ": " + value + "\n") writeProperty("BrlAPI Version", ".".join(map(str, brlapi.getLibraryVersion()))) try: brl = brlapi.Connection() try: writeProperty("File Descriptor", str(brl.fileDescriptor)) writeProperty("Server Host", brl.host) writeProperty("Authorization Schemes", brl.auth) writeProperty("Driver Name", brl.driverName) writeProperty("Model Identifier", brl.modelIdentifier) writeProperty("Display Width", str(brl.displaySize[0])) writeProperty("Display Height", str(brl.displaySize[1])) brl.enterTtyMode() try:
return ctypes.WinDLL(os.path.join(directory, names[0])) return ctypes.CDLL(os.path.join(directory, ("lib" + name + ".so"))) sys.path.insert(0, getBuildDirectory("lib")) library = loadLibrary(getLibraryDirectory(), "brlapi") import brlapi if __name__ == "__main__": import errno def writeProperty (name, value): sys.stdout.write(name + ": " + value + "\n") writeProperty("BrlAPI Version", ".".join(map(str, brlapi.getLibraryVersion()))) try: brl = brlapi.Connection() try: writeProperty("File Descriptor", str(brl.fileDescriptor)) writeProperty("Server Host", brl.host) writeProperty("Authorization Schemes", brl.auth) writeProperty("Driver Name", brl.driverName) writeProperty("Model Identifier", brl.modelIdentifier) writeProperty("Display Width", str(brl.displaySize[0])) writeProperty("Display Height", str(brl.displaySize[1])) brl.enterTtyMode() timeout = 10