[wxPython] wxExecute?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] wxExecute?

Guy N. Hurst
Hi,

I have started out with a basic framework having Exit and About.
Next, I need to be able to run an external program from within the one I
am making.
(to download data from barcode scanner).

But I noticed in the documentation I have, that wxExecute is not listed
with the supported function classes for wxPython... :-(

Maybe it has since been added ?

I am not sure what to do next, so I turn to this mailing list.

Anyone have some pointers for me?

Thanks.

Guy N. Hurst
wxPython 2.1.11, Win95


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

RE: [wxPython] wxExecute?

Winkelman, Jeff-2
Guy,

Depending on what exactly you are trying to do with the external program you
want to launch, there are a few things you can use:

1)  Look into the os module that comes with Python.  This module has several
methods for process management.  The most popular being os.popen().
However, there is the following problem taken from the Python FAQ:

7.13. Why doesn't os.popen() work in PythonWin on NT?
The reason that os.popen() doesn't work from within PythonWin is due to a
bug in Microsoft's C Runtime Library (CRT). The CRT assumes you have a Win32
console attached to the process.
You should use the win32pipe module's popen() instead which doesn't depend
on having an attached Win32 console.
Example:
 import win32pipe
 f = win32pipe.popen('dir /c c:\\')
 print f.readlines()
 f.close()

2)  Since you are on a Windows platform, the win32 extensions that have been
created support several was to launch other programs or create additional
processes.  One of these is demonstrated above.

Another example is the following I did to run the netstat command at the
command line from a python program:

        import win32pipe, time, string

        f = win32pipe.popen('netstat -e')
        time.sleep(1)
        line = f.readline()
        if string.find(line, 'Bytes') != -1:
            f.close()
                return

Hope this gets you started.  Information regarding the above can be found on
python.org, python's documentation, and the win32 extensions
documentation....


> -----Original Message-----
> From: Guy N. Hurst [SMTP:[hidden email]]
> Sent: Tuesday, November 30, 1999 3:12 AM
> To: wxPython Post
> Subject: [wxPython] wxExecute?
>
> Hi,
>
> I have started out with a basic framework having Exit and About.
> Next, I need to be able to run an external program from within the one I
> am making.
> (to download data from barcode scanner).
>
> But I noticed in the documentation I have, that wxExecute is not listed
> with the supported function classes for wxPython... :-(
>
> Maybe it has since been added ?
>
> I am not sure what to do next, so I turn to this mailing list.
>
> Anyone have some pointers for me?
>
> Thanks.
>
> Guy N. Hurst
> wxPython 2.1.11, Win95
>
>
> _______________________________________________
> wxPython-users maillist  -  [hidden email]
> http://starship.python.net/mailman/listinfo/wxpython-users


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] wxExecute?

Ionel Simionescu
In reply to this post by Guy N. Hurst

----- Original Message -----
From: Guy N. Hurst <[hidden email]>

| I have started out with a basic framework having Exit and About.
| Next, I need to be able to run an external program from within the one I
| am making.
| (to download data from barcode scanner).
|
| But I noticed in the documentation I have, that wxExecute is not listed
| with the supported function classes for wxPython... :-(
|
| Maybe it has since been added ?
|
| I am not sure what to do next, so I turn to this mailing list.
|
| Anyone have some pointers for me?

You may consider to look at:
Python Library, module os, the exec* family of functions.

(I guess that one does not really need wxExecute in wxPython when he can do
the same from Python.)

ionel


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] wxExecute?

Robin Dunn
In reply to this post by Guy N. Hurst
> But I noticed in the documentation I have, that wxExecute is not listed
> with the supported function classes for wxPython... :-(
>

Python provides several good ways to execute other programs.  Look in the
Python docs at the os module.

On the other hand, wxExecute is supported by wxPython.  It's not listed in
the list of supported classes because it is not a class.  I guess there needs
to be another page that lists the supported functions too.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] wxExecute?

