burghoff / Scientific-Inkscape

Scientific Inkscape: Inkscape extensions for figure resizing and editing
528 stars 20 forks source link

Incomplete terminal listing and string to byte string comparison #7

Closed razimantv closed 1 year ago

razimantv commented 1 year ago

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

https://github.com/burghoff/Scientific-Inkscape/blob/a40e57c48e35714c23896ef84778569b12bf7ca4/scientific_inkscape/autoexporter.py#L242-L257

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Thank you, that works perfectly.

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

burghoff commented 1 year ago

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