Moving around files and fun things of that sort.

Micah Mayo astrophels at yahoo.com
Tue Aug 27 14:10:38 EDT 2002


Howdy,

I am writing a set of 'resurrection' scripts for the servers on my
network. While I'm aware this task would probably be handled better by
a set of shell scripts, I am new to programming and python, so I
decided to cut my teeth with this one. Basically, I have all of my
important config files on a disk, so if one of the servers crashes,
and I just want to reinstall, run my python script and everything will
be put in its place and their respective deamons will restart. The
first version mounted my disk and copied a file over using the
os.system method, then using the os.path.getmtime and os.path.getsize
methods, i compare and verify that the file was copied successfully(I
use cp -p to preserve the date). I did all that in a couple of hours
last night. I got in this morning and started looking at my program
and realized how clunky it really was. First, I have right now 17
config files. This only covers one server, and we have 5. The way it
was set up, I had to write in all of that functionality for every
single file.. It was just bogus. So, I scrapped it and started working
on version 0.2. In version 0.2 I have created two lists, which hold
the source and destination of the files I want to copy, and are titled
respectively. Here is what I'd like to do, basically:
x = 0
for x in range (17):
    os.system('cp -p source[x] destination[x]')
    if os.path.getsize(source[x]) != os.path.getsize(destination[x]):
        print 'Size not verified, do you wish to contnue?'
        etc..
        etc..
(this is pseudo-code, so don't worry about specific syntax)
my problem is this will not work with the os.system method. There
isn't a way that I can find that will allow me to mix these arrays
with the system command. So a) is there a way for python to copy the
files w/o using the os.system, or is there a way to make os.system
work?

Any help will be appreciated.

Micah

Please e-mail me, as I am posting this through google.



More information about the Python-list mailing list