[Kimchi-devel] [PATCH 3/6] Move IsoFormatError() from isoinfo.py to exception.py

Royce Lv lvroyce at linux.vnet.ibm.com
Tue Dec 31 02:57:42 UTC 2013


Reviewed-by: Royce Lv<lvroyce at linux.vnet.ibm.com>

On 2013年12月31日 01:09, Aline Manera wrote:
> From: Aline Manera <alinefm at br.ibm.com>
>
> All Kimchi exception should be in exception.py
> So move IsoFormatError() to there and update imports accordingly.
>
> Signed-off-by: Aline Manera <alinefm at br.ibm.com>
> ---
>   src/kimchi/exception.py  |    4 ++++
>   src/kimchi/isoinfo.py    |    5 +----
>   src/kimchi/model.py      |    6 +++---
>   src/kimchi/vmtemplate.py |    4 ++--
>   4 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/src/kimchi/exception.py b/src/kimchi/exception.py
> index d7a2835..8143b05 100644
> --- a/src/kimchi/exception.py
> +++ b/src/kimchi/exception.py
> @@ -34,3 +34,7 @@ class InvalidParameter(Exception):
>
>   class InvalidOperation(Exception):
>       pass
> +
> +
> +class IsoFormatError(Exception):
> +    pass
> diff --git a/src/kimchi/isoinfo.py b/src/kimchi/isoinfo.py
> index 59cdd45..7b7fa78 100644
> --- a/src/kimchi/isoinfo.py
> +++ b/src/kimchi/isoinfo.py
> @@ -28,6 +28,7 @@ import sys
>   import urllib2
>
>
> +from kimchi.exception import IsoFormatError
>   from kimchi.utils import kimchi_log
>
>   iso_dir = [
> @@ -117,10 +118,6 @@ iso_dir = [
>   ]
>
>
> -class IsoFormatError(Exception):
> -    pass
> -
> -
>   class IsoImage(object):
>       """
>       Scan an iso9660 image to extract the Volume ID and check for boot-ability
> diff --git a/src/kimchi/model.py b/src/kimchi/model.py
> index a6790b8..decb889 100644
> --- a/src/kimchi/model.py
> +++ b/src/kimchi/model.py
> @@ -62,8 +62,8 @@ from kimchi import vnc
>   from kimchi import xmlutils
>   from kimchi.asynctask import AsyncTask
>   from kimchi.distroloader import DistroLoader
> -from kimchi.exception import InvalidOperation, InvalidParameter, MissingParameter
> -from kimchi.exception import NotFoundError, OperationFailed
> +from kimchi.exception import InvalidOperation, InvalidParameter, IsoFormatError
> +from kimchi.exception import MissingParameter, NotFoundError, OperationFailed
>   from kimchi.featuretests import FeatureTests
>   from kimchi.networkxml import to_network_xml
>   from kimchi.objectstore import ObjectStore
> @@ -1167,7 +1167,7 @@ class Model(object):
>               try:
>                   os_distro, os_version = isoinfo.probe_one(path)
>                   bootable = True
> -            except isoinfo.IsoFormatError:
> +            except IsoFormatError:
>                   bootable = False
>               res.update(
>                   dict(os_distro=os_distro, os_version=os_version, path=path, bootable=bootable))
> diff --git a/src/kimchi/vmtemplate.py b/src/kimchi/vmtemplate.py
> index dd43faa..8bf3df9 100644
> --- a/src/kimchi/vmtemplate.py
> +++ b/src/kimchi/vmtemplate.py
> @@ -29,7 +29,7 @@ import urlparse
>
>   from kimchi import isoinfo
>   from kimchi import osinfo
> -from kimchi.exception import InvalidParameter
> +from kimchi.exception import InvalidParameter, IsoFormatError
>
>
>   QEMU_NAMESPACE = "xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'"
> @@ -64,7 +64,7 @@ class VMTemplate(object):
>
>               try:
>                   iso_distro, iso_version = isoinfo.probe_one(iso)
> -            except isoinfo.IsoFormatError, e:
> +            except IsoFormatError, e:
>                   raise InvalidParameter(e)
>
>           # Fetch defaults based on the os distro and version




More information about the Kimchi-devel mailing list