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

Added a check to integrate with the flatpak package #7248

Merged
merged 2 commits into from
Dec 26, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Added

- We added the extension support and the external application support (For Texshow, Texmaker and LyX) to the flatpak [#7248](https://github.com/JabRef/jabref/pull/7248)

### Changed

### Fixed
Expand Down
19 changes: 11 additions & 8 deletions buildres/linux/jabrefHost.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#!/usr/bin/python3 -u

# Note that running python with the `-u` flag is required on Windows,
# in order to ensure that stdin and stdout are opened in binary, rather
# than text, mode.
#!/usr/bin/python3

import json
import logging
Expand All @@ -15,17 +11,24 @@
import sys
from pathlib import Path

# We assume that this python script is located in "jabref/lib" while the executable is "jabref/bin/JabRef"
# Try a set of possible launchers to execute JabRef
script_dir = Path(__file__).resolve().parent.parent
relpath_path = script_dir / "bin/JabRef"
lowercase_path = shutil.which("jabref")
uppercase_path = shutil.which("JabRef")

# Relative path used in the portable install
if relpath_path.exists():
JABREF_PATH = relpath_path
# Lowercase launcher used in deb/rpm/snap packages
elif lowercase_path is not None and os.path.exists(lowercase_path):
JABREF_PATH = Path(lowercase_path)
# Uppercase launcher used in Arch AUR package
elif uppercase_path is not None and os.path.exists(uppercase_path):
JABREF_PATH = Path(uppercase_path)
# FLatpak support
elif subprocess.run(["flatpak", "info", "org.jabref.jabref"], capture_output=True).returncode == 0:
JABREF_PATH = "flatpak run org.jabref.jabref"
else:
logging.error("Could not determine JABREF_PATH")
sys.exit(-1)
Expand Down Expand Up @@ -70,7 +73,7 @@ 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)]
cmd = str(JABREF_PATH).split() + ["--importBibtex", r"{}".format(data)]
logging.info("Try to execute command {}".format(cmd))
try:
response = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
Expand All @@ -90,7 +93,7 @@ def add_jabref_entry(data):
logging.info(str(message))

if "status" in message and message["status"] == "validate":
cmd = [str(JABREF_PATH), "--version"]
cmd = str(JABREF_PATH).split() + ["--version"]
try:
response = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as exc:
Expand Down