From 411838b7c599ee28931e07dd80d8ad73e52b4009 Mon Sep 17 00:00:00 2001 From: Julien Cochuyt Date: Thu, 20 Feb 2020 17:28:30 +0100 Subject: [PATCH] Python 3 compatibility (NVDA >= 2019.3) --- .../seikamini/__init__.py | 41 +++++++++++++++---- buildVars.py | 4 +- readme.md | 4 ++ 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/addon/brailleDisplayDrivers/seikamini/__init__.py b/addon/brailleDisplayDrivers/seikamini/__init__.py index 0e81d77..e81bf01 100644 --- a/addon/brailleDisplayDrivers/seikamini/__init__.py +++ b/addon/brailleDisplayDrivers/seikamini/__init__.py @@ -12,6 +12,8 @@ # 2019-04-23 (Accessolutions): # - Repackaging as an NVDA add-on. # - Amend driver description to mention newer models +# 2020-02-20 (Accessolutions): +# - Python 3 compatibility from ctypes import * import os @@ -27,6 +29,20 @@ import winUser +try: + from six.moves import xrange +except ImportError: + # NVDA version < 2018.3 + pass + + +try: + from addonAPIVersion import CURRENT as ADDON_API_VERSION +except ImportError: + # NVDA version < 2019.1 + ADDON_API_VERSION = (0, 0, 0) + + addonHandler.initTranslation() @@ -120,8 +136,10 @@ def __init__(self): # seikaDll.UpdateBrailleDisplay.errcheck=self.seika_errcheck seikaDll.UpdateBrailleDisplay.restype=c_int - seikaDll.UpdateBrailleDisplay.argtype=(c_char_p,c_int) - + if ADDON_API_VERSION >= (2019, 3): + seikaDll.UpdateBrailleDisplay.argtype = (POINTER(c_ubyte), c_int) + else: + seikaDll.UpdateBrailleDisplay.argtype = (c_char_p, c_int) # seikaDll.GetBrailleKey.errcheck=self.seika_errcheck seikaDll.GetBrailleKey.restype=c_int seikaDll.GetBrailleKey.argtype=(c_void_p,c_void_p) @@ -151,7 +169,7 @@ def __init__(self): pN = port.split("COM")[1] except IndexError: pN = "0" - portNum = int(pN) + portNum = int(pN, 10) log.info("seikamini test {c}, {b}".format(c=port, b=bName)) if seikaDll.BrailleOpen(0,portNum): @@ -174,11 +192,16 @@ def terminate(self): seikaDll.BrailleClose() def display(self, cells): - # every transmitted line consists of the preamble SEIKA_SENDHEADER and the Cells - line = "".join(chr(cell) for cell in cells) - expectedLength = self.numCells - line += chr(0) * (expectedLength - len(line)) - seikaDll.UpdateBrailleDisplay(line,self.numCells) + if ADDON_API_VERSION >= (2019, 3): + # cells will already be padded up to numCells. + cellBytes = bytes(cells) + seikaDll.UpdateBrailleDisplay(cellBytes,self.numCells) + else: + # every transmitted line consists of the preamble SEIKA_SENDHEADER and the Cells + line = "".join(chr(cell) for cell in cells) + expectedLength = self.numCells + line += chr(0) * (expectedLength - len(line)) + seikaDll.UpdateBrailleDisplay(line,self.numCells) def handleResponses(self): pint = c_int * 1 @@ -209,7 +232,7 @@ def handleResponses(self): if Key: # Mini Seika has no Btn .... gesture = InputGesture(keys=Key) if Btn: # Mini Seika has no Btn .... - gesture = InputGesture(keys=Btn) + gesture = InputGesture(keys=Btn) if Brl: # or how to handle Brailleinput? gesture = InputGesture(dots=Brl) if Key or Btn or Brl: diff --git a/buildVars.py b/buildVars.py index b059ae3..fbc7486 100644 --- a/buildVars.py +++ b/buildVars.py @@ -20,7 +20,7 @@ "addon_description" : _("""Repackaging by Accessolutions of the driver provided by the manufacturer as an NVDA add-on."""), # version - "addon_version" : "3.2.2019.1.1", + "addon_version" : "3.2.2019.3.1", # Author(s) "addon_author" : ( u"Accessolutions , " @@ -34,7 +34,7 @@ # Minimum NVDA version supported (e.g. "2018.3.0") "addon_minimumNVDAVersion" : "2012.2", # Last NVDA version supported/tested (e.g. "2018.4.0", ideally more recent than minimum version) - "addon_lastTestedNVDAVersion" : "2019.1.1", + "addon_lastTestedNVDAVersion" : "2019.3.1", # Add-on update channel (default is stable or None) "addon_updateChannel" : None, } diff --git a/readme.md b/readme.md index 7538e05..a27844e 100644 --- a/readme.md +++ b/readme.md @@ -4,12 +4,16 @@ - Copyright (C) 2019 Accessolutions ## Release Dates + - Seika notetakers driver NVDA add-on v3.2.2019.3.1 - February 20, 2020 - Seika notetakers driver NVDA add-on v3.2.2019.1.1 - April 23, 2019 - Seika Patch for NVDA v3.2 - July 10, 2017 - Seika Patch for NVDA v3.1 - July 6, 2017 - Seika Patch for NVDA v3.0 - June 12, 2017 - Seika Patch for NVDA v2.0 - April 23, 2017 +## Version 3.2.2019.3.1 +Python 3 compatibility + ## Version 3.2.2019.1.1 Repackaging by Accessolutions as an NVDA add-on.