Skip to contentSkip to conversation

Using shutil.move to move result files in job.py

PATCH In review Cao, Chen 2 participants 2 messages Oct 13, 2009 – Oct 14, 2009 KVM

lore
Share & tools
lore

Cao, Chen

author
#0 lore raw

PATCH 1/1 Using shutil.move to move result files in job.py

Since os.rename requires that the file is in the same partition with the dest directory, we would get a python OSError if the result directory is mounted to a nfs server (or different partition or something else alike).

the traceback would be like:

Traceback (most recent call last):
File "/usr/local/kvm/kvm-test/bin/autotest", line 52, in ?
options.log)
File "/usr/local/kvm/kvm-test/bin/job.py", line 1274, in runjob
myjob.complete(0)
File "/usr/local/kvm/kvm-test/bin/job.py", line 798, in complete os.rename(self.state_file, dest)
OSError: [Errno 18] Invalid cross-device link

---
 client/bin/job.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
client/bin/job.py +1 -1
index a1c07cc..ebfb3a3 100755
@@ -938,7 +938,7 @@ class base_job(object):
         """Clean up and exit"""
         # We are about to exit 'complete' so clean up the control file.
         dest = os.path.join(self.resultdir, os.path.basename(self.state_file))
-        os.rename(self.state_file, dest)
+        shutil.move(self.state_file, dest)
 
         self.harness.run_complete()
         self.disable_external_logging()
Signature · 1 line
1.6.0.6
#1 lore raw

Ok, looks good. Commited as

http://autotest.kernel.org/changeset/3844

Quoted 42 lines · Chen

Since os.rename requires that the file is in the same partition with the dest directory, we would get a python OSError if the result directory is mounted to a nfs server (or different partition or something else alike).

the traceback would be like:

 Traceback (most recent call last):
   File "/usr/local/kvm/kvm-test/bin/autotest", line 52, in ? options.log)
   File "/usr/local/kvm/kvm-test/bin/job.py", line 1274, in runjob myjob.complete(0)
   File "/usr/local/kvm/kvm-test/bin/job.py", line 798, in complete os.rename(self.state_file, dest)
 OSError: [Errno 18] Invalid cross-device link

---
 client/bin/job.py |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
client/bin/job.py +0 -0
index a1c07cc..ebfb3a3 100755
@@ -938,7 +938,7 @@ class base_job(object):

        """Clean up and exit"""
        # We are about to exit 'complete' so clean up the control file. dest = os.path.join(self.resultdir, os.path.basename(self.state_file))
-        os.rename(self.state_file, dest)
+        shutil.move(self.state_file, dest)

        self.harness.run_complete()
        self.disable_external_logging()
--
1.6.0.6

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Signature · 1 line
Lucas