summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b7d5adc)
raw | patch | inline | side by side (parent: b7d5adc)
author | JazzyNico <JazzyNico@users.sourceforge.net> | |
Mon, 3 Aug 2009 20:05:31 +0000 (20:05 +0000) | ||
committer | JazzyNico <JazzyNico@users.sourceforge.net> | |
Mon, 3 Aug 2009 20:05:31 +0000 (20:05 +0000) |
Also fixes Bug #387946 (UniConvertor called with wrong filename)
share/extensions/Makefile.am | patch | blob | history | |
share/extensions/plt_output.inx | patch | blob | history | |
share/extensions/plt_output.py | [new file with mode: 0644] | patch | blob |
share/extensions/sk1_output.inx | patch | blob | history | |
share/extensions/sk1_output.py | [new file with mode: 0644] | patch | blob |
share/extensions/uniconv_output.py | [new file with mode: 0644] | patch | blob |
share/extensions/wmf_output.inx | patch | blob | history | |
share/extensions/wmf_output.py | [new file with mode: 0644] | patch | blob |
index bed1319eccb9e2f628fac5a14a9a111b0bb95d4c..500da938c7304db2d25cbc1d2702fcf90be92e9a 100644 (file)
pathmodifier.py\
perfectboundcover.py \
perspective.py \
+ plt_output.py \
polyhedron_3d.py \
printing-marks.py \
ps2dxf.sh \
simplepath.rb \
simplestyle.py \
simpletransform.py \
+ sk1_output.py \
sk2svg.sh \
SpSVG.pm \
spirograph.py\
triangle.py \
txt2svg.pl \
uniconv-ext.py \
+ uniconv_output.py \
web-set-att.py \
web-transmit-att.py \
- whirl.py
+ whirl.py \
+ wmf_output.py
otherstuff = \
aisvg.xslt \
index c4b3926fed943d4ac03e1d738ecf1482ca59f1a3..f7000cd792ea942770761862acccfe2c6a44d6df 100644 (file)
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>AutoCAD Plot Output</_name>
<id>org.inkscape.output.plt</id>
- <dependency type="executable" location="extensions">uniconv-ext.py</dependency>
+ <dependency type="executable" location="extensions">plt_output.py</dependency>
<output>
<extension>.plt</extension>
<mimetype>image/x-plt</mimetype>
<_filetypetooltip>Save a file for plotters</_filetypetooltip>
</output>
<script>
- <command reldir="extensions" interpreter="python">uniconv-ext.py</command>
+ <command reldir="extensions" interpreter="python">plt_output.py</command>
</script>
</inkscape-extension>
diff --git a/share/extensions/plt_output.py b/share/extensions/plt_output.py
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+"""
+plt_output.py
+Module for running UniConverter sk1 exporting commands in Inkscape extensions
+
+Copyright (C) 2009 Nicolas Dufour (jazzynico)
+
+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
+"""
+
+import sys
+from uniconv_output import run, get_command
+
+cmd = get_command()
+run((cmd + ' "%s" ') % sys.argv[1], "UniConvertor", ".plt")
+
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99
\ No newline at end of file
index cd11473a107906e70f5f269ef53ce39841e82293..33494299c6290d280fd60e6720d937032b53cb76 100644 (file)
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>sK1 vector graphics files output</_name>
<id>org.inkscape.output.sk1</id>
- <dependency type="executable" location="extensions">uniconv-ext.py</dependency>
+ <dependency type="executable" location="extensions">sk1_output.py</dependency>
<output>
<extension>.sk1</extension>
<mimetype>application/x-xsk1</mimetype>
<_filetypetooltip>File format for use in sK1 vector graphics editor</_filetypetooltip>
</output>
<script>
- <command reldir="extensions" interpreter="python">uniconv-ext.py</command>
+ <command reldir="extensions" interpreter="python">sk1_output.py</command>
</script>
</inkscape-extension>
diff --git a/share/extensions/sk1_output.py b/share/extensions/sk1_output.py
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+"""
+sk1_output.py
+Module for running UniConverter sk1 exporting commands in Inkscape extensions
+
+Copyright (C) 2009 Nicolas Dufour (jazzynico)
+
+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
+"""
+
+import sys
+from uniconv_output import run, get_command
+
+cmd = get_command()
+run((cmd + ' "%s" ') % sys.argv[1], "UniConvertor", ".sk1")
+
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99
\ No newline at end of file
diff --git a/share/extensions/uniconv_output.py b/share/extensions/uniconv_output.py
--- /dev/null
@@ -0,0 +1,127 @@
+#!/usr/bin/env python
+
+"""
+uniconv_output.py
+Module for running UniConverter exporting commands in Inkscape extensions
+
+Copyright (C) 2009 Nicolas Dufour (jazzynico)
+Based on unicon-ext.py and run_command.py by Stephen Silver
+
+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
+"""
+
+# Run a command that generates an UniConvertor export file from a SVG file.
+# On success, outputs the contents of the UniConverter convertion to stdout,
+# and exits with a return code of 0.
+# On failure, outputs an error message to stderr, and exits with a return
+# code of 1.
+
+import os
+import sys
+import tempfile
+
+def run(command_format, prog_name, uniconv_format):
+ outfile = tempfile.mktemp(uniconv_format)
+ command = command_format + outfile
+ msg = None
+ # In order to get a return code from the process, we use subprocess.Popen
+ # if it's available (Python 2.4 onwards) and otherwise use popen2.Popen3
+ # (Unix only). As the Inkscape package for Windows includes Python 2.5,
+ # this should cover all supported platforms.
+ try:
+ try:
+ from subprocess import Popen, PIPE
+ p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
+ rc = p.wait()
+ out = p.stdout.read()
+ err = p.stderr.read()
+ except ImportError:
+ try:
+ from popen2 import Popen3
+ p = Popen3(command, True)
+ p.wait()
+ rc = p.poll()
+ out = p.fromchild.read()
+ err = p.childerr.read()
+ except ImportError:
+ # shouldn't happen...
+ msg = "Neither subprocess.Popen nor popen2.Popen3 is available"
+ if rc and msg is None:
+ msg = "%s failed:\n%s\n%s\n" % (prog_name, out, err)
+ except Exception, inst:
+ msg = "Error attempting to run %s: %s" % (prog_name, str(inst))
+
+ # If successful, copy the output file to stdout.
+ if msg is None:
+ if os.name == 'nt': # make stdout work in binary on Windows
+ import msvcrt
+ msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
+ try:
+ f = open(outfile, "rb")
+ data = f.read()
+ sys.stdout.write(data)
+ f.close()
+ except IOError, inst:
+ msg = "Error reading temporary file: %s" % str(inst)
+
+ # Clean up.
+ try:
+ os.remove(outfile)
+ except Exception:
+ pass
+
+ # Ouput error message (if any) and exit.
+ if msg is not None:
+ sys.stderr.write(msg + "\n")
+ sys.exit(1)
+ else:
+ sys.exit(0)
+
+def get_command():
+ cmd = None
+
+ try:
+ from subprocess import Popen, PIPE
+ p = Popen('uniconv', shell=True, stdout=PIPE, stderr=PIPE).wait()
+ if p==0 :
+ cmd = 'uniconv'
+ else:
+ p = Popen('uniconvertor', shell=True, stdout=PIPE, stderr=PIPE).wait()
+ if p==0 :
+ cmd = 'uniconvertor'
+ except ImportError:
+ from popen2 import Popen3
+ p = Popen3('uniconv', True).wait()
+ if p!=32512 : cmd = 'uniconv'
+ p = Popen3('uniconvertor', True).wait()
+ if p!=32512 : cmd = 'uniconvertor'
+
+ if cmd == None:
+ # there's no succeffully-returning uniconv command; try to get the module directly (on Windows)
+ try:
+ # cannot simply import uniconvertor, it aborts if you import it without parameters
+ import imp
+ imp.find_module("uniconvertor")
+ except ImportError:
+ sys.stderr.write(_('You need to install the UniConvertor software.\n'+\
+ 'For GNU/Linux: install the package python-uniconvertor.\n'+\
+ 'For Windows: download it from\n'+\
+ 'http://sk1project.org/modules.php?name=Products&product=uniconvertor\n'+\
+ 'and install into your Inkscape\'s Python location\n'))
+ sys.exit(1)
+ cmd = 'python -c "from uniconvertor import uniconv; uniconv();"'
+ return cmd
+
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99
index 01816e28f4f741265e0a66989b1c48689b24d036..e00721f0a5e60b0cd0a47b0e3721359f07e8ac64 100644 (file)
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>Windows Metafile Input</_name>
<id>org.inkscape.output.wmf</id>
- <dependency type="executable" location="extensions">uniconv-ext.py</dependency>
+ <dependency type="executable" location="extensions">wmf_output.py</dependency>
<output>
<extension>.wmf</extension>
<mimetype>application/x-wmf</mimetype>
<_filetypetooltip>A popular graphics file format for clipart</_filetypetooltip>
</output>
<script>
- <command reldir="extensions" interpreter="python">uniconv-ext.py</command>
+ <command reldir="extensions" interpreter="python">wmf_output.py</command>
</script>
</inkscape-extension>
diff --git a/share/extensions/wmf_output.py b/share/extensions/wmf_output.py
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+"""
+wmf_output.py
+Module for running UniConverter wmf exporting commands in Inkscape extensions
+
+Copyright (C) 2009 Nicolas Dufour (jazzynico)
+
+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
+"""
+
+import sys
+from uniconv_output import run, get_command
+
+cmd = get_command()
+run((cmd + ' "%s" ') % sys.argv[1], "UniConvertor", ".wmf")
+
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99
\ No newline at end of file