From 699754c77fb8cc50a491d1ae7bce480120fcf389 Mon Sep 17 00:00:00 2001 From: Galileo Sartor Date: Thu, 21 Nov 2019 12:54:32 +0100 Subject: [PATCH] Retain compatibility with python3.5 and earlier (#5649) * Remove fstring from jabrefHost.py Retain compatibility with distros with python3 version < 3.5 * Use str in logging config --- buildres/linux/jabrefHost.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/buildres/linux/jabrefHost.py b/buildres/linux/jabrefHost.py index cf9803da519..3c56a0a73e9 100755 --- a/buildres/linux/jabrefHost.py +++ b/buildres/linux/jabrefHost.py @@ -22,7 +22,7 @@ logging_dir = Path.home() / ".mozilla/native-messaging-hosts/" if not logging_dir.exists(): logging_dir.mkdir(parents=True) -logging.basicConfig(filename=logging_dir / "jabref_browser_extension.log") +logging.basicConfig(filename=str(logging_dir / "jabref_browser_extension.log")) # Read a message from stdin and decode it. def get_message(): @@ -31,9 +31,9 @@ def get_message(): logging.error("Raw_length null") sys.exit(0) message_length = struct.unpack("=I", raw_length)[0] - logging.info(f"Got length: {message_length} bytes to be read") + logging.info("Got length: {} bytes to be read".format(message_length)) message = sys.stdin.buffer.read(message_length).decode("utf-8") - logging.info(f"Got message of {len(message)} chars") + logging.info("Got message of {} chars".format(len(message))) data = json.loads(message) logging.info("Successfully retrieved JSON") return data @@ -60,13 +60,13 @@ def send_message(message): def add_jabref_entry(data): """Send string via cli as literal to preserve special characters""" cmd = [str(JABREF_PATH), "--importBibtex", r"{}".format(data)] - logging.info(f"Try to execute command {cmd}") + logging.info("Try to execute command {}".format(cmd)) try: response = subprocess.check_output(cmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as exc: - logging.error(f"Failed to call JabRef: {exc.returncode} {exc.output}") + logging.error("Failed to call JabRef: {} {}".format(exc.returncode, exc.output)) else: - logging.info(f"Called JabRef and got: {response}") + logging.info("Called JabRef and got: {}".format(response)) return response @@ -83,10 +83,10 @@ def add_jabref_entry(data): try: response = subprocess.check_output(cmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as exc: - logging.error(f"Failed to call JabRef: {exc.returncode} {exc.output}") + logging.error("Failed to call JabRef: {} {}".format(exc.returncode, exc.output)) send_message({"message": "jarNotFound", "path": JABREF_PATH}) else: - logging.info(f"{response}") + logging.info("Response: {}".format(response)) send_message({"message": "jarFound"}) else: entry = message["text"]