Inkscape.org
Creating New Extensions What is throwing this error while overwriting?
  1. #1
    Simon Simon @SimonH
    *

    This is inklinea's Quick exporter: https://inkscape.org/~inklinea/%E2%98%85quick-export

    I'm modifying it so that it has an option to overwrite existing files; which means that anything you have loaded as a file layer in Krita or any other software; all we need to sync that file is the hit one button and this is super handy to couple with the 'Object to Vector' feature to ensure that it's looks correct in Krita. This is because It seems Inkscape is not going entirely by CSS convention for SVG's while Krita is but is not quite fully complete in it's implementation; so converting layers to vector quickly within a one click export solution makes a lot of sense.

    I got it working but I'm getting a warning/error when overwriting.
    In case it matters I'm using Nobara Linux with Gnome.

    So here's the new version of the PY script ('quick_export.py'):
     

    #!/usr/bin/env python
    # coding=utf-8
    #
    # Copyright (C) [2021] [Matt Cottam], [mpcottam@raincloud.co.uk]
    #
    # This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 2 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    #
    #
    # #############################################################################
    #  Quick Export - Quickly export Inkscape svg, plain svg, and png
    #  After setting the options in the main dialogue
    #  Assign a shortcut in Inkscape Edit>Preferences>Interface>Keyboard to org.inkscape.inklinea.quick_export.noprefs
    #  For shortcut triggered quick export
    #  It does require that you have saved
    #  Your svg file at least once before using (will not work on an unsaved svg)
    #  Requires Inkscape 1.1+
    # #############################################################################
    
    import inkex
    from inkex import command
    from pathlib import Path
    from datetime import datetime
    
    def command_line_call(self):
    
        # current date and time to time stamp
        timestamp = datetime.today().replace(microsecond=0)
        timestamp_suffix = str(timestamp.strftime('%Y-%m-%d-%H-%M-%S'))
    
        # Get output directory
        my_file_path = self.options.input_file
    
        # Collect export format options
        my_export_path = self.options.save_path
    
        # Get name of currently open Inkscape file
        my_filename = self.svg.name
    
        # Check to see if user has saved file at least once
        if len(my_filename) < 2:
            inkex.errormsg('Please Save Your File First')
            return
    
        # Build a formatted string for command line actions
        my_actions = '--actions='
    
        # Use the original filename without timestamp if overwrite is true
        if self.options.overwrite_existing_file == 'true':
            my_svg_export_filename_path = my_export_path + '/' + my_filename
            my_svg_plain_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_plain.svg')
            my_png_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '.png')
            my_pdf_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '.pdf')
            my_html5_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '.html')
        else:
            my_svg_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '.svg')
            my_svg_plain_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '_plain.svg')
            my_png_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '.png')
            my_pdf_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '.pdf')
            my_html5_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '.html')
    
        # Get png dpi setting
        png_dpi = self.options.png_dpi
    
        # Check which export file formats have been selected by user
        if self.options.export_svg_cb == 'true':
            export_svg_actions = f'export-filename:{my_svg_export_filename_path};export-do;'
            my_actions = my_actions + export_svg_actions
    
        if self.options.export_svg_plain_cb == 'true':
            export_svg_plain_actions = f'export-filename:{my_svg_plain_export_filename_path};export-plain-svg;export-do;'
            my_actions = my_actions + export_svg_plain_actions
    
        if self.options.export_png_cb == 'true':
            export_png_actions = f'export-filename:{my_png_export_filename_path};export-dpi:{png_dpi};export-do;'
            my_actions = my_actions + export_png_actions
    
        if self.options.export_pdf_cb == 'true':
            export_pdf_actions = f'export-filename:{my_pdf_export_filename_path};export-do;'
            my_actions = my_actions + export_pdf_actions
    
        if self.options.export_html5_cb == 'true':
            export_html5_actions = f'export-filename:{my_html5_export_filename_path};export-do;'
            my_actions = my_actions + export_html5_actions
    
        # Any text to path export actions need to be at end of action list
        if self.options.export_svg_ttp_cb == 'true':
            export_svg_actions = f'export-text-to-path;export-filename:{my_svg_export_filename_path};export-plain-svg:no;export-do;'
            my_actions = my_actions + export_svg_actions
    
        if self.options.export_svg_plain_ttp_cb == 'true':
            export_svg_actions = f'export-text-to-path;export-filename:{my_svg_plain_export_filename_path};export-plain-svg;export-do;'
            my_actions = my_actions + export_svg_actions
    
        # Exit if no export file formats have been selected
        if my_actions == '--actions=':
            inkex.errormsg('Please Select At Least One Export Format')
            return
    
        # Check to make sure export directory exists
        if Path(my_export_path).is_dir():
            inkex.command.inkscape(my_file_path, my_actions)
        else:
            inkex.errormsg('Please Select An Export Folder')
    
    class QuickExport(inkex.EffectExtension):
    
        def add_arguments(self, pars):
    
            pars.add_argument("--notebook_main", type=str, dest="notebook_main", default=0)
    
            pars.add_argument("--export_svg_cb", type=str, dest="export_svg_cb", default='true')
            pars.add_argument("--export_svg_ttp_cb", type=str, dest="export_svg_ttp_cb", default='true')
    
            pars.add_argument("--export_svg_plain_cb", type=str, dest="export_svg_plain_cb", default='true')
            pars.add_argument("--export_svg_plain_ttp_cb", type=str, dest="export_svg_plain_ttp_cb", default='true')
    
            pars.add_argument("--export_png_cb", type=str, dest="export_png_cb", default='true')
            pars.add_argument("--png_dpi", type=int, dest="png_dpi", default=96)
    
            pars.add_argument("--export_pdf_cb", type=str, dest="export_pdf_cb", default='true')
            pars.add_argument("--export_html5_cb", type=str, dest="export_html5_cb", default='true')
    
            pars.add_argument("--save_path", type=str, dest="save_path", default=str(Path.home()))
    
            pars.add_argument("--overwrite_existing_file", type=str, dest="overwrite_existing_file", default='false')
    
        def effect(self):
            command_line_call(self)
    
    if __name__ == '__main__':
        QuickExport().run()
    

     

    And in case it's needed for testing, the INX file ('quick_export.inx')
     

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!--Copyright (C) [2021] [Matt Cottam], [mpcottam@raincloud.co.uk]-->
    <!--This program is free software; you can redistribute it and/or modify-->
    <!--it under the terms of the GNU General Public License as published by-->
    <!--the Free Software Foundation; either version 2 of the License, or-->
    <!--(at your option) any later version.-->
    <!--This program is distributed in the hope that it will be useful,-->
    <!--but WITHOUT ANY WARRANTY; without even the implied warranty of-->
    <!--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the-->
    <!--GNU General Public License for more details.-->
    <!--You should have received a copy of the GNU General Public License-->
    <!--along with this program; if not, write to the Free Software-->
    <!--Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.-->
    
    <!-- #############################################################################-->
    <!-- #  Quick Export - Quickly export Inkscape svg, plain svg, and png-->
    <!-- #  After setting the options in the main dialogue-->
    <!-- #  Assign a shortcut in Inkscape Edit>Preferences>Interface>Keyboard to org.inkscape.inklinea.quick_export.noprefs-->
    <!-- #  For shortcut triggered quick export-->
    <!-- # Requires Inkscape 1.1+ -->
    <!-- #############################################################################-->
    
    <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
        <name>Quick Export</name>
        <id>org.inkscape.inklinea.quick_export</id>
        <param name="notebook_main" type="notebook">
            <page name="settings_page" gui-text="Settings">
                <hbox>
                    <param name="export_svg_cb" type="boolean" gui-text="Export Inkscape SVG" gui-description="Export Inkscape SVG">true</param>
                    <param name="export_svg_ttp_cb" type="boolean" gui-text="Export Inkscape SVG (Text to Path)" gui-description="Export Inkscape SVG (Text to path)">true</param>
                </hbox>
                <hbox>
                    <param name="export_svg_plain_cb" type="boolean" gui-text="Export Plain SVG" gui-description="Export Plain SVG">true</param>
                    <param name="export_svg_plain_ttp_cb" type="boolean" gui-text="Export Plain SVG (Text to path)" gui-description="Export Plain SVG (Text to path)">true</param>
                </hbox>
                <param name="export_png_cb" type="boolean" gui-text="Export PNG" gui-description="Export PNG">true</param>
                <param name="png_dpi" type="int" min="10" max="99999999" gui-text="PNG dpi">96</param>
                <separator/>
                <param name="export_pdf_cb" type="boolean" gui-text="Export PDF" gui-description="Export PDF Document">true</param>
                <param name="export_html5_cb" type="boolean" gui-text="Export HTML5" gui-description="Export HTML5 Canvas">true</param>
                <separator/>
                <param type="path" name="save_path" gui-text="File Save Path" mode="folder">None Selected</param>
                <separator/>
                <param name="overwrite_existing_file" type="boolean" gui-text="Overwrite Existing File" gui-description="If checked, the file will be overwritten instead of creating a new file with a unique timestamp.">false</param>
            </page>
            <page name="about_page" gui-text="About">
                <label>
                    Quick Export - Quickly export Inkscape svg, plain svg, png, pdf and html5 canvas
                </label>
                <label>
                    Inkscape 1.1+
                </label>
                <label appearance="url">
                    https://gitlab.com/inklinea/quick-export
                </label>
                <label appearance="url">
                    https://inkscape.org/~inklinea/
                </label>
                <label>
                * This is not a replacement for saving or Inkscape autosave :) ---
                Appears at Extensions>Export ---
                After setting the options in the main dialogue ---
                Assign a shortcut in Inkscape Edit>Preferences>Interface>Keyboard to
                </label>
                    <label appearance="header">org.inkscape.inklinea.quick_export.noprefs
                    </label>
                <label>
                    For shortcut triggered quick export --- Not 100% sure where the PDF and HTML5 settings are pulled from, presume from last used save settings.
                </label>
            </page>
        </param>
        <effect needs-live-preview="false">
            <object-type>path</object-type>
            <effects-menu>
                <submenu name="Export"/>
            </effects-menu>
        </effect>
        <script>
            <command location="inx" interpreter="python">quick_export.py</command>
        </script>
    </inkscape-extension>
    


    And it works; but here's the error message when when the file exists already and I try to re-export with overwrite enabled:

    Traceback (most recent call last):
      File "/usr/share/inkscape/extensions/quick_export.py", line 143, in <module>
        QuickExport().run()
      File "/usr/share/inkscape/extensions/inkex/base.py", line 250, in run
        self.save_raw(self.effect())
                      ^^^^^^^^^^^^^
      File "/usr/share/inkscape/extensions/quick_export.py", line 140, in effect
        command_line_call(self)
      File "/usr/share/inkscape/extensions/quick_export.py", line 113, in command_line_call
        inkex.command.inkscape(my_file_path, my_actions)
      File "/usr/share/inkscape/extensions/inkex/command.py", line 294, in inkscape
        stdout = call(INKSCAPE_EXECUTABLE_NAME, svg_file, *args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/share/inkscape/extensions/inkex/command.py", line 260, in call
        stdout = _call(program, *args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/share/inkscape/extensions/inkex/command.py", line 239, in _call
        raise ProgramRunError(program, process.returncode, stderr, stdout, args)
    inkex.command.ProgramRunError: Return Code: -11: b'\nEmergency save activated!\nEmergency save completed. Inkscape will close now.\nIf you can reproduce this crash, please file a bug at https://inkscape.org/report\nwith a detailed description of the steps leading to the crash, so we can fix it.\n** Message: 00:12:38.191: Error: \n 0# Inkscape::Application::crash_handler(int) in /usr/bin/inkscape\n 1# 0x00007F2DB9409B70 in /lib64/libc.so.6\n 2# 0x00007F2DBA01A039 in /lib64/libgtk-3.so.0\n 3# 0x00007F2DBB56709C in /lib64/libgio-2.0.so.0\n 4# 0x00007F2DBB56AE03 in /lib64/libgio-2.0.so.0\n 5# 0x00007F2DBB5D563B in /lib64/libgio-2.0.so.0\n 6# 0x00007F2DBB56709C in /lib64/libgio-2.0.so.0\n 7# 0x00007F2DBB56AE03 in /lib64/libgio-2.0.so.0\n 8# 0x00007F2DBB5C29A2 in /lib64/libgio-2.0.so.0\n 9# 0x00007F2DBB56709C in /lib64/libgio-2.0.so.0\n10# 0x00007F2DBB5670D5 in /lib64/libgio-2.0.so.0\n11# 0x00007F2DBB6E04FD in /lib64/libglib-2.0.so.0\n12# g_main_context_dispatch in /lib64/libglib-2.0.so.0\n13# 0x00007F2DBB7426B8 in /lib64/libglib-2.0.so.0\n14# g_main_context_iteration in /lib64/libglib-2.0.so.0\n15# g_application_run in /lib64/libgio-2.0.so.0\n16# main in /usr/bin/inkscape\n17# 0x00007F2DB93F3B4A in /lib64/libc.so.6\n18# __libc_start_main in /lib64/libc.so.6\n19# _start in /usr/bin/inkscape\n'
    b''
    args: ("Return Code: -11: b'\\nEmergency save activated!\\nEmergency save completed. Inkscape will close now.\\nIf you can reproduce this crash, please file a bug at https://inkscape.org/report\\nwith a detailed description of the steps leading to the crash, so we can fix it.\\n** Message: 00:12:38.191: Error: \\n 0# Inkscape::Application::crash_handler(int) in /usr/bin/inkscape\\n 1# 0x00007F2DB9409B70 in /lib64/libc.so.6\\n 2# 0x00007F2DBA01A039 in /lib64/libgtk-3.so.0\\n 3# 0x00007F2DBB56709C in /lib64/libgio-2.0.so.0\\n 4# 0x00007F2DBB56AE03 in /lib64/libgio-2.0.so.0\\n 5# 0x00007F2DBB5D563B in /lib64/libgio-2.0.so.0\\n 6# 0x00007F2DBB56709C in /lib64/libgio-2.0.so.0\\n 7# 0x00007F2DBB56AE03 in /lib64/libgio-2.0.so.0\\n 8# 0x00007F2DBB5C29A2 in /lib64/libgio-2.0.so.0\\n 9# 0x00007F2DBB56709C in /lib64/libgio-2.0.so.0\\n10# 0x00007F2DBB5670D5 in /lib64/libgio-2.0.so.0\\n11# 0x00007F2DBB6E04FD in /lib64/libglib-2.0.so.0\\n12# g_main_context_dispatch in /lib64/libglib-2.0.so.0\\n13# 0x00007F2DBB7426B8 in /lib64/libglib-2.0.so.0\\n14# g_main_context_iteration in /lib64/libglib-2.0.so.0\\n15# g_application_run in /lib64/libgio-2.0.so.0\\n16# main in /usr/bin/inkscape\\n17# 0x00007F2DB93F3B4A in /lib64/libc.so.6\\n18# __libc_start_main in /lib64/libc.so.6\\n19# _start in /usr/bin/inkscape\\n'\nb''\nargs: ('inkscape', -11, b'\\nEmergency save activated!\\nEmergency save completed. Inkscape will close now.\\nIf you can reproduce this crash, please file a bug at https://inkscape.org/report\\nwith a detailed description of the steps leading to the crash, so we can fix it.\\n** Message: 00:12:38.191: Error: \\n 0# Inkscape::Application::crash_handler(int) in /usr/bin/inkscape\\n 1# 0x00007F2DB9409B70 in /lib64/libc.so.6\\n 2# 0x00007F2DBA01A039 in /lib64/libgtk-3.so.0\\n 3# 0x00007F2DBB56709C in /lib64/libgio-2.0.so.0\\n 4# 0x00007F2DBB56AE03 in /lib64/libgio-2.0.so.0\\n 5# 0x00007F2DBB5D563B in /lib64/libgio-2.0.so.0\\n 6# 0x00007F2DBB56709C in /lib64/libgio-2.0.so.0\\n 7# 0x00007F2DBB56AE03 in /lib64/libgio-2.0.so.0\\n 8# 0x00007F2DBB5C29A2 in /lib64/libgio-2.0.so.0\\n 9# 0x00007F2DBB56709C in /lib64/libgio-2.0.so.0\\n10# 0x00007F2DBB5670D5 in /lib64/libgio-2.0.so.0\\n11# 0x00007F2DBB6E04FD in /lib64/libglib-2.0.so.0\\n12# g_main_context_dispatch in /lib64/libglib-2.0.so.0\\n13# 0x00007F2DBB7426B8 in /lib64/libglib-2.0.so.0\\n14# g_main_context_iteration in /lib64/libglib-2.0.so.0\\n15# g_application_run in /lib64/libgio-2.0.so.0\\n16# main in /usr/bin/inkscape\\n17# 0x00007F2DB93F3B4A in /lib64/libc.so.6\\n18# __libc_start_main in /lib64/libc.so.6\\n19# _start in /usr/bin/inkscape\\n', b'', ['/usr/bin/inkscape', '/tmp/ink_ext_XXXXXX.svgY9C4E2', '--actions=export-text-to-path;export-filename:/mnt/sda1/Documents/COA2/Logo/Post/SVG/SVGQuickTest/Newtest/CoaToolsText_InkscapeSVG_plain.svg;export-plain-svg;export-do;'])",)

    The error message doesn't stop the overwrite; but requires me to click through and I'd honestly mute it if I knew how.

    Any ideas?

  2. #2
    inklinea inklinea @inklinea⛰️
    *

    In Inkscape 1.3

    There is an action:

    export-overwrite

    A cheeky way to add the overwrite option might be to add this action ( including the semicolon ) to a variable.

    Then join to the final action string before the command call.

    Or just join it as a string.

    my_actions = ''.join(('export-overwrite;', my_actions))

    I've not tested it :)

  3. #3
    Simon Simon @SimonH
    *

    Awesome; that did solve the issue with the overwriting; and now it will overwrite without error. But now, it's giving me a similar error when exporting for the first time; and I think it's because there's something wrong with the way my code checks to see if a file is there already to determine whether using standard save or overwrite save.

    This is the error I get when there are no files I and I go to update with overwrite enabled:
     

    Traceback (most recent call last):
      File "/usr/share/inkscape/extensions/quick_export.py", line 131, in <module>
        QuickExport().run()
      File "/usr/share/inkscape/extensions/inkex/base.py", line 250, in run
        self.save_raw(self.effect())
                      ^^^^^^^^^^^^^
      File "/usr/share/inkscape/extensions/quick_export.py", line 127, in effect
        command_line_call(self)
      File "/usr/share/inkscape/extensions/quick_export.py", line 105, in command_line_call
        inkex.command.inkscape(my_file_path, my_actions)
      File "/usr/share/inkscape/extensions/inkex/command.py", line 294, in inkscape
        stdout = call(INKSCAPE_EXECUTABLE_NAME, svg_file, *args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/share/inkscape/extensions/inkex/command.py", line 260, in call
        stdout = _call(program, *args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/share/inkscape/extensions/inkex/command.py", line 239, in _call
        raise ProgramRunError(program, process.returncode, stderr, stdout, args)
    inkex.command.ProgramRunError: Return Code: -11: b'\nEmergency save activated!\nEmergency save completed. Inkscape will close now.\nIf you can reproduce this crash, please file a bug at https://inkscape.org/report\nwith a detailed description of the steps leading to the crash, so we can fix it.\n** Message: 14:06:23.863: Error: \n 0# Inkscape::Application::crash_handler(int) in /usr/bin/inkscape\n 1# 0x00007F8BBF45BB70 in /lib64/libc.so.6\n 2# 0x00007F8BC021A039 in /lib64/libgtk-3.so.0\n 3# 0x00007F8BC169A09C in /lib64/libgio-2.0.so.0\n 4# 0x00007F8BC169DE03 in /lib64/libgio-2.0.so.0\n 5# 0x00007F8BC170863B in /lib64/libgio-2.0.so.0\n 6# 0x00007F8BC169A09C in /lib64/libgio-2.0.so.0\n 7# 0x00007F8BC169DE03 in /lib64/libgio-2.0.so.0\n 8# 0x00007F8BC16F59A2 in /lib64/libgio-2.0.so.0\n 9# 0x00007F8BC169A09C in /lib64/libgio-2.0.so.0\n10# 0x00007F8BC169A0D5 in /lib64/libgio-2.0.so.0\n11# 0x00007F8BC181A4FD in /lib64/libglib-2.0.so.0\n12# g_main_context_dispatch in /lib64/libglib-2.0.so.0\n13# 0x00007F8BC187C6B8 in /lib64/libglib-2.0.so.0\n14# g_main_context_iteration in /lib64/libglib-2.0.so.0\n15# g_application_run in /lib64/libgio-2.0.so.0\n16# main in /usr/bin/inkscape\n17# 0x00007F8BBF445B4A in /lib64/libc.so.6\n18# __libc_start_main in /lib64/libc.so.6\n19# _start in /usr/bin/inkscape\n'
    b''
    args: ("Return Code: -11: b'\\nEmergency save activated!\\nEmergency save completed. Inkscape will close now.\\nIf you can reproduce this crash, please file a bug at https://inkscape.org/report\\nwith a detailed description of the steps leading to the crash, so we can fix it.\\n** Message: 14:06:23.863: Error: \\n 0# Inkscape::Application::crash_handler(int) in /usr/bin/inkscape\\n 1# 0x00007F8BBF45BB70 in /lib64/libc.so.6\\n 2# 0x00007F8BC021A039 in /lib64/libgtk-3.so.0\\n 3# 0x00007F8BC169A09C in /lib64/libgio-2.0.so.0\\n 4# 0x00007F8BC169DE03 in /lib64/libgio-2.0.so.0\\n 5# 0x00007F8BC170863B in /lib64/libgio-2.0.so.0\\n 6# 0x00007F8BC169A09C in /lib64/libgio-2.0.so.0\\n 7# 0x00007F8BC169DE03 in /lib64/libgio-2.0.so.0\\n 8# 0x00007F8BC16F59A2 in /lib64/libgio-2.0.so.0\\n 9# 0x00007F8BC169A09C in /lib64/libgio-2.0.so.0\\n10# 0x00007F8BC169A0D5 in /lib64/libgio-2.0.so.0\\n11# 0x00007F8BC181A4FD in /lib64/libglib-2.0.so.0\\n12# g_main_context_dispatch in /lib64/libglib-2.0.so.0\\n13# 0x00007F8BC187C6B8 in /lib64/libglib-2.0.so.0\\n14# g_main_context_iteration in /lib64/libglib-2.0.so.0\\n15# g_application_run in /lib64/libgio-2.0.so.0\\n16# main in /usr/bin/inkscape\\n17# 0x00007F8BBF445B4A in /lib64/libc.so.6\\n18# __libc_start_main in /lib64/libc.so.6\\n19# _start in /usr/bin/inkscape\\n'\nb''\nargs: ('inkscape', -11, b'\\nEmergency save activated!\\nEmergency save completed. Inkscape will close now.\\nIf you can reproduce this crash, please file a bug at https://inkscape.org/report\\nwith a detailed description of the steps leading to the crash, so we can fix it.\\n** Message: 14:06:23.863: Error: \\n 0# Inkscape::Application::crash_handler(int) in /usr/bin/inkscape\\n 1# 0x00007F8BBF45BB70 in /lib64/libc.so.6\\n 2# 0x00007F8BC021A039 in /lib64/libgtk-3.so.0\\n 3# 0x00007F8BC169A09C in /lib64/libgio-2.0.so.0\\n 4# 0x00007F8BC169DE03 in /lib64/libgio-2.0.so.0\\n 5# 0x00007F8BC170863B in /lib64/libgio-2.0.so.0\\n 6# 0x00007F8BC169A09C in /lib64/libgio-2.0.so.0\\n 7# 0x00007F8BC169DE03 in /lib64/libgio-2.0.so.0\\n 8# 0x00007F8BC16F59A2 in /lib64/libgio-2.0.so.0\\n 9# 0x00007F8BC169A09C in /lib64/libgio-2.0.so.0\\n10# 0x00007F8BC169A0D5 in /lib64/libgio-2.0.so.0\\n11# 0x00007F8BC181A4FD in /lib64/libglib-2.0.so.0\\n12# g_main_context_dispatch in /lib64/libglib-2.0.so.0\\n13# 0x00007F8BC187C6B8 in /lib64/libglib-2.0.so.0\\n14# g_main_context_iteration in /lib64/libglib-2.0.so.0\\n15# g_application_run in /lib64/libgio-2.0.so.0\\n16# main in /usr/bin/inkscape\\n17# 0x00007F8BBF445B4A in /lib64/libc.so.6\\n18# __libc_start_main in /lib64/libc.so.6\\n19# _start in /usr/bin/inkscape\\n', b'', ['/usr/bin/inkscape', '/tmp/ink_ext_XXXXXX.svg3C5EF2', '--actions=export-text-to-path;export-filename:/mnt/sda1/Documents/COA2/Logo/Post/SVG/SVGQuickTest/Newtest/CoaToolsText_InkscapeSVG_plain.svg;export-plain-svg;export-do;'])",)
    



    Here's the latest PY code; any ideas to fix it?

    #!/usr/bin/env python
    # coding=utf-8
    #
    # Copyright (C) [2021] [Matt Cottam], [mpcottam@raincloud.co.uk]
    #
    # This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 2 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    #
    #
    # #############################################################################
    #  Quick Export - Quickly export Inkscape svg, plain svg, and png
    #  After setting the options in the main dialogue
    #  Assign a shortcut in Inkscape Edit>Preferences>Interface>Keyboard to org.inkscape.inklinea.quick_export.noprefs
    #  For shortcut triggered quick export
    #  It does require that you have saved
    #  Your svg file at least once before using (will not work on an unsaved svg)
    #  Requires Inkscape 1.1+
    # #############################################################################
    
    import inkex
    from pathlib import Path
    from datetime import datetime
    
    # Function to check if a file already exists
    def file_exists(filepath):
        return Path(filepath).exists()
    
    # Main function to handle the export logic
    def command_line_call(self):
        timestamp = datetime.today().replace(microsecond=0)
        timestamp_suffix = str(timestamp.strftime('%Y-%m-%d-%H-%M-%S'))
    
        my_file_path = self.options.input_file
        my_export_path = self.options.save_path
        my_filename = self.svg.name
    
        if len(my_filename) < 2:
            inkex.errormsg('Please Save Your File First')
            return
    
        my_actions = '--actions='
    
        # Define file paths based on whether overwriting is enabled
        if self.options.overwrite_existing_file == 'true':
            my_svg_export_filename_path = my_export_path + '/' + my_filename
            my_svg_plain_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_plain.svg')
            my_png_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '.png')
            my_pdf_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '.pdf')
            my_html5_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '.html')
        else:
            my_svg_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '.svg')
            my_svg_plain_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '_plain.svg')
            my_png_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '.png')
            my_pdf_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '.pdf')
            my_html5_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '.html')
    
        png_dpi = self.options.png_dpi
    
        # Check which export file formats have been selected by user
        # For each format, check if the file exists and add overwrite flag accordingly
        if self.options.export_svg_cb == 'true':
            overwrite_flag = 'export-overwrite;' if file_exists(my_svg_export_filename_path) else ''
            my_actions += f'{overwrite_flag}export-filename:{my_svg_export_filename_path};export-do;'
    
        if self.options.export_svg_plain_cb == 'true':
            overwrite_flag = 'export-overwrite;' if file_exists(my_svg_plain_export_filename_path) else ''
            my_actions += f'{overwrite_flag}export-filename:{my_svg_plain_export_filename_path};export-plain-svg;export-do;'
    
        if self.options.export_png_cb == 'true':
            overwrite_flag = 'export-overwrite;' if file_exists(my_png_export_filename_path) else ''
            my_actions += f'{overwrite_flag}export-filename:{my_png_export_filename_path};export-dpi:{png_dpi};export-do;'
    
        if self.options.export_pdf_cb == 'true':
            overwrite_flag = 'export-overwrite;' if file_exists(my_pdf_export_filename_path) else ''
            my_actions += f'{overwrite_flag}export-filename:{my_pdf_export_filename_path};export-do;'
    
        if self.options.export_html5_cb == 'true':
            overwrite_flag = 'export-overwrite;' if file_exists(my_html5_export_filename_path) else ''
            my_actions += f'{overwrite_flag}export-filename:{my_html5_export_filename_path};export-do;'
    
        if self.options.export_svg_ttp_cb == 'true':
            overwrite_flag = 'export-overwrite;' if file_exists(my_svg_export_filename_path) else ''
            my_actions += f'{overwrite_flag}export-text-to-path;export-filename:{my_svg_export_filename_path};export-plain-svg:no;export-do;'
    
        if self.options.export_svg_plain_ttp_cb == 'true':
            overwrite_flag = 'export-overwrite;' if file_exists(my_svg_plain_export_filename_path) else ''
            my_actions += f'{overwrite_flag}export-text-to-path;export-filename:{my_svg_plain_export_filename_path};export-plain-svg;export-do;'
    
        if my_actions == '--actions=':
            inkex.errormsg('Please Select At Least One Export Format')
            return
    
        if Path(my_export_path).is_dir():
            inkex.command.inkscape(my_file_path, my_actions)
        else:
            inkex.errormsg('Please Select An Export Folder')
    
    # Class definition for the Inkscape extension
    class QuickExport(inkex.EffectExtension):
        # Method to add arguments for the extension
        def add_arguments(self, pars):
            pars.add_argument("--notebook_main", type=str, dest="notebook_main", default=0)
            pars.add_argument("--export_svg_cb", type=str, dest="export_svg_cb", default='true')
            pars.add_argument("--export_svg_ttp_cb", type=str, dest="export_svg_ttp_cb", default='true')
            pars.add_argument("--export_svg_plain_cb", type=str, dest="export_svg_plain_cb", default='true')
            pars.add_argument("--export_svg_plain_ttp_cb", type=str, dest="export_svg_plain_ttp_cb", default='true')
            pars.add_argument("--export_png_cb", type=str, dest="export_png_cb", default='true')
            pars.add_argument("--png_dpi", type=int, dest="png_dpi", default=96)
            pars.add_argument("--export_pdf_cb", type=str, dest="export_pdf_cb", default='true')
            pars.add_argument("--export_html5_cb", type=str, dest="export_html5_cb", default='true')
            pars.add_argument("--save_path", type=str, dest="save_path", default=str(Path.home()))
            pars.add_argument("--overwrite_existing_file", type=str, dest="overwrite_existing_file", default='false')
    
        # Main effect method that gets called by Inkscape
        def effect(self):
            command_line_call(self)
    
    # Main execution
    if __name__ == '__main__':
        QuickExport().run()
    

    -S

  4. #4
    inklinea inklinea @inklinea⛰️

    I installed Nobara 38 Gnome on a virtual machine and allowed to update. 

    It comes with Inkscape 1.3

    The extension runs without errors for me.

  5. #5
    Simon Simon @SimonH

    Thanks for testing that... Fascinating.
    That's my luck to fix an addon that works fine for everyone but me.
    So something with my set-up is breaking but I have no clue what could possibly bring up the error...

    Is there anyone who can maybe interpret the error message?

    The other thing I'm considering is just force muting the error since it's working just complaining unnecessary...

    -S

  6. #6
    inklinea inklinea @inklinea⛰️

    I'm not sure what is causing the crash.

    As shown in the output error msg you can report it on the gitlab issues page.

    It does seem to be related to https://gitlab.com/inkscape/inbox/-/issues/8833

    If you see the post by Krir17 and the two links in that message. 

    However I am not sure how to solve it.

     

  7. #7
    Simon Simon @SimonH

    I hacked it into submission by literally suppressing warnings and instead they will generate via a log file in the home directory for debug reasons.
    Now it does what I want! Quickly exporting a universally compatible SVG without bugging me with warnings I don't care about! The button clicks have successfully been defeated between Inkscape and Krita! This means I can work with all kinds of crazy text effects and still quickly sync it through to Krita. Awesome.

    This is my first every extension modification; say if I can't get hold of the original extension author, should I release it as another extension?
    I would like to store it safety for others to make use of. I guess it should be fine since it's GPL?

    Here's the final PY file. the .INX stays the same.
     

    #!/usr/bin/env python
    # coding=utf-8
    #
    # Copyright (C) [2021] [Matt Cottam], [mpcottam@raincloud.co.uk]
    #
    # This program is free software; you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation; either version 2 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    #
    #
    # #############################################################################
    #  Quick Export - Quickly export Inkscape svg, plain svg, and png
    #  After setting the options in the main dialogue
    #  Assign a shortcut in Inkscape Edit>Preferences>Interface>Keyboard to org.inkscape.inklinea.quick_export.noprefs
    #  For shortcut triggered quick export
    #  It does require that you have saved
    #  Your svg file at least once before using (will not work on an unsaved svg)
    #  Requires Inkscape 1.1+
    # #############################################################################
    
    import inkex
    from inkex import command
    from pathlib import Path
    from datetime import datetime
    import sys
    import os
    
    def command_line_call(self):
    
        # Current date and time to time stamp
        timestamp = datetime.today().replace(microsecond=0)
        timestamp_suffix = str(timestamp.strftime('%Y-%m-%d-%H-%M-%S'))
    
        # Get output directory
        my_file_path = self.options.input_file
    
        # Collect export format options
        my_export_path = self.options.save_path
    
        # Get name of currently open Inkscape file
        my_filename = self.svg.name
    
        # Check to see if user has saved file at least once
        if len(my_filename) < 2:
            inkex.errormsg('Please Save Your File First')
            return
    
        # Build a formatted string for command line actions
        my_actions = '--actions='
    
        # Use the original filename without timestamp if overwrite is true
        if self.options.overwrite_existing_file == 'true':
            my_svg_export_filename_path = my_export_path + '/' + my_filename
            my_svg_plain_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_plain.svg')
            my_png_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '.png')
            my_pdf_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '.pdf')
            my_html5_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '.html')
        else:
            my_svg_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '.svg')
            my_svg_plain_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '_plain.svg')
            my_png_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '.png')
            my_pdf_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '.pdf')
            my_html5_export_filename_path = my_export_path + '/' + my_filename.replace('.svg', '_' + timestamp_suffix + '.html')
    
        # Get png dpi setting
        png_dpi = self.options.png_dpi
    
        # Check which export file formats have been selected by user
        if self.options.export_svg_cb == 'true':
            export_svg_actions = f'export-filename:{my_svg_export_filename_path};export-do;'
            my_actions = my_actions + export_svg_actions
    
        if self.options.export_svg_plain_cb == 'true':
            export_svg_plain_actions = f'export-filename:{my_svg_plain_export_filename_path};export-plain-svg;export-do;'
            my_actions = my_actions + export_svg_plain_actions
    
        if self.options.export_png_cb == 'true':
            export_png_actions = f'export-filename:{my_png_export_filename_path};export-dpi:{png_dpi};export-do;'
            my_actions = my_actions + export_png_actions
    
        if self.options.export_pdf_cb == 'true':
            export_pdf_actions = f'export-filename:{my_pdf_export_filename_path};export-do;'
            my_actions = my_actions + export_pdf_actions
    
        if self.options.export_html5_cb == 'true':
            export_html5_actions = f'export-filename:{my_html5_export_filename_path};export-do;'
            my_actions = my_actions + export_html5_actions
    
        # Any text to path export actions need to be at end of action list
        if self.options.export_svg_ttp_cb == 'true':
            export_svg_actions = f'export-text-to-path;export-filename:{my_svg_export_filename_path};export-do;'
            my_actions = my_actions + export_svg_actions
    
        if self.options.export_svg_plain_ttp_cb == 'true':
            export_svg_actions = f'export-text-to-path;export-filename:{my_svg_plain_export_filename_path};export-do;'
            my_actions = my_actions + export_svg_actions
    
        # Exit if no export file formats have been selected
        if my_actions == '--actions=':
            inkex.errormsg('Please Select At Least One Export Format')
            return
    
        # Redirect standard error to suppress warnings and errors
        original_stderr = sys.stderr
        sys.stderr = open('/dev/null', 'w')
    
        # Set the path for the log file to the user's home directory to avoid permission issues
        log_file_path = os.path.join(os.path.expanduser('~'), 'quick_export_error.log')
    
        try:
            # Check to make sure export directory exists
            if Path(my_export_path).is_dir():
                inkex.command.inkscape(my_file_path, my_actions)
            else:
                inkex.errormsg('Please Select An Export Folder')
        except Exception as e:
            # Log the exception to a file in the user's home directory
            with open(log_file_path, "a") as log_file:
                log_file.write(f"An error occurred: {e}\n")
        finally:
            # Restore original stderr
            sys.stderr.close()
            sys.stderr = original_stderr
    
    class QuickExport(inkex.EffectExtension):
    
        def add_arguments(self, pars):
    
            pars.add_argument("--notebook_main", type=str, dest="notebook_main", default=0)
    
            pars.add_argument("--export_svg_cb", type=str, dest="export_svg_cb", default='true')
            pars.add_argument("--export_svg_ttp_cb", type=str, dest="export_svg_ttp_cb", default='true')
    
            pars.add_argument("--export_svg_plain_cb", type=str, dest="export_svg_plain_cb", default='true')
            pars.add_argument("--export_svg_plain_ttp_cb", type=str, dest="export_svg_plain_ttp_cb", default='true')
    
            pars.add_argument("--export_png_cb", type=str, dest="export_png_cb", default='true')
            pars.add_argument("--png_dpi", type=int, dest="png_dpi", default=96)
    
            pars.add_argument("--export_pdf_cb", type=str, dest="export_pdf_cb", default='true')
            pars.add_argument("--export_html5_cb", type=str, dest="export_html5_cb", default='true')
    
            pars.add_argument("--save_path", type=str, dest="save_path", default=str(Path.home()))
    
            pars.add_argument("--overwrite_existing_file", type=str, dest="overwrite_existing_file", default='false')
    
        def effect(self):
            command_line_call(self)
    
    if __name__ == '__main__':
        QuickExport().run()
    



    I love opensorce! <3

    -S

  8. #8
    Simon Simon @SimonH
    *

    Hang on.. I must have done something wrong because the SVG does not load as a file layer into Krita now... but I can drag and drop it straight it... ahh man.. Weird.
    Not sure what I did differently.

    Looks like there's more to be done..

    EDIT: Ok got it; there's a problem when syncing files between my HD and SSD, but it goes away when the documents are all in the same drive. Probably a Krita issue.

    I guess it's done!

    -S

  9. #9
    inklinea inklinea @inklinea⛰️

    I wrote the extension in 2021 to solve a similar problem and as the author I am very happy for anyone to modify it. It's GPL3 for that reason.

    Probably best to release it as a separate extension and upload it to a free gitlab account. Or just folk it. 

    I am terrible at merging etc, I literally drag and drop a lot of my stuff file by file into gitlab for that reason. 

    One thing you will have to do though, is change this code in the .inx

    <name>Quick Export</name>

    <id>org.inkscape.inklinea.quick_export</id>

    The reason being is that if two extensions have the same id, they collide and will not run. Changing the name in the .inx is optional but less confusing.

    I was probably going to changethe extension at some point.

    The reason being the actions object-to-path has changed the  way it operates from Inkscape 1.2 --> 1.3 and no longer gives the expected grouped text.

    Anyway nice to see someone enjoying writing extensions.

  10. #10
    Simon Simon @SimonH

    Awesome thanks Inklinea, and tbh I think I had a dumb moment and overlooked that you were the original author haha.

    Sure I'll take a look at fixing these lines of code too :)

    Thanks for all your help Inklinea.

    Warm regards,

    Simon.

  11. #11
    Simon Simon @SimonH

    I was thinking a lot about the name recently and thought if it's going to be a different name i was keen to go with 'Ink Sync' because all I care about is syncing Inkscape to other applications. When ever I think exporting, I think of final destination/interchange (FBX, gltf, 8bitPNG etc); where as I want the name to communicate an iterative, constant process. It's probably going to continue to evolve in that direction; I may remove features and or add functionality to reduce clicks such as a trigger when the user changes focus of the window away from inkscape. I had considered quick export 2, quick export sync, and I think quick sync was my favourite runner up; because I'm thinking if our thoughts are aligned that it's good to have the option to export to update existing files, then it might be confusing to have vastly different names for very similar tools. Maybe none of it matters and I'm over thinking it!

    -s

Inkscape Inkscape.org Inkscape Forum Creating New Extensions What is throwing this error while overwriting?