shutil.copy2 error
Horse
jbuturff at gmail.com
Mon Sep 24 10:34:37 EDT 2007
I've written a python script that copies a nightly Oracle backup file
to another server. Every couple days, the script fails with this
error message:
Error copying Q:/Oradata/GISPROD/Backups/3UISN35R_1_1 to s:/gisprod/
backups/3UISN35R_1_1
[Errno 22] Invalid argument
Here's the code for the function I'm running. The path names are all
correct, and it works *most of the time*. It only fails about once or
twice a week. Anyone know where I can get more info on this "errno 22
invalid argument"?
def CopyNewFiles(SOURCE_DIR, DEST_DIR):
global STATUS
try:
os.chdir(SOURCE_DIR)
for x in os.listdir(SOURCE_DIR):
int_time = os.stat(x)[stat.ST_CTIME]
str_time = time.ctime(int_time)
if datetime.date.fromtimestamp(int_time + 0.00) >
YESTERDAY:
try:
DEST_FILE = os.path.join(DEST_DIR, x)
logfile.write(" Copying " + SOURCE_DIR + x + "
to " + DEST_FILE + "\n")
logfile.flush()
if not os.path.isfile(DEST_FILE):
shutil.copy2(x, DEST_FILE)
else:
logfile.write(" File exists. Skipping.
\n")
logfile.flush()
except (IOError, os.error), why:
logfile.write("\n\nError copying " + SOURCE_DIR +
x + " to " + DEST_FILE + "\n\n")
logfile.write("\n" + str(why) + "\n")
logfile.flush()
STATUS = "FAILED"
except:
logfile.write("\n\nUnhandled error in CopyNewFiles\n\n")
logfile.write("SOURCE_DIR = " + SOURCE_DIR + "\n")
logfile.write("DEST_DIR = " + DEST_DIR + "\n")
logfile.flush()
STATUS = "FAILED"
More information about the Python-list
mailing list