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

Incomplete terminal listing and string to byte string comparison #7

Closed
razimantv opened this issue Feb 14, 2023 · 9 comments
Closed

Comments

@razimantv
Copy link
Contributor

The terminal list in autoexporter.py is a list of strings, while comparison is done with byte strings.

terminals = ["x-terminal-emulator", "mate-terminal", "gnome-terminal", "terminator", "xfce4-terminal", "urxvt", "rxvt", "termit", "Eterm", "aterm", "uxterm", "xterm", "roxterm", "termite", "lxterminal", "terminology", "st", "qterminal", "lilyterm", "tilix", "terminix", "konsole", "kitty", "guake", "tilda", "alacritty", "hyper", "terminal", "iTerm", "mintty", "xiterm", "terminal.app", "Terminal.app", "terminal-w", "terminal.js", "Terminal.js", "conemu", "cmder", "powercmd", "terminus", "termina", "terminal-plus", "iterm2", "terminus-terminal", "terminal-tabs"]
terms = []
for terminal in terminals:
result = subprocess.run(['which', terminal], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode == 0:
terms.append(terminal)
for t in reversed(terms):
if t == b"x-terminal-emulator":
LINUX_TERMINAL_CALL = (
"x-terminal-emulator -e bash -c '%CMD'"
)
elif t == b"gnome-terminal":
LINUX_TERMINAL_CALL = (
'gnome-terminal -- bash -c "%CMD; exec bash"'
)

My understanding is that strings do not equal byte strings in Python3.

Additionally, the terminal check is only done for gnome terminal and x-terminal-emulator, neither of which I have (only konsole).

@razimantv
Copy link
Contributor Author

I have made a pull request #8 to solve the string comparison issue, but I have been unable to get the exporter working with konsole.

burghoff added a commit that referenced this issue Feb 14, 2023
Make comparisons without byte strings to solve part of Issue #7
@burghoff
Copy link
Owner

Thanks, I test infrequently on Linux. Did you try adding a case like the following?

    elif t == "konsole":
        LINUX_TERMINAL_CALL = "konsole -e bash -c '%CMD'"

Also, what version/installation are you using? I couldn't get Snap and AppImages to work at all, and all of the recent versions seem to be one of those.

@razimantv
Copy link
Contributor Author

I tried different ways to call konsole. They all open the terminal, but the control does not return to Inkscape, so I cannot edit files anymore.

When I did try with gnome-terminal, I was able to edit in Inkscape further. But the terminal kept giving errors and the autoexport itself was not working. I am trying to find the origin now, but not much luck.

I am on Inkscape 1.2.2 (b0a8486541, 2022-12-01) on Arch installed with Pacman, running Python 3.10.9.

@razimantv
Copy link
Contributor Author

This is the error I see on gnome-terminal when I save the file in Inkscape, BTW:

Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/home/razimantv/.config/inkscape/extensions/autoexporter_script.py", line 268, in run
    offset = round(os.get_terminal_size().columns/2);
OSError: [Errno 25] Inappropriate ioctl for device

@burghoff
Copy link
Owner

Can you change that line to offset=50 to see if that fixes it?

Also, since all of the recent versions of Inkscape on all platforms come with Python GTK bindings, I have been thinking about using that to make a simple GUI, which should also work on all versions of Linux.

@razimantv
Copy link
Contributor Author

Yes. I had removed the offset lines altogether and it worked. Setting offset to 50 works too. The terminal is empty (does not show the expected print statements), but the file gets autosaved.

@burghoff
Copy link
Owner

burghoff commented Feb 15, 2023

On the dev branch I added new versions of autoexporter.py and autoexporter_script.py that use the built-in GTK instead of the terminal business. It should greatly improve Linux compatibility. Would you mind trying it out?

@razimantv
Copy link
Contributor Author

Thank you, that works perfectly.

The directory was a bit polluted with extra package directories etc. I removed those and it still works.

@burghoff
Copy link
Owner

The packages are for the new Powerpoint extractor extension I've been working on, so they don't matter for the others.

@burghoff burghoff closed this as completed Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants