Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain compatibility with python3.5 and earlier #5649

Merged
merged 2 commits into from
Nov 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions buildres/linux/jabrefHost.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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
Expand All @@ -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


Expand All @@ -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"]
Expand Down