LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-25-2010, 09:00 PM   #1
jabfinger
Member
 
Registered: Jan 2004
Location: USA, Pa
Distribution: Gentoo, Fedora Core 3, Mepis, Vector
Posts: 83

Rep: Reputation: 15
python 2.6.4 os.popen os.system


Hello,

I am trying to write a gui app with python2.6.4 and wx on win XP.
I am attempting to resize an image with Imagemagick from within the program using os.popen and os.system in a thread.

Code:
os.popen("mogrify -resize " + str(x) + "x" + str(y) + "!" + " images/static/" + my_ref + ".gif")
or

Code:
os.system("mogrify -resize " + str(x) + "x" + str(y) + "!" + " images/static/" + my_ref + ".gif")
they both work as far as resizing the image but when os.system is used a command shell opens during the mogrify and when os.popen is used the command shell does not show but the rest of the program freezes until mogrify is done.

I would prefer that the program did not freeze during this process and the command shell did not show.

I have tried using wx to scale the image but the scaled image looks crappy.

anyway is there a way to use os.system and not have the shell show?

thanks
 
Old 02-26-2010, 05:21 AM   #2
pgpython
Member
 
Registered: Dec 2005
Location: Sheffield, UK
Distribution: Gentoo
Posts: 142

Rep: Reputation: 32
First of all there is a python module for ImageMagick. I am curious as to why you are using it through the os instead of through python?

There is no way to get os.system to do what you want it doesn't have that power. It's useful for when you need to make simple os calls like creating or removing a directory. If you need something I suggest subprocess which has a very good popen command that can easily be used to do what you want.
 
Old 02-26-2010, 10:22 AM   #3
jabfinger
Member
 
Registered: Jan 2004
Location: USA, Pa
Distribution: Gentoo, Fedora Core 3, Mepis, Vector
Posts: 83

Original Poster
Rep: Reputation: 15
thanks pgpython,

In answer to your question about why. os.popen and Imigemagick are on the system now and pymagick is not. I guess I just do not want to install more stuff than I need or can get away with. I realy did not want to install Imagemagick either but resizing/scaling with wx was not cutting it
as far as image quality is concerned.

Both of the commands that I have listed work. I just thought perhapse there was a way that one or the other would do the work without holding up the program or displaying the shell. I am using os.popen in the same program to open notepad.exe as well, and though it holds up the rest of the program at this point I am glad because files wont be opened by the program during the editing with notepad.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
strange behavior of system() and popen() kornelix Programming 14 12-31-2009 05:57 AM
python, os.system() function. howto use python variables? jhwilliams Programming 5 07-28-2007 01:56 AM
python gtk program almost done, stuck at os.popen? Maybe? nomb Programming 1 03-22-2007 02:44 PM
Help needed with system() and popen! twirl Programming 4 09-14-2005 09:22 AM
C Popen gold5angel Programming 2 04-17-2004 07:07 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration