Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inkscape CLI with Ubuntu 12.04 LTS #24

Closed
createthis opened this issue Dec 22, 2012 · 2 comments
Closed

Inkscape CLI with Ubuntu 12.04 LTS #24

createthis opened this issue Dec 22, 2012 · 2 comments
Assignees

Comments

@createthis
Copy link

Hey, I noticed that inkscape was opening the GUI and not doing PDF conversions, so I did some digging. I'm running Inkscape 0.48.3.1 r9886 (Mar 29 2012) and Python 2.7.3.

Apparently adding the -z option tells inkscape to not open a GUI, so I added that. But the big thing I noticed was that Python was ignoring the CLI arguments altogether. I tested this by running the CLI string:

inkscape -f mendel/sheets/frame_base.svg -A mendel/sheets/frame_base.pdf -z

.. manually on the command line. That would work fine, but when Python executed the same thing, the GUI would open and nothing would happen.

This behavior was caused by the shell = True argument to Popen. The documentation states:

The shell argument (which defaults to False) specifies whether to use the shell as the program to execute. If shell is True, it is recommended to pass args as a string rather than as a sequence.

Changing it to shell = False made inkscape work as expected.

Here is my diff:

diff --git a/InkCL.py b/InkCL.py
index 4db94da..a1042dd 100644
--- a/InkCL.py
+++ b/InkCL.py
@@ -8,7 +8,7 @@ def run(*args):
     for arg in args:
         print arg,
     print
-    run = subprocess.Popen(["inkscape"] + list(args), shell = True, stdout = subprocess.PIPE, stderr = subprocess.
+    run = subprocess.Popen(["inkscape"] + list(args) + list(' -z'), shell = False, stdout = subprocess.PIPE, stder
     out,err=[e.splitlines() for e in run.communicate()]
     return run.returncode, out, err
'''

Hopefully that's useful to someone.
@ghost ghost assigned nophead Dec 24, 2012
@fschulze
Copy link

fschulze commented Jan 7, 2013

It should be + ['-z'], the current + list(' -z') actually appends [' ', '-', 'z'] to the argument list.

@nophead
Copy link
Owner

nophead commented Jan 7, 2013

That is what it is currently. I didn't take the patch literally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants