From 4e08765f873f14d663e9de36c1b47d5563050d0d Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 19 May 2017 08:42:00 +1000 Subject: [PATCH] Move exception to it's own file (again) Moving the exception didn't cause problems in I925ed62bdc808f0e07862f6e0905e80b50fbe942, but in later changes where we split blockdevice.py up a bit more, we can get a bit tangled with circular imports. Change-Id: I8297483f64c4e1deecd5ec88ee40e9198bb83589 --- diskimage_builder/block_device/blockdevice.py | 6 ++---- diskimage_builder/block_device/exception.py | 15 +++++++++++++++ .../block_device/level0/localloop.py | 2 +- .../block_device/level1/partitioning.py | 2 +- diskimage_builder/block_device/level2/mkfs.py | 2 +- diskimage_builder/block_device/level3/mount.py | 2 +- 6 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 diskimage_builder/block_device/exception.py diff --git a/diskimage_builder/block_device/blockdevice.py b/diskimage_builder/block_device/blockdevice.py index 4d10bb92..0cf44bf4 100644 --- a/diskimage_builder/block_device/blockdevice.py +++ b/diskimage_builder/block_device/blockdevice.py @@ -22,6 +22,8 @@ import yaml from stevedore import extension +from diskimage_builder.block_device.exception import \ + BlockDeviceSetupException from diskimage_builder.block_device.utils import exec_sudo from diskimage_builder.graph.digraph import Digraph @@ -29,10 +31,6 @@ from diskimage_builder.graph.digraph import Digraph logger = logging.getLogger(__name__) -class BlockDeviceSetupException(Exception): - pass - - class BlockDevice(object): """Handles block devices. diff --git a/diskimage_builder/block_device/exception.py b/diskimage_builder/block_device/exception.py new file mode 100644 index 00000000..92dc602a --- /dev/null +++ b/diskimage_builder/block_device/exception.py @@ -0,0 +1,15 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +class BlockDeviceSetupException(Exception): + """Generic exception""" diff --git a/diskimage_builder/block_device/level0/localloop.py b/diskimage_builder/block_device/level0/localloop.py index 4df7af2b..a776ecae 100644 --- a/diskimage_builder/block_device/level0/localloop.py +++ b/diskimage_builder/block_device/level0/localloop.py @@ -16,7 +16,7 @@ import logging import os import subprocess -from diskimage_builder.block_device.blockdevice import \ +from diskimage_builder.block_device.exception import \ BlockDeviceSetupException from diskimage_builder.block_device.tree_config import TreeConfig from diskimage_builder.block_device.utils import parse_abs_size_spec diff --git a/diskimage_builder/block_device/level1/partitioning.py b/diskimage_builder/block_device/level1/partitioning.py index 05114898..6ca11043 100644 --- a/diskimage_builder/block_device/level1/partitioning.py +++ b/diskimage_builder/block_device/level1/partitioning.py @@ -17,7 +17,7 @@ import os from subprocess import CalledProcessError -from diskimage_builder.block_device.blockdevice import \ +from diskimage_builder.block_device.exception import \ BlockDeviceSetupException from diskimage_builder.block_device.level1.mbr import MBR from diskimage_builder.block_device.tree_config import TreeConfig diff --git a/diskimage_builder/block_device/level2/mkfs.py b/diskimage_builder/block_device/level2/mkfs.py index 4ce4cdd2..ba4469c5 100644 --- a/diskimage_builder/block_device/level2/mkfs.py +++ b/diskimage_builder/block_device/level2/mkfs.py @@ -15,7 +15,7 @@ import logging import uuid -from diskimage_builder.block_device.blockdevice \ +from diskimage_builder.block_device.exception \ import BlockDeviceSetupException from diskimage_builder.block_device.tree_config import TreeConfig from diskimage_builder.block_device.utils import exec_sudo diff --git a/diskimage_builder/block_device/level3/mount.py b/diskimage_builder/block_device/level3/mount.py index a0f0e91c..1046f29c 100644 --- a/diskimage_builder/block_device/level3/mount.py +++ b/diskimage_builder/block_device/level3/mount.py @@ -15,7 +15,7 @@ import logging import os -from diskimage_builder.block_device.blockdevice \ +from diskimage_builder.block_device.exception \ import BlockDeviceSetupException from diskimage_builder.block_device.tree_config import TreeConfig from diskimage_builder.block_device.utils import exec_sudo