=== modified file 'lava_dispatcher/actions/boot_control.py'
@@ -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'
@@ -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'
@@ -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'
@@ -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'
@@ -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'
@@ -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'
@@ -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'
@@ -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'
@@ -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'
@@ -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'
@@ -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)