using Python to run other programs

F

Frog

Hi, i'm not a programmer so I have a very stupid question. I'm trying to
make a practical script. I need to run an executable program in it but i
can't get it to work. Maybe someone here can figure it out easily:

-----
#! /python

a = (recipient's e-mail address)

pgp -feat a

(sendmail to address after encryption)
------

How do I get python to open the pgp program?

Should I use an environment other than python?

thanks!
 
S

Sagiv Malihi

hi,
using python to run shell commands is very easy.
all you need to do is create the command line you would want to run. in your
case:
command = "pgp -feat " + a
and then run it using os.system(), like this:
import os
os.system(command)


if you also want to get the output of the command, you can use the
'commands' module, like this:
import commands

output, rc = commands.getoutput(command)

then you get the output into the variable 'output', and the exit code of the
program into the variable 'rc'.

sagiv.
 
J

Jegenye 2001 Bt

Download Duplicity, there's a nice GnuPG module in it, which would also
demonstrate the technique how this can be done.

http://www.nongnu.org/duplicity

To send e-mail is pretty easy by using the standard library. Have a look at
the tutorial which comes with your Python installation.

Best,
Miklós
 
B

Bob Gailer

This is the 3rd time I've downloaded, installed and tried Boa. Each time I
meet with one frustration or another. This time I'm trying to go thru the
Getting Started, and find numerous places that the tutorial does not agree
with the reality or I try something and it does not work.

Has anyone had success with Boa Constructor? If so how did you learn it?
The tutorial clearly is not the way I can learn it.

Bob Gailer
(e-mail address removed)
303 442 2625
 
K

Kylotan

Bob Gailer said:
This is the 3rd time I've downloaded, installed and tried Boa. Each time I
meet with one frustration or another. This time I'm trying to go thru the
Getting Started, and find numerous places that the tutorial does not agree
with the reality or I try something and it does not work.

I too found that the tutorial was inaccurate (perhaps just out of
date), but I was able to guess what to do instead. Do you have any
specific examples of problems that maybe myself or others could help
with?
Has anyone had success with Boa Constructor? If so how did you learn it?
The tutorial clearly is not the way I can learn it.

To be honest with you I gave up on Boa, the main reason being that it
doesn't support wxSizers, which are useful - and with which the visual
designer becomes less important anyway. But I can sympathise with your
frustration. I think that one downside of Python having such great
centralised documentation is that the other projects seem to be very
poorly documented by comparison! Tutorials tend to be out of date, and
a lot of the help I can find on various subjects seems to stop at
'hello world' and then jump directly to the tricks of the trade.

I am attempting to learn how to use wxPython from their mailing list,
from the demos that come with the package, and from the Wiki
(http://wiki.wxpython.org/index.cgi/FrontPage). However, expect to
have to do a lot of cross-referencing, as I couldn't find anything
that could stand alone as a comprehensive guide.
 
R

Richard Bird CCNP, CCDP, MCSE, etc.

Bob Gailer said:
This is the 3rd time I've downloaded, installed and tried Boa. Each time I
meet with one frustration or another. This time I'm trying to go thru the
Getting Started, and find numerous places that the tutorial does not agree
with the reality or I try something and it does not work.

Has anyone had success with Boa Constructor? If so how did you learn it?
The tutorial clearly is not the way I can learn it.

Bob Gailer
(e-mail address removed)
303 442 2625

--

I too experience your frustration with boa. I finally figured it out
and now enjoy using it. Once you get your first interface built,
there's no stopping you. Remember to create your panel first, then you
can add controls and such to it.

Richard Bird
 
J

Javier Ruere

Bob said:
Has anyone had success with Boa Constructor? If so how did you learn it?
The tutorial clearly is not the way I can learn it.

I've never tried the tutorial. I just explored the program making some
bogus projects testing all the main features. Then, as I used it, kept
learning the rest of it.

Javier
 
J

Javier Ruere

Kylotan said:
To be honest with you I gave up on Boa, the main reason being that it
doesn't support wxSizers, which are useful - and with which the visual
designer becomes less important anyway.

Boa now supports wxSizers.

Javier
 
K

Kylotan

Javier Ruere said:
Boa now supports wxSizers.

Javier

The version I have is the same one that is available for download on
the website and seems to have absolutely nothing on wxSizers. In fact
I remember reading recently that there is preliminary support but it
is only in CVS. Perhaps that is what you mean?
 
J

Javier Ruere

Kylotan said:
The version I have is the same one that is available for download on
the website and seems to have absolutely nothing on wxSizers. In fact
I remember reading recently that there is preliminary support but it
is only in CVS. Perhaps that is what you mean?

Yes, that's what I meant. Sizer were added in version 0.2.5 IIRC and
only 0.2.3 seems to be available.
I never used an application directly from CVS before Boa but, since
releases are so far apart and the quality of the code is so good, I
started using the checkout directly. I think it was a really good idea
in this particular case.

Javier
 
M

Michal Dzirba

Yes, that's what I meant. Sizer were added in version 0.2.5 IIRC and
only 0.2.3 seems to be available.
I never used an application directly from CVS before Boa but, since
releases are so far apart and the quality of the code is so good, I
started using the checkout directly. I think it was a really good idea
in this particular case.

Javier

The problem is that one is not able to chackout tha project, at least it
is not posiible from the place where im sitting. Is there any other way
than cvs to take a look at say, nightly builds?


Michal.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top