Module: check_mk
Branch: master
Commit: af0c1cd006264a761c5b1ba2411c8605ccfa3788
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=af0c1cd006264a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Dec 1 11:04:53 2016 +0100
4082 FIX Icon selector: Fixed exception in case non images are saved in icon folder
---
.werks/4082 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/valuespec.py | 9 ++++++++-
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/.werks/4082 b/.werks/4082
new file mode 100644
index 0000000..7b58c46
--- /dev/null
+++ b/.werks/4082
@@ -0,0 +1,10 @@
+Title: Icon selector: Fixed exception in case non images are saved in icon folder
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i3
+Date: 1480586351
+
+
diff --git a/ChangeLog b/ChangeLog
index 8896401..0abbb95 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -72,6 +72,7 @@
* 4076 FIX: Git integration: Using mail address of user in author info
* 4077 FIX: Fixed "Request URI too long" when cloning role after editing another one
* 4079 FIX: Improved error handling in case a WATO folder can not be written
+ * 4082 FIX: Icon selector: Fixed exception in case non images are saved in icon folder
Notifications:
* 4042 FIX: Fix missing From address in synchronous SMTP notifications...
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index b15b446..8c22978 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -3931,7 +3931,14 @@ class IconSelector(ValueSpec):
if file_name[-4:] == '.png' and os.path.isfile(file_path):
# extract the category from the meta data
- im = Image.open(file_path)
+ try:
+ im = Image.open(file_path)
+ except IOError, e:
+ if "%s" % e == "cannot identify image file":
+ continue # Silently skip invalid files
+ else:
+ raise
+
category = im.info.get('Comment')
if category not in valid_categories:
category = 'misc'