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" 3 4402
On Sep 24, 7:34 am, Horse <jbutu...@gmail.comwrote:
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)
I'm not sure of the error; but one possibility is that the source-
directory contents may be modified by some other process, while you
are looping here copying one-by-one the files.
So a file 'x' could be present at the time you enter loop, but gone by
the time you try the shutil.copy2. Again this is just a guess...
Yet another possibility is 'x' is not a regular file (say in unix it
could be a named pipe).. you can try adding a check for x (like
os.path.isfile(x)) and copy only regular files.
Karthik
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"
On Sep 24, 6:34 pm, Karthik Gurusamy <kar1...@gmail.comwrote:
On Sep 24, 7:34 am, Horse <jbutu...@gmail.comwrote:
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)
I'm not sure of the error; but one possibility is that the source-
directory contents may be modified by some other process, while you
are looping here copying one-by-one the files.
So a file 'x' could be present at the time you enter loop, but gone by
the time you try the shutil.copy2. Again this is just a guess...
Yet another possibility is 'x' is not a regular file (say in unix it
could be a named pipe).. you can try adding a check for x (like
os.path.isfile(x)) and copy only regular files.
Karthik
Thanks for the ideas, I will look into if there is anything else using
these files (maybe a system level backup they hadn't told me
about??). Otherwise, these files are perfectly valid, I can go back
on the ones that error and manually copy them by hand to the
destination folder. I should've mentioned earlier, but this is
running on a windows 2000 system, and the destination folder is a
samba share on a Linux server.
In message <11**********************@19g2000hsx.googlegroups. com>, Horse
wrote:
I should've mentioned earlier, but this is
running on a windows 2000 system, and the destination folder is a
samba share on a Linux server.
Could it be the connection to the Samba server has gone down temporarily? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: bmgz |
last post by:
I am have made a simple script that moves all desktop clutter (ie files that
are not *.lnk) to a specified folder
eg. c:\myhome\mydocs\desktopdebris\2003-12-16
...
|
by: Todd7 |
last post by:
I am writing a python program to load a pdf file into an IEHtmlWindow
which displays it through adobe acrobat reader 7. Depending on the
buttons the user clicks, the program moves it to another...
|
by: BartlebyScrivener |
last post by:
I'm working on various backup scripts, using filecmp and shutil.
When I run a script to copy files to a mapped network drive, shutil
creates a backup file with a date of 2002 or so.
If I use...
|
by: Antoine De Groote |
last post by:
Google tells quite some things about it, but none of them are satisfactory.
I'm on Windows, and shutil operations (e.g. move, copy) throw
Permission denied all the time, for the source files. It...
|
by: Ben Sizer |
last post by:
I need to copy directories from one place to another, but it needs to
overwrite individual files and directories rather than just exiting if
a destination file already exists. Previous suggestions...
|
by: Robert Dailey |
last post by:
Hi,
I'm trying to create a Python equivalent of the C++ "ifstream" class,
with slight behavior changes.
Basically, I want to have a "filestream" object that will allow you to
overload the...
|
by: yinglcs |
last post by:
Hi,
Is there a c library which does shutil.copy2() in python? Basically
copy a file from 1 directory to another?
import shutil
import os
shutil.copy2(r"C:\test\test",r"C:\test1\test")
|
by: Roopesh |
last post by:
Hi,
I have a multithreaded application. There are two threads, T1 and T2.
Suppose that there are two folders A, B. Thread T1 fetches data from
network and creates files in folder A and after...
|
by: klia |
last post by:
hello folks
i am trying to tweak the current codes so that later when i call it from the terminal i can provide sourcefile and the destination file rather being fixed in the code. because now i...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |