shutil.copy2 error
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" -- http://mail.python.org/mailman/listinfo/python-list
Re: shutil.copy2 error
On Sep 24, 6:34 pm, Karthik Gurusamy <[EMAIL PROTECTED]> wrote: > On Sep 24, 7:34 am, Horse <[EMAIL PROTECTED]> wrote: > > > > > 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. -- http://mail.python.org/mailman/listinfo/python-list
OH MY GOD! HUMANS HAVE ORIGINS IN THE DEVONIAN!
== >BREAKING HOGWASH! == > TALK.ORIGINS RECENTLY ANNOUNCED THAT HUMANS HAVE ORIGINS IN THE DEVONIAN. > THIS RECENT RECOGNITION OF THE GREATEST FACT IN EARTH'S HISTORY IS PROFOUND TO http://www.talkorigins.org/ CREDIBILITY. (Also see http://www.ediacara.org/) > DAVID IAIN GREIG, TALK.ORIGINS DICTATOR WAS RELUCTANT BUT FINALLY ANNOUNCED IN A PAPER IN http://www.sciencemag.org/ THAT THRINAXODON WAS RIGHT, AND HUMANS DO HAVE ORIGINS IN THE DEVONIAN! > === EVIDENCE THAT HUMANS LIVED IN THE DEVONIAN: https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/6f501c469c7af24f# https://groups.google.com/group/sci.bio.paleontology/browse_thread/thread/3aad75c16afb0b82# http://thrinaxodon.wordpress.com/ === THRINAXODON ONLY HAD THIS TO SAY: "I..I...I...Can't believe it. This completely disproved Darwinian orthodoxy." === THE BASTARDS AT THE SMITHSONIAN, AND THE LEAKEY FOUNDATION ARE ERODING WITH FEAR. === THESE ASSHOLES ARE GOING TO DIE: THOMAS AQUINAS; ALDOUS HUXLEY; BOB CASANVOVA; SkyEyes; DAVID IAIN GRIEG; MARK ISAAK; JOHN HARSHAM; RICHARD NORMAN; DR. DOOLITTLE; CHARLES DARWIN; MARK HORTON; ERIK SIMPSON; HYPATIAB7; PAUL J. GANS; JILLERY; WIKI TRIK; THRINAXODON; PETER NYIKOS; RON OKIMOTO; JOHN S. WILKINS === THRINAXODON WAS SCOURING ANOTHER DEVONIAN FOSSIL BED, AND FOUND A HUMAN SKULL, AND A HUMAN FEMUR. HE ANALYSED THE FINDS, AND SAW THAT THEY WERE NOT NORMAL ROCKS. THESE WERE FOSSILIZED BONES. THEY EVEN HAD TOOTH MARKS ON THEM. SO, THRINAXODON BROUGHT THEM TO THE LEAKEY FOUNDATION, THEY UTTERLY DISMISSED IT, AND SAID, "We want to keep people thinking that humans evolved 2 Ma." THRINAXODON BROUGHT HIS SWORD, AND SAID, "SCIENCE CORRECTS ITSELF." RICHARD LEAKEY SAID, "That is a myth, for people to believe in science." THRINAXODON PLANS TO BRING DOOM TO SCIENCE, ITSELF. THRINAXODON IS NOW ON REDDIT -- ---Thrinaxodon -- https://mail.python.org/mailman/listinfo/python-list