[Tutor] Critique and a big thanks!
Shawhan, Doug (EM, ITS)
Doug.Shawhan at ge.com
Fri Apr 2 14:16:40 EST 2004
We are having trouble with failed hard drives on a series of newly deployed computers at the plant I work at. There are ~ 300 of these and ~10% have had failed drive so far! I have been working on a python script to back up the important outlook email database files on these machines. The script grew from a simple copy thang to this threaded beast that works way better than I ever thought it would! Thank you all so much for your help and suggestions for reading material!
My final question: What would you folks suggest to make this script more simple and easier to read? (...and if you see any horrible coding blemishes, I would like to know too!). Thanks again everyone! This list is one of the best things about python!
Copies *.pst and *.pab files from remote hosts to backup on remote hosts to the
\\Server\shared\company\MailBackup directory. Gets list of hosts to
back up from the hosts.csv file in \tmp\MailMover.
Our bunch has standardized on having mail folders in My Documents\EXCHANGE\,
your group will probably do something different - edit accordingly!
Usage: "python mailmover.py"
Caveats: one must have superuser privileges (domain opers) on the remote machines
to connect and copy /-Y files. There is, as yet, _no_ error reporting.
from threading import Thread
#create list for thread pool.
#open the .csv file and strip out the linefeeds
for host in hostholder:
def __init__(self, users, host, destination_directory):
print "thread started"
for user in self.users:
#strip extraneous pathname info from username.
#Assumes all hostnames are the same length
if mailboxes !=:
#create pathname on storage host!
os.system("copy /Y %s*.pst %s"%(collection_path, storage_path))
#we'll just copy the addressbooks too, for smarts
os.system("copy /Y %s*.pab %s"%(collection_path, storage_path))
#returns the number of living threads
num_active = 0
for g in gathers:
num_active += 1
print "%d alive" % num_active
for host in hosts:
users=glob.glob("\\\\%s\\d$\\users\\*"%host)# collect the users on the host
while count_active() >= MAX_THREADS:
print "too many active"
go=gather(users, host, destination_directory)
More information about the Tutor