From: Lucas Meneghel Rodrigues Subject: Re: [Autotest] [PATCH] Using shutil.move to move result files in job.py Date: Wed, 14 Oct 2009 07:15:56 -0300 Message-ID: <6ac58f4f0910140315w715e3be3wf3c0a4dbcb893073@mail.gmail.com> References: <1255401379-21896-1-git-send-email-kcao@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: autotest@test.kernel.org, kvm@vger.kernel.org To: "Cao, Chen" Return-path: Received: from mail-px0-f180.google.com ([209.85.216.180]:54131 "EHLO mail-px0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756916AbZJNKQd convert rfc822-to-8bit (ORCPT ); Wed, 14 Oct 2009 06:16:33 -0400 Received: by pxi10 with SMTP id 10so92604pxi.4 for ; Wed, 14 Oct 2009 03:15:56 -0700 (PDT) In-Reply-To: <1255401379-21896-1-git-send-email-kcao@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Ok, looks good. Commited as http://autotest.kernel.org/changeset/3844 On Mon, Oct 12, 2009 at 11:36 PM, Cao, Chen wrote: > 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: > > =A0Traceback (most recent call last): > =A0 =A0File "/usr/local/kvm/kvm-test/bin/autotest", line 52, in ? > =A0 =A0 =A0options.log) > =A0 =A0File "/usr/local/kvm/kvm-test/bin/job.py", line 1274, in runjo= b > =A0 =A0 =A0myjob.complete(0) > =A0 =A0File "/usr/local/kvm/kvm-test/bin/job.py", line 798, in comple= te > =A0 =A0os.rename(self.state_file, dest) > =A0OSError: [Errno 18] Invalid cross-device link > > Signed-off-by: Cao, Chen > --- > =A0client/bin/job.py | =A0 =A02 +- > =A01 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): > =A0 =A0 =A0 =A0 """Clean up and exit""" > =A0 =A0 =A0 =A0 # We are about to exit 'complete' so clean up the con= trol file. > =A0 =A0 =A0 =A0 dest =3D os.path.join(self.resultdir, os.path.basenam= e(self.state_file)) > - =A0 =A0 =A0 =A0os.rename(self.state_file, dest) > + =A0 =A0 =A0 =A0shutil.move(self.state_file, dest) > > =A0 =A0 =A0 =A0 self.harness.run_complete() > =A0 =A0 =A0 =A0 self.disable_external_logging() > -- > 1.6.0.6 > > _______________________________________________ > Autotest mailing list > Autotest@test.kernel.org > http://test.kernel.org/cgi-bin/mailman/listinfo/autotest > --=20 Lucas