By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,957 Members | 1,960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,957 IT Pros & Developers. It's quick & easy.

Launch file from Python

P: n/a
Good afternoon from someone who is trying to learn Python.

I would like to launch an app from within a Python script. From the
examples I have found, I should be able to do this with os.system.

I use this:
os.system("xplanet-1.2.0/xplanet.exe -fontsize 24 -label -target earth
-lat 33.65 -lon -84.42 -radius 40 -num_times 1 -tmpdir .")
This is copied directly from the .bat file that launches the xplanet
app. It works there.

and get this:
1

Can someone fill me in? Thanks.

Aug 8 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
On Aug 8, 12:28 pm, joc...@gmail.com wrote:
Good afternoon from someone who is trying to learn Python.

I would like to launch an app from within a Python script. From the
examples I have found, I should be able to do this with os.system.

I use this:
os.system("xplanet-1.2.0/xplanet.exe -fontsize 24 -label -target earth
-lat 33.65 -lon -84.42 -radius 40 -num_times 1 -tmpdir .")
This is copied directly from the .bat file that launches the xplanet
app. It works there.

and get this:
1

Can someone fill me in? Thanks.
That's just the exit status or run status, if I recall correctly. I
think 0 (i.e. False) means it didn't run properly and anything else is
True, or ok. Something like that. Technically speaking, you should
probably switch to using the subprocess module as it is replacing that
os module's functionality: http://www.python.org/doc/2.4/lib/mo...ubprocess.html

This thread also discusses it somewhat:
http://www.velocityreviews.com/forum...-ossystem.html

Mike

Aug 8 '07 #2

P: n/a
On Aug 8, 1:36 pm, kyoso...@gmail.com wrote:
On Aug 8, 12:28 pm, joc...@gmail.com wrote:
Good afternoon from someone who is trying to learn Python.
I would like to launch an app from within a Python script. From the
examples I have found, I should be able to do this with os.system.
I use this:
os.system("xplanet-1.2.0/xplanet.exe -fontsize 24 -label -target earth
-lat 33.65 -lon -84.42 -radius 40 -num_times 1 -tmpdir .")
This is copied directly from the .bat file that launches the xplanet
app. It works there.
and get this:
1
Can someone fill me in? Thanks.

That's just the exit status or run status, if I recall correctly. I
think 0 (i.e. False) means it didn't run properly and anything else is
True, or ok. Something like that. Technically speaking, you should
probably switch to using the subprocess module as it is replacing that
os module's functionality:http://www.python.org/doc/2.4/lib/mo...ubprocess.html

This thread also discusses it somewhat:http://www.velocityreviews.com/forum...c-problem-exam...

Mike
The application, however, never runs. I'll give the sub-process a
shot. Thanks.

Aug 8 '07 #3

P: n/a
On Aug 8, 1:11 pm, jocago <joc...@gmail.comwrote:
The application, however, never runs. I'll give the sub-process a
shot. Thanks.
Well, that's a problem. I suppose the best thing to try is use some
smaller sets of flags and see if they work. Instead of your long
string, try something smaller, like:

subprocess.Popen("xplanet-1.2.0/xplanet.exe -fontsize 24 -label -
target earth", shell=True)

Once you've gotten it to work on a smaller scale, you should be able
to work your way up.

Mike

Aug 8 '07 #4

P: n/a
ky******@gmail.com escribió:
That's just the exit status or run status, if I recall correctly. I
think 0 (i.e. False) means it didn't run properly and anything else is
True, or ok. Something like that.
The other way: 0 means "ok" while everything else means error (at least in
UNIX). The reason is clear: there is usually only one way to do things well, but
many to fail :-)
Technically speaking, you should
probably switch to using the subprocess module as it is replacing that
os module's functionality: http://www.python.org/doc/2.4/lib/mo...ubprocess.html
Correct, subprocess replaces low-level os.system, os.popen*, os.spawn*, popen*
functions.
Aug 8 '07 #5

P: n/a
On Aug 8, 2:35 pm, Arnau Sanchez <ar...@ehas.orgwrote:
kyoso...@gmail.com escribió:
That's just the exit status or run status, if I recall correctly. I
think 0 (i.e. False) means it didn't run properly and anything else is
True, or ok. Something like that.

The other way: 0 means "ok" while everything else means error (at least in
UNIX). The reason is clear: there is usually only one way to do things well, but
many to fail :-)
Technically speaking, you should
probably switch to using the subprocess module as it is replacing that
os module's functionality:http://www.python.org/doc/2.4/lib/mo...ubprocess.html

Correct, subprocess replaces low-level os.system, os.popen*, os.spawn*, popen*
functions.
Figures...I couldn't find the docs on it though...and I do know that
some Windows programs return goofy numbers in the 1000s that mean it
worked fine. So, in other words, the return value isn't very helpful.

Mike

Aug 8 '07 #6

P: n/a
On Aug 8, 2:39 pm, kyoso...@gmail.com wrote:
On Aug 8, 2:35 pm, Arnau Sanchez <ar...@ehas.orgwrote:


kyoso...@gmail.com escribió:
That's just the exit status or run status, if I recall correctly. I
think 0 (i.e. False) means it didn't run properly and anything else is
True, or ok. Something like that.
The other way: 0 means "ok" while everything else means error (at leastin
UNIX). The reason is clear: there is usually only one way to do things well, but
many to fail :-)
Technically speaking, you should
probably switch to using the subprocess module as it is replacing that
os module's functionality:http://www.python.org/doc/2.4/lib/mo...ubprocess.html
Correct, subprocess replaces low-level os.system, os.popen*, os.spawn*,popen*
functions.

Figures...I couldn't find the docs on it though...and I do know that
some Windows programs return goofy numbers in the 1000s that mean it
worked fine. So, in other words, the return value isn't very helpful.

Mike- Hide quoted text -

- Show quoted text -

I had used popen on windows and had to seperate the arguments out..
(example is in my awk module in dex tracker on sourceforge).. What
you did may not work on windows.

Aug 9 '07 #7

P: n/a
On Wed, 08 Aug 2007 10:28:57 -0700, jo****@gmail.com <jo****@gmail.comwrote:
Good afternoon from someone who is trying to learn Python.

I would like to launch an app from within a Python script. From the
examples I have found, I should be able to do this with os.system.

I use this:
os.system("xplanet-1.2.0/xplanet.exe -fontsize 24 -label -target earth
-lat 33.65 -lon -84.42 -radius 40 -num_times 1 -tmpdir .")
This is copied directly from the .bat file that launches the xplanet
app. It works there.

and get this:
1
That means "error", as others noted.

It is odd that you get no printouts. Had this been on Unix, you'd
either get "file not found" or similar from the shell trying to run
the thing, or something from xplanet itself (only really badly
programs return failure without printing some kind of cause).

Two more comments, assuming you are on Windows (you mention ".bat
files"):

- You use the relative path xplanet-1.2.0/xplanet.exe. That should
require your program to have the parent of xplanet-1.2.0 as current
directory. Did the .bat script change directory first?

- It is unusual to use / as a path separator on Windows --
xplanet-1.2.0\xplanet.exe is more normal. Some parts of Windows
tolerate both, others do not, IIRC. But Python itself should not
care in this case.

/Jorgen

--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.dyndns.org R'lyeh wgah'nagl fhtagn!
Aug 12 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.