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

Sheldon shaohef at linux.vnet.ibm.com
Mon Jan 6 15:23:47 UTC 2014


Reviewed-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>

On 01/06/2014 11:05 PM, 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 df9619f..bff0a18 100644
> --- a/src/kimchi/exception.py
> +++ b/src/kimchi/exception.py
> @@ -39,3 +39,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 121241a..7d919a0 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 a21fcf7..f48f3d3 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.iscsi import TargetClient
>   from kimchi.networkxml import to_network_xml
> @@ -1184,7 +1184,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 5d31f2a..1720384 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


-- 
Thanks and best regards!

Sheldon Feng(冯少合)<shaohef at linux.vnet.ibm.com>
IBM Linux Technology Center




More information about the Kimchi-devel mailing list