Statistics
| Branch: | Tag: | Revision:

root / image_creator / __init__.py @ d144e954

History | View | Annotate | Download (2.1 kB)

1 ae48a082 Nikos Skalkotos
# Copyright 2012 GRNET S.A. All rights reserved.
2 d57775d4 Nikos Skalkotos
#
3 d57775d4 Nikos Skalkotos
# Redistribution and use in source and binary forms, with or
4 d57775d4 Nikos Skalkotos
# without modification, are permitted provided that the following
5 d57775d4 Nikos Skalkotos
# conditions are met:
6 d57775d4 Nikos Skalkotos
#
7 d57775d4 Nikos Skalkotos
#   1. Redistributions of source code must retain the above
8 d57775d4 Nikos Skalkotos
#      copyright notice, this list of conditions and the following
9 d57775d4 Nikos Skalkotos
#      disclaimer.
10 d57775d4 Nikos Skalkotos
#
11 d57775d4 Nikos Skalkotos
#   2. Redistributions in binary form must reproduce the above
12 d57775d4 Nikos Skalkotos
#      copyright notice, this list of conditions and the following
13 d57775d4 Nikos Skalkotos
#      disclaimer in the documentation and/or other materials
14 d57775d4 Nikos Skalkotos
#      provided with the distribution.
15 d57775d4 Nikos Skalkotos
#
16 d57775d4 Nikos Skalkotos
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 d57775d4 Nikos Skalkotos
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 d57775d4 Nikos Skalkotos
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 d57775d4 Nikos Skalkotos
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 d57775d4 Nikos Skalkotos
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 d57775d4 Nikos Skalkotos
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 d57775d4 Nikos Skalkotos
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 d57775d4 Nikos Skalkotos
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 d57775d4 Nikos Skalkotos
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 d57775d4 Nikos Skalkotos
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 d57775d4 Nikos Skalkotos
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 d57775d4 Nikos Skalkotos
# POSSIBILITY OF SUCH DAMAGE.
28 d57775d4 Nikos Skalkotos
#
29 d57775d4 Nikos Skalkotos
# The views and conclusions contained in the software and
30 d57775d4 Nikos Skalkotos
# documentation are those of the authors and should not be
31 d57775d4 Nikos Skalkotos
# interpreted as representing official policies, either expressed
32 d57775d4 Nikos Skalkotos
# or implied, of GRNET S.A.
33 d57775d4 Nikos Skalkotos
34 d57775d4 Nikos Skalkotos
__version__ = '0.1'
35 aa2062ba Nikos Skalkotos
36 aa2062ba Nikos Skalkotos
import image_creator.os_type
37 aa2062ba Nikos Skalkotos
38 8c574358 Nikos Skalkotos
39 aa2062ba Nikos Skalkotos
def get_os_class(distro, osfamily):
40 aa2062ba Nikos Skalkotos
    module = None
41 aa2062ba Nikos Skalkotos
    classname = None
42 aa2062ba Nikos Skalkotos
    try:
43 aa2062ba Nikos Skalkotos
        module = __import__("image_creator.os_type.%s"
44 aa2062ba Nikos Skalkotos
            % distro, fromlist=['image_creator.os_type'])
45 aa2062ba Nikos Skalkotos
        classname = distro.capitalize()
46 aa2062ba Nikos Skalkotos
    except ImportError:
47 aa2062ba Nikos Skalkotos
        module = __import__("image_creator.os_type.%s"
48 aa2062ba Nikos Skalkotos
            % osfamily, fromlist=['image_creator.os_type'])
49 aa2062ba Nikos Skalkotos
        classname = osfamily.capitalize()
50 aa2062ba Nikos Skalkotos
51 aa2062ba Nikos Skalkotos
    return getattr(module, classname)
52 aa2062ba Nikos Skalkotos
53 ae48a082 Nikos Skalkotos
54 0ae01e26 Nikos Skalkotos
class FatalError(Exception):
55 0ae01e26 Nikos Skalkotos
    pass
56 aa2062ba Nikos Skalkotos
57 aa2062ba Nikos Skalkotos
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :