From 73557d4b7eea1ea6a07e5263ca44664aae92ddbd Mon Sep 17 00:00:00 2001 From: Lukas Oyen Date: Mon, 12 Jun 2017 17:26:27 +0200 Subject: [PATCH 1/2] Bug #38974: umc-diagnostic: new check sources_list_check.py --- .../diagnostic/plugins/sources_list_check.py | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/sources_list_check.py diff --git a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/sources_list_check.py b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/sources_list_check.py new file mode 100755 index 0000000..0889553 --- /dev/null +++ b/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/sources_list_check.py @@ -0,0 +1,85 @@ +#!/usr/bin/python2.7 +# coding: utf-8 +# +# Univention Management Console module: +# System Diagnosis UMC module +# +# Copyright 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, see +# . + +import re +import glob + +from univention.management.console.modules.diagnostic import Warning + +from univention.lib.i18n import Translation +_ = Translation('univention-management-console-module-diagnostic').translate + +title = _('Check errors in sources.list files') +description = _('All files ok.') + + +TRACEBACK_REGEX = re.compile(( + '(?P#\s+)Traceback \(most recent call last\):\n' # start of exception + '(?:(?P=start).*\n)+?' # irrelevant lines of detail + '(?P=start)(?P[^\s].*)\n')) # extract exception + + +class TracebackFound(Exception): + def __init__(self, path, exception): + super(TracebackFound, self).__init__(path, exception) + self.path = path + self.exception = exception + + def __str__(self): + msg = _('Found exception in {path!r}: {exception}') + return msg.format(path=self.path, exception=self.exception) + + +def find_tracebacks(path): + with open(path) as fob: + content = fob.read() + for match in TRACEBACK_REGEX.finditer(content): + yield match.group('exception') + + +def check_for_tracebacks(): + for path in glob.iglob('/etc/apt/sources.list.d/*'): + for exception in find_tracebacks(path): + yield TracebackFound(path, exception) + + +def run(): + error_descriptions = [str(exc) for exc in check_for_tracebacks()] + if error_descriptions: + error_descriptions.append(_('Please check the files for more details.')) + raise Warning(description='\n'.join(error_descriptions)) + + +if __name__ == '__main__': + from univention.management.console.modules.diagnostic import main + main() -- 2.7.4 From 55eab566fe0872cc4cda7e5b5b25de732fa4e74b Mon Sep 17 00:00:00 2001 From: Lukas Oyen Date: Tue, 13 Jun 2017 16:00:27 +0200 Subject: [PATCH 2/2] Bug #38974: umc-diagnostic: new check sources_list_check.py (po) --- .../umc/python/diagnostic/de.po | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 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..9d91cb2 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-13 16:35+0200\n" "PO-Revision-Date: \n" "Last-Translator: Univention GmbH \n" "Language-Team: Univention GmbH \n" @@ -27,6 +27,18 @@ msgstr "" msgid "Adjust to suggested limits" msgstr "An vorgeschlagene Limits anpassen" +#: umc/python/diagnostic/plugins/sources_list_check.py:43 +msgid "All files ok." +msgstr "Alle Dateien in Ordnung." + +#: umc/python/diagnostic/plugins/sources_list_check.py:42 +msgid "Check errors in sources.list files" +msgstr "Überprüfe Fehler in den sources.list Dateien" + +#: umc/python/diagnostic/plugins/sources_list_check.py:59 +msgid "Found exception in {path!r}: {exception}" +msgstr "Fehler in {path!r} gefunden: {exception}" + #: umc/python/diagnostic/plugins/gateway.py:11 msgid "Gateway is not reachable" msgstr "Gateway ist nicht erreichbar" @@ -108,6 +120,10 @@ msgstr "" "Bitte prüfen Sie /var/log/auth.log auf dem entfernten Rechner für weitere " "Informationen." +#: umc/python/diagnostic/plugins/sources_list_check.py:79 +msgid "Please check the files for more details." +msgstr "Überprüfen Sie die Dateine für mehr Details." + #: umc/python/diagnostic/plugins/nameserver.py:16 msgid "" "Please make sure the DNS settings in the {setup:network} are correctly set " -- 2.7.4