From f73640aee4401e19d4aaea75a42faa7bbd3b875a Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Mon, 15 Jul 2019 16:08:09 +0100 Subject: [PATCH] Updated regex for Py37 --- .../sangaboard/extensible_serial_instrument.py | 18 +++++++++--------- .../stage/sangaboard/sangaboard.py | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/openflexure_microscope/stage/sangaboard/extensible_serial_instrument.py b/openflexure_microscope/stage/sangaboard/extensible_serial_instrument.py index f0426d09..ed749b69 100644 --- a/openflexure_microscope/stage/sangaboard/extensible_serial_instrument.py +++ b/openflexure_microscope/stage/sangaboard/extensible_serial_instrument.py @@ -199,15 +199,15 @@ class ExtensibleSerialInstrument(object): response_regex = response_string noop = lambda x: x #placeholder null parse function placeholders = [ #tuples of (regex matching placeholder, regex to replace it with, parse function) - (r"%c",r".", noop), - (r"%(\d+)c",r".{\1}", noop), #TODO support %cn where n is a number of chars - (r"%d",r"[-+]?\d+", int), - (r"%[eEfg]",r"[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?", float), - (r"%i",r"[-+]?(?:0[xX][\dA-Fa-f]+|0[0-7]*|\d+)", lambda x: int(x, 0)), #0=autodetect base - (r"%o",r"[-+]?[0-7]+", lambda x: int(x, 8)), #8 means octal - (r"%s",r"\S+",noop), - (r"%u",r"\d+",int), - (r"%[xX]",r"[-+]?(?:0[xX])?[\dA-Fa-f]+",lambda x: int(x, 16)), #16 forces hexadecimal + (r"%c", r".", noop), + (r"%(\d+)c", r".{\1}", noop), #TODO support %cn where n is a number of chars + (r"%d", r"[-+]?\\d+", int), + (r"%[eEfg]", r"[-+]?(?:\\d+(?:\.\\d*)?|\.\\d+)(?:[eE][-+]?\\d+)?", float), + (r"%i", r"[-+]?(?:0[xX][\\dA-Fa-f]+|0[0-7]*|\\d+)", lambda x: int(x, 0)), #0=autodetect base + (r"%o", r"[-+]?[0-7]+", lambda x: int(x, 8)), #8 means octal + (r"%s", r"\\s+", noop), + (r"%u", r"\\d+", int), + (r"%[xX]", r"[-+]?(?:0[xX])?[\\dA-Fa-f]+", lambda x: int(x, 16)), #16 forces hexadecimal ] matched_placeholders = [] for placeholder, regex, parse_fun in placeholders: diff --git a/openflexure_microscope/stage/sangaboard/sangaboard.py b/openflexure_microscope/stage/sangaboard/sangaboard.py index 7c3cc8ee..e7d19142 100644 --- a/openflexure_microscope/stage/sangaboard/sangaboard.py +++ b/openflexure_microscope/stage/sangaboard/sangaboard.py @@ -156,7 +156,7 @@ class Sangaboard(ExtensibleSerialInstrument): # Request firmware version from the board self.firmware = self.query("version",timeout=2).rstrip() - + logging.info("Firmware response: {}".format(self.firmware)) # Check for valid firmware string if self.firmware: match = re.match(r"Sangaboard Firmware v(([\d]+)(?:\.([\d]+))+)", self.firmware)