diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 461: relocate error classes

Message ID 20121121220912.30348.14894.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Andy Doan Nov. 21, 2012, 10:09 p.m. UTC
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 <andy.doan@linaro.org>
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
diff mbox

Patch

=== 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 <http://www.gnu.org/licenses>.
 
-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 <michael.hudson@linaro.org>
+# Author: Paul Larson <paul.larson@linaro.org>
+#
+# 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 <http://www.gnu.org/licenses>.
+
+
+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)