473,320 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

why doesn't is work?a script to backup a directory

"""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>')

Apr 1 '06 #1
6 1194
On Fri, 31 Mar 2006 18:37:11 -0800, obeeker wrote:
"""there is threee directories,one of these is used for the base
directory,decided by the user, default is d0"""


[snip code]

It doesn't work? Have you tried running it to see what it does? When you
do, please post a description of what it does, including any exception
tracebacks, and just as importantly, what you expect it to do.
--
Steven.

Apr 1 '06 #2
thank you for your suggestion and apologize for my mistake.
if i run it and answer the raw_input with "Enter" i get

sth is wrong
press Return>
i comment the try-except and run it and answer the raw_input with
"Enter"
and get message following:
Traceback (most recent call last):
File "G:\9\Eb\updateEbBb.py", line 41, in -toplevel-
updateNow(base)
File "G:\9\Eb\updateEbBb.py", line 28, in updateNow
update(d0)
File "G:\9\Eb\updateEbBb.py", line 16, in update
shutil.rmtree(i)
File "D:\Program Files\Python24\lib\shutil.py", line 155, in rmtree
onerror(os.listdir, path, sys.exc_info())
File "D:\Program Files\Python24\lib\shutil.py", line 153, in rmtree
names = os.listdir(path)
WindowsError: [Errno 3] : 'O:/eb/mb/SCIL/*.*'

Apr 1 '06 #3
please don't read the prevous post ,please read this one:
thank you for your suggestion and apologize for my mistake.
if i run it and answer the raw_input with "Enter" i get

sth is wrong
press Return>
i comment the try-except and run it and answer the raw_input with
"Enter"
and get message following:
Traceback (most recent call last):
File "G:\9\Eb\updateEbBb.py", line 41, in -toplevel-
updateNow(base)
File "G:\9\Eb\updateEbBb.py", line 28, in updateNow
update(d0)
File "G:\9\Eb\updateEbBb.py", line 16, in update
shutil.rmtree(i)
File "D:\Program Files\Python24\lib\shutil.py", line 155, in rmtree
onerror(os.listdir, path, sys.exc_info())
File "D:\Program Files\Python24\lib\shutil.py", line 153, in rmtree
names = os.listdir(path)
WindowsError: [Errno 3] : 'O:/eb/mb/S/*.*'

Apr 1 '06 #4
ob*****@gmail.com wrote:
please don't read the prevous post ,please read this one:

thank you for your suggestion and apologize for my mistake.
if i run it and answer the raw_input with "Enter" i get

sth is wrong
press Return>

i comment the try-except and run it and answer the raw_input with
"Enter"
and get message following:
Traceback (most recent call last):
File "G:\9\Eb\updateEbBb.py", line 41, in -toplevel-
updateNow(base)
File "G:\9\Eb\updateEbBb.py", line 28, in updateNow
update(d0)
File "G:\9\Eb\updateEbBb.py", line 16, in update
shutil.rmtree(i)
File "D:\Program Files\Python24\lib\shutil.py", line 155, in rmtree
onerror(os.listdir, path, sys.exc_info())
File "D:\Program Files\Python24\lib\shutil.py", line 153, in rmtree
names = os.listdir(path)
WindowsError: [Errno 3] : 'O:/eb/mb/S/*.*'


shutil.rmtree() expects a directory name, not a file pattern. if you leave
out the "*.*" part at the end, it should do what you want.

(assuming you want to remove the eb/mb/S directory, that is)

</F>

Apr 1 '06 #5
i am very sorry .
the erroer was from my Portable Hard Disk
because its disk sign has changed from "o" to "h" ,from "p" to "i"
i'm very sorry

Apr 1 '06 #6
I wrote:
WindowsError: [Errno 3] : 'O:/eb/mb/S/*.*'


shutil.rmtree() expects a directory name, not a file pattern. if you leave
out the "*.*" part at the end, it should do what you want.


postscript: typically enough, I stumbled upon the same error message myself,
a day later. looks like it's Windows that adds the "*.*" thing to the path, all
by itself.

however, on my machine, I get a bit more information:

WindowsError: [Errno 3] The system cannot find the path specified:
'directory/*.*'

</F>

Apr 2 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chewy509 | last post by:
Hi Everyone, I'll just start, and say I am not a PHP developer (I'm a sysadmin, who has gotten lumped with a non-working website). But since I like to do this type of stuff, I though I might...
5
by: Paul O. Morris | last post by:
Is there a script that I can run to stop a particular SQL server service on Win2003 server? I'm looking for a similar script to restart that service as well. Thanks.
1
by: Luc Le Blanc | last post by:
I'm trying to restore a backup from a DMS DB2/2 database. The original DB has 3x 1Gb containers in the user tablespace. So the backup has 3 files, bearing the time of the backup as file name, with...
6
by: Steven | last post by:
I have a problem with moving the backup of my database from machine to machine. The size is 17 Gig and my network keeps timing out when I try to ftp it from machine to machine. I have had the...
1
by: microsoft . public . sqlserver | last post by:
I am using SQL server 7.0. After restoring all the databses (Except distribution) Everything seems to be working fine except the backup maintenance plan. I put following detail in the maintenance...
3
by: dcruncher4 | last post by:
DB2 8.2.3 the task I have is to write a script to restore a database from a backup on to another machine. the backup can be as old as seven years. The container layout on the machine to be...
9
by: george.zhang | last post by:
Hi, Friends, I have oneconcern on my stragety on db2 backup. My db2 databse backup imdage with size 100G. On the server, it has two directories which I can use to backup: directory a with 30 G...
7
by: imtmub | last post by:
I have a page, Head tag Contains many Scripts and style sheet for Menu and Page. This code working fine and displaying menus and page as i wanted. Check this page for reference....
20
by: cmrchs | last post by:
Hi, I have in my web application project (VS.NET 2008) : - a webform (webform2.aspx, webform2.aspx.cs, webform2.aspx.designer.cs) - a code-file Product.cs. But i can't use the definition of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.