Skip to content
Permalink
Browse files

Inkscape extension: Compatibility with Python3 for Inkscape 1.0-beta2

  • Loading branch information
mgmax committed Jan 3, 2020
1 parent bed3df7 commit 98e949b34eb15a4bd3b20d6872f0f66feb10e2e0
Showing with 10 additions and 9 deletions.
  1. +4 −4 tools/inkscape_extension/daemonize.py
  2. +6 −5 tools/inkscape_extension/visicut_export.py
@@ -54,8 +54,8 @@ def createDaemon():
# and inherits the parent's process group ID. This step is required
# to insure that the next call to os.setsid is successful.
pid = os.fork()
except OSError, e:
raise Exception, "%s [%d]" % (e.strerror, e.errno)
except OSError as e:
raise Exception("%s [%d]" % (e.strerror, e.errno))

if (pid == 0): # The first child.
# To become the session leader of this new session and the process group
@@ -102,8 +102,8 @@ def createDaemon():
# longer a session leader, preventing the daemon from ever acquiring
# a controlling terminal.
pid = os.fork() # Fork a second child.
except OSError, e:
raise Exception, "%s [%d]" % (e.strerror, e.errno)
except OSError as e:
raise Exception("%s [%d]" % (e.strerror, e.errno))

if (pid == 0): # The second child.
# Since the current working directory may be a mounted filesystem, we
@@ -88,7 +88,7 @@ def get_single_instance_port():
pass
# VISICUTBIN=arg[13:]
elif len(arg) >= 9 and arg[0:9] == "--import=":
IMPORT = "true" in str(arg[9:])
IMPORT = "true" in arg[9:]
else:
arguments += [arg]
else:
@@ -119,12 +119,12 @@ def is_exe(fpath):
"Please report this bug on https://github.com/t-oster/VisiCut/issues\n\n"
"For a quick fix: Set VISICUTDIR and INKSCAPEDIR in "
"{2}"
.format(str(program), str(pathlist), os.path.realpath(__file__)))
.format(repr(program), repr(pathlist), os.path.realpath(__file__)))


def inkscape_version():
"""determine if Inkscape is version 0 or 1"""
version = subprocess.check_output([INKSCAPEBIN, "--version"], stderr=DEVNULL)
version = subprocess.check_output([INKSCAPEBIN, "--version"], stderr=DEVNULL).decode('ASCII', 'ignore')
assert version.startswith("Inkscape ")
if version.startswith("Inkscape 0"):
return 0
@@ -232,13 +232,14 @@ def get_original_filename(filename):
# something is wrong with this line
break
# unescape XML string

docname = docname.replace('&lt;', '<')
docname = docname.replace('&gt;', '>')
docname = docname.replace('&quot;', '"')
docname = docname.replace('&amp;', '&')

# normalize accented characters (äöü -> aou)
docname = unicodedata.normalize('NFKD', docname).encode('ASCII', 'ignore')
docname = unicodedata.normalize('NFKD', docname).encode('ASCII', 'ignore').decode('ASCII')
break

if not docname:
@@ -285,7 +286,7 @@ def get_original_filename(filename):
s.send(dest_filename + "\n")
s.close()
sys.exit(0)
except SystemExit, e:
except SystemExit as e:
sys.exit(e)
except:
pass

0 comments on commit 98e949b

Please sign in to comment.
You can’t perform that action at this time.