index 1197f97bbbc250e24c5bdd427923f94d42b85367..6869196a54da2b5af7ec7fc2523690964b296fc4 100644 (file)
import sys
from run_command import run
-run('uniconv "%s" "%%s"' % sys.argv[1], "UniConvertor")
-
+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 "import uniconvertor"'
+
+run((cmd+' "%s" "%%s"') % sys.argv[1].replace("%","%%"), "UniConvertor")
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99