@@ -, +, @@
sources_list_check.py
---
.../diagnostic/plugins/sources_list_check.py | 93 ++++++++++++++++++++++
1 file changed, 93 insertions(+)
create mode 100755 management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/sources_list_check.py
--- a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/sources_list_check.py
+++ a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/sources_list_check.py
@@ -0,0 +1,93 @@
+#!/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((
+ '#\s+Traceback \(most recent call last\):\n' # start of exception
+ '(?:.*\n)+?' # irrelevant lines of detail
+ '#\s+raise (?P\w+).*\n' # `raise` line to exctract the exception class
+ '#\s+(?P=exception): (?P.*)\n')) # extract exception message
+
+
+IGNORED_EXCEPTIONS = set()
+
+
+class TracebackFound(Exception):
+ def __init__(self, path, exception, message):
+ super(TracebackFound, self).__init__(path, exception, message)
+ self.path = path
+ self.exception = exception
+ self.message = message
+
+ def __str__(self):
+ msg = _('Found exception in {path!r}: {exception} - {message}')
+ return msg.format(path=self.path, exception=self.exception, message=self.message)
+
+
+def find_tracebacks(path):
+ with open(path) as fob:
+ content = fob.read()
+ for match in TRACEBACK_REGEX.finditer(content):
+ yield (match.group('exception'), match.group('message'))
+
+
+def check_for_tracebacks():
+ for path in glob.iglob('/etc/apt/sources.list.d/*'):
+ for (exception, message) in find_tracebacks(path):
+ yield TracebackFound(path, exception, message)
+
+
+def run():
+ exceptions = (exc for exc in check_for_tracebacks()
+ if exc.exception not in IGNORED_EXCEPTIONS)
+
+ error_descriptions = [str(exc) for exc in exceptions]
+ 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()
--
sources_list_check.py (po)
---
.../umc/python/diagnostic/de.po | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
--- a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po
+++ a/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:03+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:64
+msgid "Found exception in {path!r}: {exception} - {message}"
+msgstr "Fehler in {path!r} gefunden: {exception} - {message}"
+
#: 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:87
+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 "
--