From patchwork Wed Jun 10 00:57:50 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 29113 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5A0w87A004585 for ; Wed, 10 Jun 2009 00:58:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751927AbZFJA6B (ORCPT ); Tue, 9 Jun 2009 20:58:01 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751446AbZFJA6B (ORCPT ); Tue, 9 Jun 2009 20:58:01 -0400 Received: from mx2.redhat.com ([66.187.237.31]:37543 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750725AbZFJA6B (ORCPT ); Tue, 9 Jun 2009 20:58:01 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5A0w3h1020846; Tue, 9 Jun 2009 20:58:03 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n5A0w2Ss027447; Tue, 9 Jun 2009 20:58:02 -0400 Received: from localhost.localdomain (vpn-10-19.bos.redhat.com [10.16.10.19]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n5A0vsFi016064; Tue, 9 Jun 2009 20:57:57 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [KVM-AUTOTEST PATCH] Make all programs on kvm test use /usr/bin/python - take 2 Date: Tue, 9 Jun 2009 21:57:50 -0300 Message-Id: <1244595470-14912-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org All kvm modules that can be used as stand alone programs were updated to use #!/usr/bin/python instead of #!/usr/bin/env python, complying with the rest of the autotest code base. As suggested by Martin, common.py was added. With this, the stand alone programs will be able to use the autotest library namespace and choose the best python interpreter available in the system. Signed-off-by: Lucas Meneghel Rodrigues --- client/tests/kvm/common.py | 8 ++++++++ client/tests/kvm/fix_cdkeys.py | 3 ++- client/tests/kvm/kvm_config.py | 4 +++- client/tests/kvm/make_html_report.py | 5 +++-- client/tests/kvm/stepeditor.py | 4 ++-- client/tests/kvm/stepmaker.py | 4 +++- 6 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 client/tests/kvm/common.py diff --git a/client/tests/kvm/common.py b/client/tests/kvm/common.py new file mode 100644 index 0000000..ce78b85 --- /dev/null +++ b/client/tests/kvm/common.py @@ -0,0 +1,8 @@ +import os, sys +dirname = os.path.dirname(sys.modules[__name__].__file__) +client_dir = os.path.abspath(os.path.join(dirname, "..", "..")) +sys.path.insert(0, client_dir) +import setup_modules +sys.path.pop(0) +setup_modules.setup(base_path=client_dir, + root_module_name="autotest_lib.client") diff --git a/client/tests/kvm/fix_cdkeys.py b/client/tests/kvm/fix_cdkeys.py index 4f7a824..7a821fa 100755 --- a/client/tests/kvm/fix_cdkeys.py +++ b/client/tests/kvm/fix_cdkeys.py @@ -1,5 +1,6 @@ -#!/usr/bin/env python +#!/usr/bin/python import shutil, os, sys +import common """ Program that replaces the CD keys present on a KVM autotest configuration file. diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py index 40f16f1..13fdac2 100755 --- a/client/tests/kvm/kvm_config.py +++ b/client/tests/kvm/kvm_config.py @@ -1,4 +1,6 @@ +#!/usr/bin/python import re, os, sys, StringIO +import common from autotest_lib.client.common_lib import error """ @@ -356,7 +358,7 @@ class config: # (inside an exception or inside subvariants) if restricted: e_msg = "Using variants in this context is not allowed" - raise error.AutotestError() + raise error.AutotestError(e_msg) if self.debug and not restricted: self.__debug_print(indented_line, "Entering variants block (%d dicts in" diff --git a/client/tests/kvm/make_html_report.py b/client/tests/kvm/make_html_report.py index 6aed39e..e69367b 100755 --- a/client/tests/kvm/make_html_report.py +++ b/client/tests/kvm/make_html_report.py @@ -1,4 +1,7 @@ #!/usr/bin/python +import os, sys, re, getopt, time, datetime, commands +import common + """ Script used to parse the test results and generate an HTML report. @@ -7,8 +10,6 @@ Script used to parse the test results and generate an HTML report. @author: Dror Russo (drusso@redhat.com) """ -import os, sys, re, getopt, time, datetime, commands - format_css=""" html,body { diff --git a/client/tests/kvm/stepeditor.py b/client/tests/kvm/stepeditor.py index 9669200..e7794ac 100755 --- a/client/tests/kvm/stepeditor.py +++ b/client/tests/kvm/stepeditor.py @@ -1,6 +1,6 @@ -#!/usr/bin/env python +#!/usr/bin/python import pygtk, gtk, os, glob, shutil, sys, logging -import ppm_utils +import common, ppm_utils pygtk.require('2.0') """ diff --git a/client/tests/kvm/stepmaker.py b/client/tests/kvm/stepmaker.py index 2b7fd54..8f16ffd 100644 --- a/client/tests/kvm/stepmaker.py +++ b/client/tests/kvm/stepmaker.py @@ -1,8 +1,10 @@ -#!/usr/bin/env python +#!/usr/bin/python import pygtk, gtk, gobject, time, os, commands +import common from autotest_lib.client.common_lib import error import kvm_utils, logging, ppm_utils, stepeditor pygtk.require('2.0') + """ Step file creator/editor.