Markus Gritsch
In reply to this post by Guy N. Hurst
"Guy N. Hurst" wrote:

> Hi,
>
> I have started out with a basic framework having Exit and About.
> Next, I need to be able to run an external program from within the one I
> am making.
> (to download data from barcode scanner).
>
> But I noticed in the documentation I have, that wxExecute is not listed
> with the supported function classes for wxPython... :-(
>
> Maybe it has since been added ?
>
> I am not sure what to do next, so I turn to this mailing list.
>
> Anyone have some pointers for me?

Maybe you would like to look at the Python library reference manual:
http://www.python.org/doc/current/lib/os-process.html

---
Markus

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] wxExecute?

Guy N. Hurst
In reply to this post by Robin Dunn
Thanks to all who responded.

For some reason, I didn't think the os module was an option.
I have now tried both the os module and wxExecute (which does exist :-).

Both do work, but wxExecute handled more gracefully for what I was
trying to do.

Of course, I will need the os module functionality soon enough.
Thanks for all the pointers.

Guy N. Hurst


Robin Dunn wrote:

>
> > But I noticed in the documentation I have, that wxExecute is not listed
> > with the supported function classes for wxPython... :-(
> >
>
> Python provides several good ways to execute other programs.  Look in the
> Python docs at the os module.
>
> On the other hand, wxExecute is supported by wxPython.  It's not listed in
> the list of supported classes because it is not a class.  I guess there needs
> to be another page that lists the supported functions too.
>
> --
> Robin Dunn
> Software Craftsman
> [hidden email]
> http://AllDunn.com/robin/
> http://AllDunn.com/wxPython/  Check it out!
>
> _______________________________________________
> wxPython-users maillist  -  [hidden email]
> http://starship.python.net/mailman/listinfo/wxpython-users


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] wxExecute?

Guy N. Hurst
(cc to list)

Hi,

I liked wxExecute, because when it tried to run a bad command, it
recovered well,
whereas using os module on a bad command made my system crash HARD. (ok,
maybe I should use try/except).
But, when trying the simple copy command with wxExecute, it complained
it couldn't find the file, whereas the os module executed the same
command easily (os.system).

Then I found the wxCopyFile function, among others -- but they must not
be implemented,
because when I tried this one, it gave me: "NameError: wxCopyFile".
Not only that, but it seems to use the wxString class, which is not in
the list of implemented classes.
wxGetCWD() doesn't work either...

I am definitely losing confidence in wxExecute.

As for the console window, I have that also - I have yet to discover how
to make that go away...

Anyone else have ideas?

Guy N. Hurst



Andrew Yinger wrote:

>
> Hi.
>
>     As noted, wxExecute does not seem to be documented.  Since it looks as
> if you are trying it out, can you clue me into what it does exactly?  For
> example, could I use it for some of the functionality found in os.system()
> and os.popen()?  (The reason I ask is that I have to run my wxPython app
> with a console window present because I need to use these os functions to
> execute some lame shell scripts -- if I do not run with a console window,
> these function calls do not appear to work!)
>
> Thanks,
>
> Andrew
>
> ----- Original Message -----
> From: Guy N. Hurst <[hidden email]>
> To: wxPython Post <[hidden email]>
> Sent: Tuesday, November 30, 1999 9:50 PM
> Subject: Re: [wxPython] wxExecute?
>
> > Thanks to all who responded.
> >
> > For some reason, I didn't think the os module was an option.
> > I have now tried both the os module and wxExecute (which does exist :-).
> >
> > Both do work, but wxExecute handled more gracefully for what I was
> > trying to do.
> >
> > Of course, I will need the os module functionality soon enough.
> > Thanks for all the pointers.
> >
> > Guy N. Hurst
> >
> >


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] wxExecute?

Harri Pasanen-3
In reply to this post by Guy N. Hurst

