View | Details | Raw Unified | Return to bug 38974 | Differences between
and this patch

Collapse All | Expand All

(-)a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/plugins/sources_list_check.py (-2 / +93 lines)
Line 0    Link Here 
0
- 
1
#!/usr/bin/python2.7
2
# coding: utf-8
3
#
4
# Univention Management Console module:
5
#  System Diagnosis UMC module
6
#
7
# Copyright 2017 Univention GmbH
8
#
9
# http://www.univention.de/
10
#
11
# All rights reserved.
12
#
13
# The source code of this program is made available
14
# under the terms of the GNU Affero General Public License version 3
15
# (GNU AGPL V3) as published by the Free Software Foundation.
16
#
17
# Binary versions of this program provided by Univention to you as
18
# well as other copyrighted, protected or trademarked materials like
19
# Logos, graphics, fonts, specific documentations and configurations,
20
# cryptographic keys etc. are subject to a license agreement between
21
# you and Univention and not subject to the GNU AGPL V3.
22
#
23
# In the case you use this program under the terms of the GNU AGPL V3,
24
# the program is provided in the hope that it will be useful,
25
# but WITHOUT ANY WARRANTY; without even the implied warranty of
26
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
# GNU Affero General Public License for more details.
28
#
29
# You should have received a copy of the GNU Affero General Public
30
# License with the Debian GNU/Linux or Univention distribution in file
31
# /usr/share/common-licenses/AGPL-3; if not, see
32
# <http://www.gnu.org/licenses/>.
33
34
import re
35
import glob
36
37
from univention.management.console.modules.diagnostic import Warning
38
39
from univention.lib.i18n import Translation
40
_ = Translation('univention-management-console-module-diagnostic').translate
41
42
title = _('Check errors in sources.list files')
43
description = _('All files ok.')
44
45
46
TRACEBACK_REGEX = re.compile((
47
	'#\s+Traceback \(most recent call last\):\n'  # start of exception
48
	'(?:.*\n)+?'                                  # irrelevant lines of detail
49
	'#\s+raise (?P<exception>\w+).*\n'            # `raise` line to exctract the exception class
50
	'#\s+(?P=exception): (?P<message>.*)\n'))     # extract exception message
51
52
53
IGNORED_EXCEPTIONS = set()
54
55
56
class TracebackFound(Exception):
57
	def __init__(self, path, exception, message):
58
		super(TracebackFound, self).__init__(path, exception, message)
59
		self.path = path
60
		self.exception = exception
61
		self.message = message
62
63
	def __str__(self):
64
		msg = _('Found exception in {path!r}: {exception} - {message}')
65
		return msg.format(path=self.path, exception=self.exception, message=self.message)
66
67
68
def find_tracebacks(path):
69
	with open(path) as fob:
70
		content = fob.read()
71
		for match in TRACEBACK_REGEX.finditer(content):
72
			yield (match.group('exception'), match.group('message'))
73
74
75
def check_for_tracebacks():
76
	for path in glob.iglob('/etc/apt/sources.list.d/*'):
77
		for (exception, message) in find_tracebacks(path):
78
			yield TracebackFound(path, exception, message)
79
80
81
def run():
82
	exceptions = (exc for exc in check_for_tracebacks()
83
		if exc.exception not in IGNORED_EXCEPTIONS)
84
85
	error_descriptions = [str(exc) for exc in exceptions]
86
	if error_descriptions:
87
		error_descriptions.append(_('Please check the files for more details.'))
88
		raise Warning(description='\n'.join(error_descriptions))
89
90
91
if __name__ == '__main__':
92
	from univention.management.console.modules.diagnostic import main
93
	main()
1
sources_list_check.py (po)
94
sources_list_check.py (po)
2
--
3
.../umc/python/diagnostic/de.po                      | 20 ++++++++++++++++++--
95
.../umc/python/diagnostic/de.po                      | 20 ++++++++++++++++++--
4
1 file changed, 18 insertions(+), 2 deletions(-)
96
1 file changed, 18 insertions(+), 2 deletions(-)
(-)a/management/univention-management-console-module-diagnostic/umc/python/diagnostic/de.po (-3 / +18 lines)
 Lines 2-9    Link Here 
2
msgid ""
2
msgid ""
3
msgstr ""
3
msgstr ""
4
"Project-Id-Version: univention-management-console-module-diagnostic\n"
4
"Project-Id-Version: univention-management-console-module-diagnostic\n"
5
"Report-Msgid-Bugs-To: packages@univention.de\n"
5
"Report-Msgid-Bugs-To: \n"
6
"POT-Creation-Date: 2016-01-14 12:19+0100\n"
6
"POT-Creation-Date: 2017-06-13 16:03+0200\n"
7
"PO-Revision-Date: \n"
7
"PO-Revision-Date: \n"
8
"Last-Translator: Univention GmbH <packages@univention.de>\n"
8
"Last-Translator: Univention GmbH <packages@univention.de>\n"
9
"Language-Team: Univention GmbH <packages@univention.de>\n"
9
"Language-Team: Univention GmbH <packages@univention.de>\n"
 Lines 27-32   msgstr "" Link Here 
27
msgid "Adjust to suggested limits"
27
msgid "Adjust to suggested limits"
28
msgstr "An vorgeschlagene Limits anpassen"
28
msgstr "An vorgeschlagene Limits anpassen"
29
29
30
#: umc/python/diagnostic/plugins/sources_list_check.py:43
31
msgid "All files ok."
32
msgstr "Alle Dateien in Ordnung."
33
34
#: umc/python/diagnostic/plugins/sources_list_check.py:42
35
msgid "Check errors in sources.list files"
36
msgstr "Überprüfe Fehler in den sources.list Dateien"
37
38
#: umc/python/diagnostic/plugins/sources_list_check.py:64
39
msgid "Found exception in {path!r}: {exception} - {message}"
40
msgstr "Fehler in {path!r} gefunden: {exception} - {message}"
41
30
#: umc/python/diagnostic/plugins/gateway.py:11
42
#: umc/python/diagnostic/plugins/gateway.py:11
31
msgid "Gateway is not reachable"
43
msgid "Gateway is not reachable"
32
msgstr "Gateway ist nicht erreichbar"
44
msgstr "Gateway ist nicht erreichbar"
 Lines 108-113   msgstr "" Link Here 
108
"Bitte prüfen Sie /var/log/auth.log auf dem entfernten Rechner für weitere "
120
"Bitte prüfen Sie /var/log/auth.log auf dem entfernten Rechner für weitere "
109
"Informationen."
121
"Informationen."
110
122
123
#: umc/python/diagnostic/plugins/sources_list_check.py:87
124
msgid "Please check the files for more details."
125
msgstr "Überprüfen Sie die Dateine für mehr Details."
126
111
#: umc/python/diagnostic/plugins/nameserver.py:16
127
#: umc/python/diagnostic/plugins/nameserver.py:16
112
msgid ""
128
msgid ""
113
"Please make sure the DNS settings in the {setup:network} are correctly set "
129
"Please make sure the DNS settings in the {setup:network} are correctly set "
114
- 

Return to bug 38974