Using shutil.move to move result files in job.py
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
@@ -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
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 runjobmyjob.complete(0)
File "/usr/local/kvm/kvm-test/bin/job.py", line 798, in completeos.rename(self.state_file, dest)
OSError: [Errno 18] Invalid cross-device linkSigned-off-by Cao, Chen <[email protected]>---
client/bin/job.py | 2 +-1 files changed, 1 insertions(+), 1 deletions(-)client/bin/job.py +0
-0@@ -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