From: "Cao, Chen" Subject: [PATCH] Using shutil.move to move result files in job.py Date: Tue, 13 Oct 2009 10:36:19 +0800 Message-ID: <1255401379-21896-1-git-send-email-kcao@redhat.com> Cc: autotest@test.kernel.org, kvm@vger.kernel.org, "Cao, Chen" To: lmr@redhat.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:63038 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756131AbZJMCgr (ORCPT ); Mon, 12 Oct 2009 22:36:47 -0400 Sender: kvm-owner@vger.kernel.org List-ID: 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 Signed-off-by: Cao, Chen --- client/bin/job.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/client/bin/job.py b/client/bin/job.py index a1c07cc..ebfb3a3 100755 --- a/client/bin/job.py +++ b/client/bin/job.py @@ -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