From a465363cc4c7539280f90d7e772d2d668fb6e5ff Mon Sep 17 00:00:00 2001 From: Lukas Oyen Date: Tue, 27 Jun 2017 15:23:11 +0200 Subject: [PATCH 1/3] Bug #xxx: umc-diagnostic: new check `check_ucr_templates.py Original `check_blocked_ucr_templates.py written by Julian Hupertz (with slight cleanup). --- .../diagnostic/plugins/check_ucr_templates.py | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_ucr_templates.py diff --git a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_ucr_templates.py b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_ucr_templates.py new file mode 100644 index 0000000..994da1f --- /dev/null +++ b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_ucr_templates.py @@ -0,0 +1,80 @@ +#!/usr/bin/python2.7 +# coding: utf-8 +# +# Univention Management Console module: +# System Diagnosis UMC module +# +# Copyright 2016-2017 Univention GmbH +# +# http://www.univention.de/ +# +# All rights reserved. +# +# The source code of this program is made available +# under the terms of the GNU Affero General Public License version 3 +# (GNU AGPL V3) as published by the Free Software Foundation. +# +# Binary versions of this program provided by Univention to you as +# well as other copyrighted, protected or trademarked materials like +# Logos, graphics, fonts, specific documentations and configurations, +# cryptographic keys etc. are subject to a license agreement between +# you and Univention and not subject to the GNU AGPL V3. +# +# In the case you use this program under the terms of the GNU AGPL V3, +# the program is provided in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License with the Debian GNU/Linux or Univention distribution in file +# /usr/share/common-licenses/AGPL-3; if not, seG +# . + + +from subprocess import Popen, PIPE, STDOUT +from univention.management.console.config import ucr +from univention.management.console.modules.diagnostic import Critical + +from univention.lib.i18n import Translation +_ = Translation('univention-management-console-module-diagnostic').translate + +title = _('Check for blocked ucr templates') +description = _('No problems found with blocked ucr templates') + + +def run(): + ucr.load() + try: + process = Popen(["univention-check-templates"], stdout=PIPE, stderr=STDOUT) + stdout, stderr = process.communicate() + if process.returncode: + description = _("Calling 'univention-check-templates failed") + raise Critical("\n".join([ + description, + "Returncode of process: %s" % (process.returncode), + "stderr: %s" % (stderr) + ])) + if stdout == "": + return + else: + description = _("Error from 'univention-check-templates' returned.") + raise Critical("\n".join([ + description, + "Stdout: %s" % (stdout), + "Stderr: %s" % (stderr) + ])) + except Critical: + raise + except Exception as ex: + description = _("Unknown problem during check of 'univention-check-templates") + raise Critical('\n'.join([ + description, + "Exception-Type: %s" % (ex.__class__), + "Exception-Message: %s" % (ex.message) + ])) + + +if __name__ == '__main__': + from univention.management.console.modules.diagnostic import main + main() -- 2.7.4 From cd5ed008c05b9b1f9ffebd93082f0f629e5874bc Mon Sep 17 00:00:00 2001 From: Lukas Oyen Date: Tue, 27 Jun 2017 15:45:02 +0200 Subject: [PATCH 2/3] Bug #xxx: umc-diagnostic: simplify `check_ucr_templates.py` --- .../diagnostic/plugins/check_ucr_templates.py | 51 ++++++++-------------- 1 file changed, 17 insertions(+), 34 deletions(-) mode change 100644 => 100755 management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_ucr_templates.py diff --git a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_ucr_templates.py b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_ucr_templates.py old mode 100644 new mode 100755 index 994da1f..a6ab806 --- a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_ucr_templates.py +++ b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/check_ucr_templates.py @@ -28,51 +28,34 @@ # # You should have received a copy of the GNU Affero General Public # License with the Debian GNU/Linux or Univention distribution in file -# /usr/share/common-licenses/AGPL-3; if not, seG +# /usr/share/common-licenses/AGPL-3; if not, see # . -from subprocess import Popen, PIPE, STDOUT -from univention.management.console.config import ucr -from univention.management.console.modules.diagnostic import Critical +import subprocess +from univention.management.console.modules.diagnostic import Warning from univention.lib.i18n import Translation _ = Translation('univention-management-console-module-diagnostic').translate -title = _('Check for blocked ucr templates') -description = _('No problems found with blocked ucr templates') +title = _('Check for modified UCR templates') +description = _('No problems found with modified UCR templates') def run(): - ucr.load() + cmd = ['univention-check-templates'] try: - process = Popen(["univention-check-templates"], stdout=PIPE, stderr=STDOUT) - stdout, stderr = process.communicate() - if process.returncode: - description = _("Calling 'univention-check-templates failed") - raise Critical("\n".join([ - description, - "Returncode of process: %s" % (process.returncode), - "stderr: %s" % (stderr) - ])) - if stdout == "": - return - else: - description = _("Error from 'univention-check-templates' returned.") - raise Critical("\n".join([ - description, - "Stdout: %s" % (stdout), - "Stderr: %s" % (stderr) - ])) - except Critical: - raise - except Exception as ex: - description = _("Unknown problem during check of 'univention-check-templates") - raise Critical('\n'.join([ - description, - "Exception-Type: %s" % (ex.__class__), - "Exception-Message: %s" % (ex.message) - ])) + subprocess.check_output(cmd) + except subprocess.CalledProcessError as error: + error_description = [ + _('Errors found by `univention-check-templates`.'), + _('The following UCR files are modified locally.'), + _('Updated versions will be named FILENAME.dpkg-*.'), + _('The files should be checked for differences.'), + ] + if error.output: + error_description.extend(('\n\n', error.output)) + raise Warning(' '.join(error_description)) if __name__ == '__main__': -- 2.7.4 From 6ef12ec5435feaa75f6799aa54a27e346f9e905b Mon Sep 17 00:00:00 2001 From: Lukas Oyen Date: Tue, 27 Jun 2017 16:02:32 +0200 Subject: [PATCH 3/3] Bug #xxx: umc-diagnostic: new `check_ucr_templates.py` (po) --- .../umc/python/diagnostic/de.po | 30 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po index affad86..15e20b7 100644 --- a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po +++ b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: univention-management-console-module-diagnostic\n" -"Report-Msgid-Bugs-To: packages@univention.de\n" -"POT-Creation-Date: 2016-01-14 12:19+0100\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-27 16:21+0200\n" "PO-Revision-Date: \n" "Last-Translator: Univention GmbH \n" "Language-Team: Univention GmbH \n" @@ -27,6 +27,14 @@ msgstr "" msgid "Adjust to suggested limits" msgstr "An vorgeschlagene Limits anpassen" +#: umc/python/diagnostic/plugins/check_ucr_templates.py:41 +msgid "Check for modified UCR templates" +msgstr "Überprüfe veränderte UCR Vorlagen" + +#: umc/python/diagnostic/plugins/check_ucr_templates.py:51 +msgid "Errors found by `univention-check-templates`." +msgstr "Es wurden Fehler durch `univention-check-templates` gefunden." + #: umc/python/diagnostic/plugins/gateway.py:11 msgid "Gateway is not reachable" msgstr "Gateway ist nicht erreichbar" @@ -97,6 +105,10 @@ msgstr "" msgid "Nameserver(s) are not responsive" msgstr "Nameserver sind nicht ansprechbar" +#: umc/python/diagnostic/plugins/check_ucr_templates.py:42 +msgid "No problems found with modified UCR templates" +msgstr "Keine Probleme mit modifizierten UCR Vorlagen gefunden." + #: umc/python/diagnostic/plugins/package_status.py:11 msgid "Package status corrupt" msgstr "Paketstatus korrupt" @@ -141,7 +153,15 @@ msgstr "Sicherheitslimits überschritten" msgid "Test again" msgstr "Erneut testen" -#: umc/python/diagnostic/plugins/ssh_connection.py:48 +#: umc/python/diagnostic/plugins/check_ucr_templates.py:54 +msgid "The files should be checked for differences." +msgstr "Die Dateien sollten auf Unterschiede geprüft werden." + +#: umc/python/diagnostic/plugins/check_ucr_templates.py:52 +msgid "The following UCR files are modified locally." +msgstr "Die folgenden UCR Vorlagen wurden lokal verändert." + +#: umc/python/diagnostic/plugins/ssh_connection.py:52 msgid "" "The following list shows the affected remote servers and the reason for the " "failed ssh connection:" @@ -260,6 +280,10 @@ msgstr "" "dass Authentifikations-Zugangsdaten (falls existierend) korrekt sind und die " "ACL's des Proxy-Servers nicht verbieten, Anfragen an %s zu stellen." +#: umc/python/diagnostic/plugins/check_ucr_templates.py:53 +msgid "Updated versions will be named FILENAME.dpkg-*." +msgstr "Aktualisierte Versionen werden DATEINAME.dpkg-* genannt." + #: umc/python/diagnostic/plugins/package_status.py:28 msgid "some" msgstr "einigen" -- 2.7.4