-----Original Message-----
From: Guy N. Hurst <[hidden email]>
To: Andrew Yinger <[hidden email]>
Cc: wxPython Post <[hidden email]>
Date: Sunday, December 05, 1999 6:36 AM
Subject: Re: [wxPython] wxExecute?


>(cc to list)
>
>Hi,
>
>I liked wxExecute, because when it tried to run a bad command, it
>recovered well,
>whereas using os module on a bad command made my system crash HARD. (ok,
>maybe I should use try/except).
>But, when trying the simple copy command with wxExecute, it complained
>it couldn't find the file, whereas the os module executed the same
>command easily (os.system).
>


For copying files I suggest you take a look at Python standard module
'shutil'
That provides functions such as copyfile, copytree, etc.

On windows (NT) the cmd.exe, or command.com complicates life, as it
implements some commands internally.   I would think that there is some way
to make wxExecute perform the copy by invoking cmd.exe with parameters, but
I suggest not to bother and use shutil.copy2 instead.   wxExecute will
likely work well for windows applications with a corresponding exe.  I think
os.system will use cmd.exe to do its work, and will thus flash a msdos
window while launching the command.



-Harri



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

RE: [wxPython] wxExecute?

Cristian Echeverria
In reply to this post by Guy N. Hurst
If you are on win95/98/NT you must see
spawnv (into the os module).
this function works only on windows and avoid the
console.

Cristian

----- Original Message -----
From: Guy N. Hurst <[hidden email]>
To: Andrew Yinger <[hidden email]>
Cc: wxPython Post <[hidden email]>
Sent: Saturday, December 04, 1999 11:15 PM
Subject: Re: [wxPython] wxExecute?


> (cc to list)
>
> Hi,
>
> I liked wxExecute, because when it tried to run a bad command, it
> recovered well,
> whereas using os module on a bad command made my system crash HARD. (ok,
> maybe I should use try/except).
> But, when trying the simple copy command with wxExecute, it complained
> it couldn't find the file, whereas the os module executed the same
> command easily (os.system).
>
> Then I found the wxCopyFile function, among others -- but they must not
> be implemented,
> because when I tried this one, it gave me: "NameError: wxCopyFile".
> Not only that, but it seems to use the wxString class, which is not in
> the list of implemented classes.
> wxGetCWD() doesn't work either...
>
> I am definitely losing confidence in wxExecute.
>
> As for the console window, I have that also - I have yet to discover how
> to make that go away...
>
> Anyone else have ideas?
>
> Guy N. Hurst
>
>
>
> Andrew Yinger wrote:
> >
> > Hi.
> >
> >     As noted, wxExecute does not seem to be documented.  Since it looks
as
> > if you are trying it out, can you clue me into what it does exactly?
For
> > example, could I use it for some of the functionality found in
os.system()
> > and os.popen()?  (The reason I ask is that I have to run my wxPython app
> > with a console window present because I need to use these os functions
to
> > execute some lame shell scripts -- if I do not run with a console
window,

> > these function calls do not appear to work!)
> >
> > Thanks,
> >
> > Andrew
> >
> > ----- Original Message -----
> > From: Guy N. Hurst <[hidden email]>
> > To: wxPython Post <[hidden email]>
> > Sent: Tuesday, November 30, 1999 9:50 PM
> > Subject: Re: [wxPython] wxExecute?
> >
> > > Thanks to all who responded.
> > >
> > > For some reason, I didn't think the os module was an option.
> > > I have now tried both the os module and wxExecute (which does exist
:-).

> > >
> > > Both do work, but wxExecute handled more gracefully for what I was
> > > trying to do.
> > >
> > > Of course, I will need the os module functionality soon enough.
> > > Thanks for all the pointers.
> > >
> > > Guy N. Hurst
> > >
> > >
>
>
> _______________________________________________
> wxPython-users maillist  -  [hidden email]
> http://starship.python.net/mailman/listinfo/wxpython-users
>


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users