why doesn't is work?a script to backup a directory
obeeker at gmail.com
obeeker at gmail.com
Fri Mar 31 21:37:11 EST 2006
"""there is threee directories,one of these is used for the base
directory,decided by the user, default is d0"""
import shutil
#the three directories
d0='D:/Program Files/eb/mb/S'
d1='O:/eb/mb/S'
d2='P:/S/eb/mb/S'
#to backup
def update(base):
l=[d0,d1,d2]
l.remove(base)
for i in l:
shutil.rmtree(i)
for i in l:
shutil.copytree(base,i)
#use the base directory to invoke the update() func
def updateNow(base):
try:
if base=='d1':
update(d1)
elif base=='d2':
update(d2)
else:
update(d0)
except:
print "sth is wrong"
else:
print "OK!"
#promt user which is the base
if __name__ == '__main__':
print 'd0=',d0
print 'd1=',d1
print 'd2=',d2
base=raw_input("your base/standard directory is d0 d1 or d2 ?\n")
print base
updateNow(base)
raw_input('press Return>')
More information about the Python-list
mailing list