From patchwork Wed Nov 21 22:09:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Doan X-Patchwork-Id: 13044 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 47ED323FC2 for ; Wed, 21 Nov 2012 22:09:18 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id C5A93A19D0E for ; Wed, 21 Nov 2012 22:09:17 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id t4so2792067iag.11 for ; Wed, 21 Nov 2012 14:09:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=M1bSCVYj9MffBU0FGBleozlt4E7jIo8tyqnaLB7DyqA=; b=X1DOHp1evUaY2L6loUxUs3Zxa0mtjtLIZpTos4OpHAiwX9YvcAC9bVfuS/JYhiSzhj jM/a+aPgZdiDqbFX73onGRX4FdE1L6vmfSBZnwQGugSnlIsig5K0LnsY5qB0Ig77UoEJ X2azlLZW01J69O2TXG1/kP5WYSxhgajhusRuO7ZkpU3YRCJYd5RtDRF1kI/MwtWLaUUI d/zVDiOUCXMDMuqDsROu1bt9BWj0RmVSgIVWRa+05tGBFTWjA3Qim0JuXp72AV1bhsRX aIR9IHYailHGsM5yTQvrUGtqZ+XaZf3Izoip0P6lQYPlPlMsElvO1OfN7k53NHoEaBuy DkzA== Received: by 10.50.42.168 with SMTP id p8mr992707igl.57.1353535756959; Wed, 21 Nov 2012 14:09:16 -0800 (PST) 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.50.67.148 with SMTP id n20csp112134igt; Wed, 21 Nov 2012 14:09:15 -0800 (PST) Received: by 10.180.74.108 with SMTP id s12mr1447434wiv.12.1353535755155; Wed, 21 Nov 2012 14:09:15 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id z5si843262wep.48.2012.11.21.14.09.13 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 21 Nov 2012 14:09:14 -0800 (PST) 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 1TbITo-0001X1-Lb for ; Wed, 21 Nov 2012 22:09:12 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 91F73E00B1 for ; Wed, 21 Nov 2012 22:09: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: 461 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 461: relocate error classes Message-Id: <20121121220912.30348.14894.launchpad@ackee.canonical.com> Date: Wed, 21 Nov 2012 22:09: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="16293"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 851309ac233ebcd8593e3962511964514ef37678 X-Gm-Message-State: ALoCoQnjApIt7QS4CjRnC4tmRP8Za1rA3zxQnFZxXeB5TrQ5smz/fohV4ibctX9e1AWbkDrwhIX8 Merge authors: Andy Doan (doanac) Related merge proposals: https://code.launchpad.net/~doanac/lava-dispatcher/error-refactor/+merge/135253 proposed by: Andy Doan (doanac) ------------------------------------------------------------ revno: 461 [merge] committer: Andy Doan branch nick: lava-dispatcher timestamp: Wed 2012-11-21 16:07:45 -0600 message: relocate error classes added: lava_dispatcher/errors.py modified: lava_dispatcher/actions/boot_control.py lava_dispatcher/actions/launch_control.py lava_dispatcher/actions/lava_android_test.py lava_dispatcher/actions/lava_test.py lava_dispatcher/client/base.py lava_dispatcher/client/targetdevice.py lava_dispatcher/device/master.py lava_dispatcher/downloader.py lava_dispatcher/job.py lava_dispatcher/utils.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/actions/boot_control.py' --- lava_dispatcher/actions/boot_control.py 2012-11-14 16:31:18 +0000 +++ lava_dispatcher/actions/boot_control.py 2012-11-20 21:22:17 +0000 @@ -23,7 +23,7 @@ import logging from lava_dispatcher.actions import BaseAction, null_or_empty_schema -from lava_dispatcher.client.base import CriticalError +from lava_dispatcher.errors import CriticalError _boot_schema = { 'type': 'object', @@ -34,6 +34,7 @@ 'additionalProperties': False, } + class cmd_boot_linaro_android_image(BaseAction): """ Call client code to boot to the master image """ @@ -49,6 +50,7 @@ logging.exception("boot_linaro_android_image failed: %s" % e) raise CriticalError("Failed to boot test image.") + class cmd_boot_linaro_image(BaseAction): """ Call client code to boot to the test image """ === modified file 'lava_dispatcher/actions/launch_control.py' --- lava_dispatcher/actions/launch_control.py 2012-11-19 20:32:14 +0000 +++ lava_dispatcher/actions/launch_control.py 2012-11-20 21:22:17 +0000 @@ -31,7 +31,7 @@ from linaro_dashboard_bundle.evolution import DocumentEvolution from lava_dispatcher.actions import BaseAction -from lava_dispatcher.client.base import OperationFailed +from lava_dispatcher.errors import OperationFailed from lava_dispatcher.test_data import create_attachment import lava_dispatcher.utils as utils === modified file 'lava_dispatcher/actions/lava_android_test.py' --- lava_dispatcher/actions/lava_android_test.py 2012-10-24 01:15:37 +0000 +++ lava_dispatcher/actions/lava_android_test.py 2012-11-20 21:22:17 +0000 @@ -23,7 +23,7 @@ import subprocess import logging from lava_dispatcher.actions import BaseAction -from lava_dispatcher.client.base import OperationFailed, TimeoutError +from lava_dispatcher.errors import OperationFailed, TimeoutError from lava_dispatcher.utils import generate_bundle_file_name === modified file 'lava_dispatcher/actions/lava_test.py' --- lava_dispatcher/actions/lava_test.py 2012-11-15 21:23:20 +0000 +++ lava_dispatcher/actions/lava_test.py 2012-11-20 21:22:17 +0000 @@ -23,7 +23,7 @@ import logging from lava_dispatcher.actions import BaseAction -from lava_dispatcher.client.base import OperationFailed +from lava_dispatcher.errors import OperationFailed from lava_dispatcher.utils import generate_bundle_file_name === modified file 'lava_dispatcher/client/base.py' --- lava_dispatcher/client/base.py 2012-10-31 15:33:04 +0000 +++ lava_dispatcher/client/base.py 2012-11-20 21:22:17 +0000 @@ -31,6 +31,11 @@ from cStringIO import StringIO +from lava_dispatcher.errors import ( + GeneralError, + NetworkError, + OperationFailed, +) from lava_dispatcher.test_data import create_attachment @@ -488,40 +493,3 @@ def getvalue(self): return self.serialio.getvalue() - - -class DispatcherError(Exception): - """ - Base exception and error class for dispatcher - """ - - -class TimeoutError(DispatcherError): - """ - The timeout error - """ - - -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): - """ - The exception throws when a file system or system operation fails. - """ === modified file 'lava_dispatcher/client/targetdevice.py' --- lava_dispatcher/client/targetdevice.py 2012-11-20 13:34:19 +0000 +++ lava_dispatcher/client/targetdevice.py 2012-11-21 22:07:45 +0000 @@ -18,22 +18,23 @@ # along # with this program; if not, see . -import contextlib import logging import os import time +from lava_dispatcher.errors import ( + CriticalError, +) from lava_dispatcher.client.base import ( - CriticalError, LavaClient, - ) +) from lava_dispatcher.device.target import ( get_target, - ) +) from lava_dispatcher.utils import ( mk_targz, logging_system, - ) +) class TargetBasedClient(LavaClient): === modified file 'lava_dispatcher/device/master.py' --- lava_dispatcher/device/master.py 2012-11-20 13:34:19 +0000 +++ lava_dispatcher/device/master.py 2012-11-21 22:07:45 +0000 @@ -32,29 +32,31 @@ import lava_dispatcher.device.boot_options as boot_options import lava_dispatcher.tarballcache as tarballcache +from lava_dispatcher.client.base import ( + NetworkCommandRunner, +) from lava_dispatcher.device.target import ( Target - ) +) from lava_dispatcher.downloader import ( download_image, download_with_retry, - ) +) +from lava_dispatcher.errors import ( + NetworkError, + CriticalError, + OperationFailed, +) from lava_dispatcher.utils import ( logging_spawn, logging_system, mk_targz, string_to_list, - ) -from lava_dispatcher.client.base import ( - NetworkError, - CriticalError, - NetworkCommandRunner, - OperationFailed, - ) +) from lava_dispatcher.client.lmc_utils import ( generate_image, image_partition_mounted, - ) +) class MasterImageTarget(Target): === modified file 'lava_dispatcher/downloader.py' --- lava_dispatcher/downloader.py 2012-09-30 17:01:37 +0000 +++ lava_dispatcher/downloader.py 2012-11-20 21:25:42 +0000 @@ -86,14 +86,15 @@ fd = None decompressor = None - fname,suffix = _url_to_fname_suffix(url, imgdir) + fname, suffix = _url_to_fname_suffix(url, imgdir) if suffix == 'gz' and decompress: - decompressor = zlib.decompressobj(16+zlib.MAX_WBITS) + decompressor = zlib.decompressobj(16 + zlib.MAX_WBITS) elif suffix == 'bz2' and decompress: decompressor = bz2.BZ2Decompressor() else: - fname = '%s.%s' % (fname, suffix) #don't remove the file's real suffix + # don't remove the file's real suffix + fname = '%s.%s' % (fname, suffix) def write(buff): if decompressor: @@ -102,7 +103,7 @@ try: fd = open(fname, 'wb') - yield (write,fname) + yield (write, fname) finally: if fd: fd.close @@ -125,7 +126,7 @@ newurl = url with open(mappings, 'r') as f: for line in f.readlines(): - pat,rep = line.split(',') + pat, rep = line.split(',') pat = pat.strip() rep = rep.strip() newurl = re.sub(pat, rep, newurl) === added file 'lava_dispatcher/errors.py' --- lava_dispatcher/errors.py 1970-01-01 00:00:00 +0000 +++ lava_dispatcher/errors.py 2012-11-20 21:22:17 +0000 @@ -0,0 +1,57 @@ +# Copyright (C) 2012 Linaro Limited +# +# Author: Michael Hudson-Doyle +# Author: Paul Larson +# +# This file is part of LAVA Dispatcher. +# +# LAVA Dispatcher is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# LAVA Dispatcher is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along +# with this program; if not, see . + + +class DispatcherError(Exception): + """ + Base exception and error class for dispatcher + """ + + +class TimeoutError(DispatcherError): + """ + The timeout error + """ + + +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): + """ + The exception throws when a file system or system operation fails. + """ === modified file 'lava_dispatcher/job.py' --- lava_dispatcher/job.py 2012-10-08 22:19:31 +0000 +++ lava_dispatcher/job.py 2012-11-20 21:22:17 +0000 @@ -29,9 +29,11 @@ from lava_dispatcher.actions import get_all_cmds from lava_dispatcher.context import LavaContext -from lava_dispatcher.client.base import CriticalError, \ - TimeoutError, \ - GeneralError +from lava_dispatcher.errors import ( + CriticalError, + TimeoutError, + GeneralError, +) job_schema = { === modified file 'lava_dispatcher/utils.py' --- lava_dispatcher/utils.py 2012-11-07 22:19:19 +0000 +++ lava_dispatcher/utils.py 2012-11-20 21:22:17 +0000 @@ -32,6 +32,8 @@ import pexpect +from lava_dispatcher.errors import CriticalError + def link_or_copy_file(src, dest): try: @@ -68,7 +70,6 @@ def mk_targz(tfname, rootdir, basedir='.', asroot=False): """ Similar shutil.make_archive but it doesn't blow up with unicode errors """ - from lava_dispatcher.client.base import CriticalError cmd = 'tar -C %s -czf %s %s' % (rootdir, tfname, basedir) if asroot: cmd = 'sudo %s' % cmd @@ -92,7 +93,6 @@ a list of all the files (full path). This is being used to get around issues that python's tarfile seems to have with unicode """ - from lava_dispatcher.client.base import CriticalError if logging_system('tar -C %s -xzf %s' % (tmpdir, tfname)): raise CriticalError('Unable to extract tarball: %s' % tfname)