0

Hello everyone,

I'm trying to basically get a cmd variable to pass into commands.getstatusoutput. The problem is that the command has a lot of single and double quotes in it and I can't seem to get it to store as a variable. When I print the cmd it comes out as I want it to (since I tried \ escaping one of the single quotes.. here is an example of what I'm trying to do:

 cmd1 = "convert -pointsize %i -fill %s -draw " % (pointsize, fill)
 cmd2 = '\'text %d,%d "%s Hour: %i"\' %s %s_cap.jpg' % (half_image, up_buff, out_month, hour, jpg, jpg) 
 cmd = cmd1+cmd2

if I print this it gives me:

convert -pointsize 72 -fill yellow -draw 'text 900,180 "September 21 Hour: 0"' example.jpg example.jpg_cap.jpg

But just simply typing cmd into the prompt or passing the cmd I'm still getting those \ in there. So I need a way of avoiding using them. I'm sure this is pretty common place, but I'm drawing a blank. cmd2 will give me an error if I try to type it in without the escape () character. Thanks in advance!

3
Contributors
5
Replies
50
Views
3 Years
Discussion Span
Last Post by fatalaccidents
0

have you tryed to use the command ib command prompt? I remember that sometimes you must add one more level of double quotes arround the double quotes, which gets removed. Can you not use only double quoting inside the command, I do not think CMD supports single quotes. I am not 100% sure, though.

Can you give exact error message you are getting?

0

I've never used commands.getstatusoutput. But wouldn't triple quotes around the variable allow you to not escape the quotes inside it?

0

The command I'm actually wanting to give is

cmd = "convert -pointsize %i -fill %s -draw 'text %d, %d "%s Hour: %i"' %s %s_cap.jpg" % (half_image, up_buff, out_month, jpg,  jpg)

but doing this gives me an Invalid Syntax error and is pointing at the r in Hour. Putting triple quotes around it is adding an escape character before the double quote after i. So does anyone know how I can get the above line to actually read correctly? Thanks for your help so far!

0

half_image and up_buff are floats, out_month and jpg are both strings.

I'm basically trying to put text on a batch of pictures and to center it I'm grabbing the image size and cutting it in half and the up_buff is just moving it up from the bottom a bit. The out_month is just a string like 'September' in this case, and jpg is the name of the file. I don't think (and I obviously don't know) but I think the problem is in the way I'm using the double quotes and single quotes. I can't figure it out.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.