[SciPy-user] subprocess

Nils Wagner nwagner@iam.uni-stuttgart...
Tue Jun 23 13:42:41 CDT 2009


On Tue, 23 Jun 2009 12:43:38 -0500
  Gökhan SEVER <gokhansever@gmail.com> wrote:
> On Tue, Jun 23, 2009 at 12:29 PM, Nils Wagner
> <nwagner@iam.uni-stuttgart.de>wrote:
> 
>> On Tue, 23 Jun 2009 11:20:45 -0600
>>
>>  Jim Vickroy <Jim.Vickroy@noaa.gov> wrote:
>>
>>> Nils Wagner wrote:
>>>
>>>> On Tue, 23 Jun 2009 10:52:13 -0600
>>>>  Jim Vickroy <Jim.Vickroy@noaa.gov> wrote:
>>>>
>>>>
>>>>> Nils Wagner wrote:
>>>>>
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> Sorry if the subject is off-topic.
>>>>>>
>>>>>> How can I run gimp from python using subprocess ?
>>>>>>
>>>>>> I would like to use several arguments, e.g.
>>>>>>
>>>>>> gimp --batch-interpreter=plug-in-script-fu-eval -i -d -b
>>>>>> '(script-autocrop "a.png")' -b '(gimp-quit 0)'
>>>>>>
>>>>>>
>>>>>> Thanks in advance.
>>>>>>
>>>>>>               Nils
>>>>>> _______________________________________________
>>>>>> SciPy-user mailing list
>>>>>> SciPy-user@scipy.org
>>>>>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>>>>>
>>>>>>
>>>>> ... don't know what Python version you are using but 
>>>>>recent releases
>>>>> (version 2.4 and later) include the *subprocess* module.
>>>>>
>>>>> Questions of this sort are best posted to 
>>>>>*comp.lang.python*.
>>>>>
>>>>>
>>>>  Thank you for your response.
>>>> I know how to import subprocess, but how do I deal with 
>>>>all the quotes in
>>>> the argument list
>>>> of my gimp command ?
>>>>
>>>> Nils
>>>> _______________________________________________
>>>> SciPy-user mailing list
>>>> SciPy-user@scipy.org
>>>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>>>
>>>>
>>> It is usually a good idea to (at a minimum) post:
>>>
>>>   *  a small script that demonstrates the error
>>>   * the exact text of the error the script triggers
>>>   * the version of Python you are using
>>>   * the OS you are using
>>>
>>
>> Sure, I am using openSuSe 11.1 on x86_64 GNU/Linux, 
>>python2.6.
>> gimp --version
>> GNU Image Manipulation Program Version 2.6.2
>>
>> The script script-autocrop.scm should be placed in in 
>>~/.gimp2.6/scripts
>>
>> python -i autocrop.py
>>
>> (gimp:8196): Gimp-Core-CRITICAL **: gimp_image_opened: 
>>assertion
>> `GIMP_IS_GIMP (gimp)' failed
>> GIMP-Fehler: »/home/nwagner/)'« konnte nicht geöffnet 
>>werden: Datei oder
>> Verzeichnis nicht gefunden
>>
>> batch command executed successfully
>> batch command executed successfully
>>
>> ^CTraceback (most recent call last):
>>  File "autocrop.py", line 6, in <module>
>>    assert subprocess.call(cmd)==0, 'Error in cmd: %s' % 
>>cmd # Returncode
>> should be zero
>> gimp: terminated: Unterbrechung
>>  File "/usr/lib64/python2.6/subprocess.py", line 444, in 
>>call
>>    return Popen(*popenargs, **kwargs).wait()
>>  File "/usr/lib64/python2.6/subprocess.py", line 1137, 
>>in wait
>>    pid, sts = os.waitpid(self.pid, 0)
>> KeyboardInterrupt
>> /usr/lib64/gimp/2.0/plug-ins/script-fu terminated: 
>>Unterbrechung
>>
>>
>> Datei oder Verzeichnis nicht gefunden means file or 
>>directory missing
>>
>> Nils
>>
>> _______________________________________________
>> SciPy-user mailing list
>> SciPy-user@scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
>>
> 
> Tried the scripts same error here too...
> 
> Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
> Linux ccn 2.6.27.19-170.2.35.fc10.i686.PAE (Fedora 10)
> 
> 
> [gsever@ccn ~]$ python -i autocrop.py
> 
> (gimp:10078): Gimp-Core-CRITICAL **: gimp_image_opened: 
>assertion
> `GIMP_IS_GIMP (gimp)' failed
> GIMP-Error: Opening '/home/gsever/)'' failed: No such 
>file or directory
> 
> batch command executed successfully
> batch command executed successfully
> 
> ^Cgimp: terminated: Interrupt
> Traceback (most recent call last):
>  File "autocrop.py", line 6, in <module>
>    assert subprocess.call(cmd)==0, 'Error in cmd: %s' % 
>cmd # Returncode
> should be zero
>  File "/usr/lib/python2.5/subprocess.py", line 444, in 
>call
>    return Popen(*popenargs, **kwargs).wait()
>  File "/usr/lib/python2.5/subprocess.py", line 1122, in 
>wait
>    pid, sts = os.waitpid(self.pid, 0)
> KeyboardInterrupt
> /usr/lib/gimp/2.0/plug-ins/script-fu terminated: 
>Interrupt
> 
> (script-fu:10081): LibGimp-WARNING **: script-fu: 
>gimp_flush(): error:
> Broken pipe

What is the output of

gimp --batch-interpreter=plug-in-script-fu-eval -i -d -b 
'(script-autocrop "a.png")' -b '(gimp-quit 0)'

I assume you have an png file called a.png in the current 
directory.

Nils
  


More information about the SciPy-user mailing list