Help running Windows programs from Python

Scott scott.freemire at gmail.com
Fri May 7 15:14:35 EDT 2010


I want to write a script to automate log archiving/compressing on a
Win2003 server. I have Python 2.6 installed. I am planning to use 7-
zip for compression (because I have been using it manually for a while
now). For now all operations will be local in the C: drive.

As a total beginner I'm having trouble grasping the control of
external programs.

I have found these options but have not tried any yet - I would like
some advice on which approach would be the most appropriate to begin
with.

Command Line Application Approach:
os.system
os.spawn*
os.popen*
popen2.*
commands.*
All of the above recommend replacing with subprocess module
subprocess - latest way to do command line?
pexpect module - http://sourceforge.net/projects/pexpect/, Most recent
file is dated 1/5/2008
    It should work on any platform that supports the standard Python
pty  module. (Windows?)
        pty - "On Windows, only sockets are supported; on Unix, all
file descriptors." (gulp, ??)

COM Application Approach:
Per the 7-zip FAQ: Use the 7z.dll or 7za.dll - I haven't found these
files yet on sf.net.
comtypes 0.6.2 - has the word COM in it?
pywin32 / win32com  - there's that word again.

And then there is this whole idea of "wrappers."

Thanks,
Scott



More information about the Python-list mailing list