From patchwork Mon Nov 22 13:38:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Zupka X-Patchwork-Id: 347471 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAMDdHVA016843 for ; Mon, 22 Nov 2010 13:39:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755838Ab0KVNjL (ORCPT ); Mon, 22 Nov 2010 08:39:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34436 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755616Ab0KVNjL (ORCPT ); Mon, 22 Nov 2010 08:39:11 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAMDdAdn025904 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 22 Nov 2010 08:39:10 -0500 Received: from jzupka.local.no ([10.3.112.12]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAMDd37Y021695; Mon, 22 Nov 2010 08:39:08 -0500 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=BDupka?= To: ldoktor@redhat.com, kvm-autotest@redhat.com, kvm@vger.kernel.org, autotest@test.kernel.org Cc: akong@redhat.com, jzupka@redhat.com Subject: [KVM-AUTOTEST][PATCH 2/2][virtio-console] Fix compatibility with python 2.4. Date: Mon, 22 Nov 2010 14:38:59 +0100 Message-Id: <1290433139-13805-2-git-send-email-jzupka@redhat.com> In-Reply-To: <1290433139-13805-1-git-send-email-jzupka@redhat.com> References: <1290433139-13805-1-git-send-email-jzupka@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 22 Nov 2010 13:39:18 +0000 (UTC) diff --git a/client/tests/kvm/scripts/virtio_guest.py b/client/tests/kvm/scripts/virtio_guest.py index 87727c7..b039ec9 100755 --- a/client/tests/kvm/scripts/virtio_guest.py +++ b/client/tests/kvm/scripts/virtio_guest.py @@ -248,7 +248,7 @@ class VirtioGuest: print os.system("stty -F %s raw -echo" % (name)) print os.system("stty -F %s -a" % (name)) f.append(self.files[name]) - except Exception as inst: + except Exception, inst: print "FAIL: Failed to open file %s" % (name) raise inst return f @@ -316,12 +316,14 @@ class VirtioGuest: else: fcntl.fcntl(fd, fcntl.F_SETFL, fl & ~os.O_NONBLOCK) - except Exception as inst: + except Exception, inst: print "FAIL: Setting (non)blocking mode: " + str(inst) return - print ("PASS: set blocking mode to %s mode" % - ("blocking" if mode else "nonblocking")) + if mode: + print "PASS: set to blocking mode" + else: + print "PASS: set to nonblocking mode" def close(self, file): @@ -339,7 +341,7 @@ class VirtioGuest: if descriptor != None: try: os.close(descriptor) - except Exception as inst: + except Exception, inst: print "FAIL: Closing the file: " + str(inst) return print "PASS: Close" @@ -359,7 +361,7 @@ class VirtioGuest: print os.system("stty -F %s raw -echo" % (name)) print os.system("stty -F %s -a" % (name)) print "PASS: Open all filles correctly." - except Exception as inst: + except Exception, inst: print "%s\nFAIL: Failed open file %s" % (str(inst), name) @@ -443,7 +445,7 @@ class VirtioGuest: data += "%c" % random.randrange(255) try: writes = os.write(in_f[0], data) - except Exception as inst: + except Exception, inst: print inst if not writes: writes = 0 @@ -451,7 +453,7 @@ class VirtioGuest: while (writes < length): try: writes += os.write(in_f[0], data) - except Exception as inst: + except Exception, inst: print inst if writes >= length: print "PASS: Send data length %d" % writes @@ -473,13 +475,13 @@ class VirtioGuest: recvs = "" try: recvs = os.read(in_f[0], buffer) - except Exception as inst: + except Exception, inst: print inst if mode: while (len(recvs) < length): try: recvs += os.read(in_f[0], buffer) - except Exception as inst: + except Exception, inst: print inst if len(recvs) >= length: print "PASS: Recv data length %d" % len(recvs)