diff options
| author | Mike Pittman <thepittos@yahoo.com.au> | 2008-04-29 16:38:53 +0000 |
|---|---|---|
| committer | ozmikepittman <ozmikepittman@users.sourceforge.net> | 2008-04-29 16:38:53 +0000 |
| commit | 76567eb20b155573931ea49060ffa95793642f84 (patch) | |
| tree | b4959c3830ba7b39d64b9d34c112f971cd49507a | |
| parent | Improved numerical precision for the SVG path data parser (along with a small... (diff) | |
| download | inkscape-76567eb20b155573931ea49060ffa95793642f84.tar.gz inkscape-76567eb20b155573931ea49060ffa95793642f84.zip | |
Fixed problems with previous commit (trunk revision 18463) relating to uniconv.ext.py and cdr2svg.sh
(bzr r5548)
| -rwxr-xr-x | share/extensions/cdr2svg.sh | 0 | ||||
| -rw-r--r-- | share/extensions/uniconv-ext.py | 69 |
2 files changed, 69 insertions, 0 deletions
diff --git a/share/extensions/cdr2svg.sh b/share/extensions/cdr2svg.sh deleted file mode 100755 index e69de29bb..000000000 --- a/share/extensions/cdr2svg.sh +++ /dev/null diff --git a/share/extensions/uniconv-ext.py b/share/extensions/uniconv-ext.py new file mode 100644 index 000000000..d114b1a30 --- /dev/null +++ b/share/extensions/uniconv-ext.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python
+
+"""
+uniconv-ext.py
+Python script for running UniConvertor in Inkscape extensions
+
+Copyright (C) 2008 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
+
+"""
+
+import os
+import random
+import subprocess
+import sys
+import tempfile
+
+# We need a filename ending in ".svg" for UniConvertor.
+# This is a hack.
+chars = list("0123456789abcdefghijklmnopqrstuvwxyz")
+while True:
+ random.shuffle(chars)
+ svgfile = os.path.join(tempfile.gettempdir(), ''.join(chars) + '.svg')
+ if not os.path.exists(svgfile):
+ break
+
+# Run UniConvertor, and determine our return code.
+try:
+ p = subprocess.Popen('uniconv "%s" "%s"' % (sys.argv[1], svgfile),
+ shell=True, stderr=subprocess.PIPE)
+ err = p.stderr.read()
+ rc = p.wait()
+ if rc:
+ sys.stderr.write("UniConvertor failed: %s\n" % err)
+ rc = 1
+except Exception, inst:
+ sys.stderr.write("Spawn error: %s\n" % str(inst))
+ rc = 1
+
+# If successful, copy the SVG file to stdout.
+if rc == 0:
+ try:
+ f = open(svgfile, "rU")
+ for line in f:
+ sys.stdout.write(line)
+ f.close()
+ except IOError, inst:
+ sys.stderr.write("Error reading temporary SVG file: %s\n" % str(inst))
+ rc = 1
+
+# Clean up and return.
+try:
+ os.remove(svgfile)
+except Exception:
+ pass
+sys.exit(rc)
|
