summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e9eb8ad)
raw | patch | inline | side by side (parent: e9eb8ad)
author | Alvin Penner <penner@vaxxine.com> | |
Thu, 4 Feb 2010 00:32:27 +0000 (19:32 -0500) | ||
committer | Alvin Penner <penner@vaxxine.com> | |
Thu, 4 Feb 2010 00:32:27 +0000 (19:32 -0500) |
share/extensions/run_command.py | patch | blob | history |
index e1b51b3b020d3a1241123e6ca2a91ab97853e646..f688444d61ba6f8e18b5f5381f99a98ef80c4216 100644 (file)
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-# Run a command that generates an SVG file from an input file.
-# On success, outputs the contents of the SVG file to stdout, and exits
+# Run a command that generates an SVG (or PDF) file from an input file.
+# On success, outputs the contents of the resulting file to stdout, and exits
# with a return code of 0.
# On failure, outputs an error message to stderr, and exits with a return
# code of 1.
svgfile = tempfile.mktemp(".svg")
command = command_format % svgfile
msg = None
+ # ps2pdf may attempt to write to the current directory, which may not
+ # be writeable, so we switch to the temp directory first.
+ try:
+ os.chdir(tempfile.gettempdir())
+ except Exception:
+ pass
# In order to get a return code from the process, we use subprocess.Popen
# if it's available (Python 2.4 onwards) and otherwise use popen2.Popen3
# (Unix only). As the Inkscape package for Windows includes Python 2.5,
except Exception, inst:
msg = "Error attempting to run %s: %s" % (prog_name, str(inst))
- # If successful, copy the SVG file to stdout.
+ # If successful, copy the output file to stdout.
if msg is None:
if os.name == 'nt': # make stdout work in binary on Windows
import msvcrt
sys.stdout.write(data)
f.close()
except IOError, inst:
- msg = "Error reading temporary SVG file: %s" % str(inst)
+ msg = "Error reading temporary file: %s" % str(inst)
# Clean up.
try: