From patchwork Thu Sep 8 04:26:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael-Doyle Hudson X-Patchwork-Id: 3973 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 60E4623E54 for ; Thu, 8 Sep 2011 04:26:14 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 4CF2BA182FA for ; Thu, 8 Sep 2011 04:26:14 +0000 (UTC) Received: by fxd18 with SMTP id 18so1749623fxd.11 for ; Wed, 07 Sep 2011 21:26:14 -0700 (PDT) Received: by 10.223.5.139 with SMTP id 11mr366001fav.138.1315455974138; Wed, 07 Sep 2011 21:26:14 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs161578lab; Wed, 7 Sep 2011 21:26:13 -0700 (PDT) Received: by 10.227.72.209 with SMTP id n17mr218700wbj.31.1315455973327; Wed, 07 Sep 2011 21:26:13 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com [91.189.90.7]) by mx.google.com with ESMTPS id el5si2280325wbb.65.2011.09.07.21.26.13 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Sep 2011 21:26:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1R1WBo-0001I2-Lg for ; Thu, 08 Sep 2011 04:26:12 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 7F648E0A07 for ; Thu, 8 Sep 2011 04:26:12 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dispatcher X-Launchpad-Branch: ~linaro-validation/lava-dispatcher/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 102 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 102: some uncontroversial coding style improvements from the config branch Message-Id: <20110908042612.7751.38720.launchpad@ackee.canonical.com> Date: Thu, 08 Sep 2011 04:26:12 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13891"; Instance="initZopeless config overlay" X-Launchpad-Hash: 4ca6eb66222a13b66be17f5af8efdc37a2480d23 ------------------------------------------------------------ revno: 102 committer: Michael-Doyle Hudson branch nick: trunk timestamp: Thu 2011-09-08 16:23:59 +1200 message: some uncontroversial coding style improvements from the config branch modified: lava_dispatcher/__init__.py lava_dispatcher/actions/deploy.py lava_dispatcher/actions/lava-test.py lava_dispatcher/android_client.py lava_dispatcher/client.py --- lp:lava-dispatcher https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk You are subscribed to branch lp:lava-dispatcher. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription === modified file 'lava_dispatcher/__init__.py' --- lava_dispatcher/__init__.py 2011-08-29 21:13:05 +0000 +++ lava_dispatcher/__init__.py 2011-09-08 04:23:59 +0000 @@ -47,8 +47,7 @@ @property def image_type(self): - if self.job_data.has_key('image_type'): - return self.job_data['image_type'] + return self.job_data.get('image_type') def run(self): lava_commands = get_all_cmds() @@ -135,17 +134,12 @@ def _assign_uuid(self): self._test_run['analyzer_assigned_uuid'] = str(uuid1()) - @property - def job_status(self): - return self._job_status - - @job_status.setter - def job_status(self, status): - self._job_status = status - def add_result(self, test_case_id, result, message=""): - result_data = { 'test_case_id': test_case_id, 'result': result \ - , 'message': message} + result_data = { + 'test_case_id': test_case_id, + 'result': result, + 'message': message + } self._test_run['test_results'].append(result_data) def add_attachment(self, attachment): === modified file 'lava_dispatcher/actions/deploy.py' --- lava_dispatcher/actions/deploy.py 2011-09-02 03:38:30 +0000 +++ lava_dispatcher/actions/deploy.py 2011-09-08 04:23:59 +0000 @@ -20,7 +20,6 @@ from commands import getoutput, getstatusoutput import os -import sys import re import shutil import traceback @@ -50,8 +49,8 @@ raise CriticalError("Unable to reach LAVA server, check network") try: - boot_tgz, root_tgz = self.generate_tarballs(hwpack, rootfs, - use_cache) + boot_tgz, root_tgz = self.generate_tarballs( + hwpack, rootfs, use_cache) except: tb = traceback.format_exc() client.sio.write(tb) === modified file 'lava_dispatcher/actions/lava-test.py' --- lava_dispatcher/actions/lava-test.py 2011-09-02 03:24:06 +0000 +++ lava_dispatcher/actions/lava-test.py 2011-09-08 04:23:59 +0000 @@ -21,12 +21,12 @@ # with this program; if not, see . from datetime import datetime -import sys import traceback from lava_dispatcher.actions import BaseAction from lava_dispatcher.client import OperationFailed from lava_dispatcher.config import LAVA_RESULT_DIR, MASTER_STR + def _setup_testrootfs(client): #Make sure in master image #, or exception can be caught and do boot_master_image() @@ -44,6 +44,7 @@ # (/dev/pts not mounted?), does not work client.run_cmd_master('mount --rbind /dev /mnt/root/dev') + def _teardown_testrootfs(client): client.run_cmd_master( 'cp -f /mnt/root/etc/resolv.conf.bak /mnt/root/etc/resolv.conf') @@ -54,6 +55,7 @@ client.run_cmd_master( 'umount /mnt/root') + def _install_lava_test(client): #install bazaar in tester image client.run_cmd_master( @@ -78,6 +80,7 @@ _teardown_testrootfs(client) raise OperationFailed("lava-test deployment failed") + class cmd_lava_test_run(BaseAction): def run(self, test_name, timeout=-1): #Make sure in test image now @@ -119,6 +122,7 @@ _teardown_testrootfs(client) + class cmd_add_apt_repository(BaseAction): """ add apt repository to test image rootfs by chroot @@ -127,7 +131,7 @@ def run(self, arg): client = self.client _setup_testrootfs(client) - + #install add-apt-repository client.run_cmd_master('chroot /mnt/root apt-get -y install python-software-properties') @@ -136,5 +140,3 @@ client.run_cmd_master('chroot /mnt/root apt-get update') _teardown_testrootfs(client) - - === modified file 'lava_dispatcher/android_client.py' --- lava_dispatcher/android_client.py 2011-09-02 03:27:41 +0000 +++ lava_dispatcher/android_client.py 2011-09-08 04:23:59 +0000 @@ -109,7 +109,7 @@ network_interface = self.board.default_network_interface try: self.run_cmd_tester( - 'netcfg %s dhcp' % network_interface, timeout = 60) + 'netcfg %s dhcp' % network_interface, timeout=60) except: print "netcfg %s dhcp exception" % network_interface return False @@ -120,7 +120,7 @@ self.proc.sendline('') self.proc.sendline(cmd) try: - id = self.proc.expect([ip_pattern, pexpect.EOF], timeout = 60) + id = self.proc.expect([ip_pattern, pexpect.EOF], timeout=60) except: print "ifconfig can not match ip pattern" return False === modified file 'lava_dispatcher/client.py' --- lava_dispatcher/client.py 2011-09-06 09:36:46 +0000 +++ lava_dispatcher/client.py 2011-09-08 04:23:59 +0000 @@ -45,13 +45,13 @@ self.board = BOARDS[hostname] @property - def master_str(self): + def master_str(self): return self._master_str - + @property - def tester_str(self): + def tester_str(self): return self._tester_str - + def in_master_shell(self): """ Check that we are in a shell on the master image """ @@ -176,6 +176,7 @@ def get_seriallog(self): return self.sio.getvalue() + class SerialIO(file): def __init__(self, logfile): self.serialio = StringIO() @@ -195,27 +196,32 @@ def getvalue(self): return self.serialio.getvalue() + class DispatcherError(Exception): """ Base exception and error class for dispatcher """ + class CriticalError(DispatcherError): """ The critical error """ + class GeneralError(DispatcherError): """ The non-critical error """ + class NetworkError(CriticalError): """ This is used when a network error occurs, such as failing to bring up the network interface on the client """ + class OperationFailed(GeneralError): pass