Code

providing compatibility for uniconversor name variations
authoraurium <aurium@users.sourceforge.net>
Mon, 1 Dec 2008 22:35:10 +0000 (22:35 +0000)
committeraurium <aurium@users.sourceforge.net>
Mon, 1 Dec 2008 22:35:10 +0000 (22:35 +0000)
share/extensions/cdr_input.inx
share/extensions/uniconv-ext.py

index 7a25ffcf48f4d48df815e55538287db191087a5e..781789719018b5ad9705f02a8e9d82037bf56f4a 100644 (file)
@@ -2,7 +2,7 @@
 <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
     <_name>Corel DRAW Input</_name>
     <id>org.inkscape.input.cdr</id>
-    <dependency type="executable" location="path">uniconv</dependency>
+    <!-- the uniconv or uniconvertor dependency will be tested by uniconv-ext.py -->
     <dependency type="executable" location="extensions">uniconv-ext.py</dependency>
     <input>
         <extension>.cdr</extension>
index 4dba05eeab6765d88a47c9bbdcedd5c1a2ac1c58..9614983301cab8cf72681a52564978502df9a82a 100644 (file)
@@ -23,8 +23,28 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
 import sys
 from run_command import run
-
-run('uniconv "%s" "%%s"' % sys.argv[1].replace("%","%%"), "UniConvertor")
-
+from subprocess import Popen, PIPE
+
+#sys.stderr.write('aaaaaaa')
+
+try:
+    p = Popen('uniconv', shell=True, stdout=PIPE, stderr=PIPE).wait()
+    if p!=127 : cmd = 'uniconv'
+    p = Popen('uniconvertor', shell=True, stdout=PIPE, stderr=PIPE).wait()
+    if p!=127 : cmd = 'uniconvertor'
+except ImportError:
+    try:
+        from popen2 import Popen3
+        p = Popen3('uniconv', True).wait()
+        if p!=32512 : cmd = 'uniconv'
+        p = Popen3('uniconvertor', True).wait()
+        if p!=32512 : cmd = 'uniconvertor'
+    except ImportError:
+        sys.stderr.write('You need to install the UniConvertor software.\n'+\
+                         'For Linux: install the packge python-uniconvertor.\n'+\
+                         'For Windows: download it from\n'+\
+                         'http://sk1project.org/modules.php?name=Products&product=uniconvertor\n')
+
+run((cmd+' "%s" "%%s"') % sys.argv[1].replace("%","%%"), "UniConvertor")
 
 # vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99