summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9d1283e)
raw | patch | inline | side by side (parent: 9d1283e)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Sun, 1 Mar 2009 17:06:19 +0000 (17:06 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Sun, 1 Mar 2009 17:06:19 +0000 (17:06 +0000) |
share/extensions/uniconv-ext.py | patch | blob | history |
index 32537a5f2f94de6de736de259926844a0b49bd4b..6869196a54da2b5af7ec7fc2523690964b296fc4 100644 (file)
import sys
from run_command import run
-from subprocess import Popen, PIPE
-cmd = 'none'
+cmd = None
try:
+ from subprocess import Popen, PIPE
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'
+ 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()
p = Popen3('uniconvertor', True).wait()
if p!=32512 : cmd = 'uniconvertor'
-if cmd == 'none' :
- sys.stderr.write('You need to install the UniConvertor software.\n'+\
+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')
-else :
- run((cmd+' "%s" "%%s"') % sys.argv[1].replace("%","%%"), "UniConvertor")
+ '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