Refactoring: Changed remaining check parameters starting with an 's' to the new rules...
[check_mk.git] / cmk / __init__.py
blob7ece2fae8c2a4e27f886cfa0971c15661cf4242b
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
26 """Check_MK's library for code used by different components of Check_MK.
28 This library is currently handled as internal module of Check_MK and
29 does not offer stable APIs. The code may change at any time."""
31 __version__ = "1.6.0i1"
33 import os
35 import cmk.utils.paths
36 from cmk.utils.exceptions import MKGeneralException
37 from cmk.utils.i18n import _
40 def omd_version():
41 return os.path.basename(os.readlink(cmk.utils.paths.omd_root + "/version"))
44 def omd_site():
45 try:
46 return os.environ["OMD_SITE"]
47 except KeyError:
48 raise MKGeneralException(
49 _("OMD_SITE environment variable not set. You can "
50 "only execute this in an OMD site."))
53 def edition_short():
54 """Can currently either return \"cre\" or \"cee\"."""
55 parts = omd_version().split(".")
56 if parts[-1] == "demo":
57 return parts[-2]
59 return parts[-1]
62 def is_enterprise_edition():
63 return edition_short() == "cee"
66 def is_raw_edition():
67 return edition_short() == "cre"
70 def is_managed_edition():
71 return edition_short() == "cme"
74 def is_demo():
75 parts = omd_version().split(".")
76 return parts[-1] == "demo"