Module: check_mk
Branch: master
Commit: 9d7d791912e76f2f60d5f7645da3729a933531aa
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9d7d791912e76f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Feb 17 09:16:13 2016 +0100
Fixed invalid exception catching of os.OSError; Fixed broken
literal_eval in Python <2.5
---
web/htdocs/lib.py | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/web/htdocs/lib.py b/web/htdocs/lib.py
index 508944b..1b9d3f1 100644
--- a/web/htdocs/lib.py
+++ b/web/htdocs/lib.py
@@ -120,7 +120,7 @@ def make_nagios_directories(name):
if head and tail and not os.path.exists(head):
try:
make_nagios_directories(head)
- except os.OSError, e:
+ except OSError, e:
# be happy if someone already created the path
if e.errno != errno.EEXIST:
raise
@@ -756,41 +756,39 @@ try:
import ast
literal_eval = ast.literal_eval
except ImportError:
- # python <2.5 compatibility
+ # Python <2.5 compatibility
try:
from compiler import parse
import compiler.ast
def literal_eval(node_or_string):
- _safe_names = {'none': none, 'true': true, 'false':
false}
+ _safe_names = {'None': None, 'True': True, 'False':
False}
if isinstance(node_or_string, basestring):
node_or_string = parse(node_or_string, mode='eval')
- if isinstance(node_or_string, compiler.ast.expression):
+ if isinstance(node_or_string, compiler.ast.Expression):
node_or_string = node_or_string.node
def _convert(node):
- if isinstance(node, compiler.ast.const) and isinstance(node.value,
+ if isinstance(node, compiler.ast.Const) and isinstance(node.value,
(basestring, int, float, long, complex)):
return node.value
- elif isinstance(node, compiler.ast.tuple):
+ elif isinstance(node, compiler.ast.Tuple):
return tuple(map(_convert, node.nodes))
- elif isinstance(node, compiler.ast.list):
+ elif isinstance(node, compiler.ast.List):
return list(map(_convert, node.nodes))
- elif isinstance(node, compiler.ast.dict):
+ elif isinstance(node, compiler.ast.Dict):
return dict((_convert(k), _convert(v)) for k, v
in node.items)
- elif isinstance(node, compiler.ast.name):
+ elif isinstance(node, compiler.ast.Name):
if node.name in _safe_names:
return _safe_names[node.name]
- elif isinstance(node, compiler.ast.unarysub):
+ elif isinstance(node, compiler.ast.UnarySub):
return -_convert(node.expr)
- raise valueerror('malformed string')
+ raise ValueError('malformed string')
return _convert(node_or_string)
except:
- literal_eval = none
-
-
+ literal_eval = None
#.
# .--Various Constants---------------------------------------------------.