def _find_check_plugins(checktype): # type: (CheckPluginName) -> List[str] """Find files to be included in precompile host check for a certain check (for example df or mem.used). In case of checks with a period (subchecks) we might have to include both "mem" and "mem.used". The subcheck *may* be implemented in a separate file.""" if '.' in checktype: candidates = [ cmk.base.check_utils.section_name_of(checktype), checktype ] else: candidates = [checktype] paths = [] for candidate in candidates: local_file_path = cmk.utils.paths.local_checks_dir / candidate if local_file_path.exists(): paths.append(str(local_file_path)) continue filename = cmk.utils.paths.checks_dir + "/" + candidate if os.path.exists(filename): paths.append(filename) return paths
def _localize_sniff() -> None: """Dig into the source code and generate a new .pot file""" logger.info("Sniffing source code...") paths = [ cmk.utils.paths.default_config_dir, cmk.utils.paths.web_dir + "/app", cmk.utils.paths.lib_dir + "/python/cmk", ] if cmk.utils.paths.local_web_dir.exists(): paths.append(str(cmk.utils.paths.local_web_dir)) sniff_files = [] for path in paths: for root, _dirs, files in os.walk(path): for f in files: if f.endswith(".py") or f.endswith(".mk"): sniff_files.append(os.path.join(root, f)) if (subprocess.call( [ "xgettext", "--no-wrap", "--sort-output", "--force-po", "-L", "Python", "--from-code=utf-8", "--omit-header", "-o", _pot_file(), *sniff_files, ], stdout=subprocess.DEVNULL, ) != 0): logger.error("Failed!\n") else: header = r"""# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2 # This file is part of Checkmk (https://checkmk.com). It is subject to the terms and # conditions defined in the file COPYING, which is part of this source code package. msgid "" msgstr "" "Project-Id-Version: Checkmk user interface translation 0.1\n" "Report-Msgid-Bugs-To: [email protected]\n" "POT-Creation-Date: 2011-05-13 09:42+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <*****@*****.**>\n" "Language: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" """ _pot_file().write_text(header + _pot_file().read_text()) logger.info("Success! Output: %s", _pot_file())
def _find_check_plugins(checktype): if '.' in checktype: candidates = [cmk_base.check_utils.section_name_of(checktype), checktype] else: candidates = [checktype] paths = [] for candidate in candidates: local_file_path = cmk.utils.paths.local_checks_dir / candidate if local_file_path.exists(): paths.append(str(local_file_path)) continue filename = cmk.utils.paths.checks_dir + "/" + candidate if os.path.exists(filename): paths.append(filename) return paths
def _localize_sniff(): logger.info('Sniffing source code...') paths = [ cmk.utils.paths.default_config_dir, cmk.utils.paths.web_dir + "/app", cmk.utils.paths.lib_dir + "/python/cmk", ] if cmk.utils.paths.local_web_dir.exists(): paths.append(str(cmk.utils.paths.local_web_dir)) sniff_files = [] for path in paths: for root, _dirs, files in os.walk(path): for f in files: if f.endswith(".py") or f.endswith(".mk"): sniff_files.append(os.path.join(root, f)) if subprocess.call([ 'xgettext', '--no-wrap', '--sort-output', '--force-po', '-L', 'Python', '--from-code=utf-8', '--omit-header', '-o', _pot_file() ] + sniff_files, stdout=open(os.devnull, "wb")) != 0: logger.error('Failed!\n') else: header = r'''# +------------------------------------------------------------------+ # | ____ _ _ __ __ _ __ | # | / ___| |__ ___ ___| | __ | \/ | |/ / | # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | # | | |___| | | | __/ (__| < | | | | . \ | # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | # | | # | Copyright Mathias Kettner 2010 [email protected] | # +------------------------------------------------------------------+ # # This file is part of Check_MK. # The official homepage is at http://mathias-kettner.de/check_mk. # # check_mk is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation in version 2. check_mk is distributed # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. See the GNU General Public License for more de- # tails. You should have received a copy of the GNU General Public # License along with GNU Make; see the file COPYING. If not, write # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA. msgid "" msgstr "" "Project-Id-Version: Check_MK Multisite translation 0.1\n" "Report-Msgid-Bugs-To: [email protected]\n" "POT-Creation-Date: 2011-05-13 09:42+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <*****@*****.**>\n" "Language: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" ''' f = open(_pot_file()).read() open(_pot_file(), 'w').write(header + f) logger.info('Success! Output: %s', _pot_file())