-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch: refs/heads/master Date: 2017-05-19T11:05:40+02:00 Author: Jens W. Klein (jensens) <[email protected]> Commit: plone/plone.namedfile@8944f61 reduce logging level Files changed: M CHANGES.rst M plone/namedfile/utils/__init__.py Repository: plone.namedfile Branch: refs/heads/master Date: 2017-05-19T14:13:30+02:00 Author: Robert Niederreiter (rnixx) <[email protected]> Commit: plone/plone.namedfile@4854127 Merge pull request #50 from plone/jensens-fix-logging reduce logging level Files changed: M CHANGES.rst M plone/namedfile/utils/__init__.py
- Loading branch information
Showing
1 changed file
with
67 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,132 +1,106 @@ | ||
Repository: plone.autoform | ||
Repository: plone.namedfile | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2017-05-17T12:07:23+02:00 | ||
Date: 2017-05-19T11:05:40+02:00 | ||
Author: Jens W. Klein (jensens) <[email protected]> | ||
Commit: https://github.com/plone/plone.autoform/commit/cabd75ff2ba1185b953180b2694f8870e3a07832 | ||
Commit: https://github.com/plone/plone.namedfile/commit/8944f614ee13fed5532a0eb81825813696b85f58 | ||
|
||
Reduce field move failure logging from error to warning | ||
reduce logging level | ||
|
||
Files changed: | ||
M CHANGES.rst | ||
M plone/autoform/base.py | ||
M plone/namedfile/utils/__init__.py | ||
|
||
diff --git a/CHANGES.rst b/CHANGES.rst | ||
index 99c79ca..eb0e37f 100644 | ||
index 137cdad..b52c670 100644 | ||
--- a/CHANGES.rst | ||
+++ b/CHANGES.rst | ||
@@ -14,6 +14,10 @@ New features: | ||
@@ -23,6 +23,9 @@ Bug fixes: | ||
- Fix bug on Image rotation if ImageIFD.XResolution or ImageIFD.YResolution are not set. | ||
[loechel] | ||
|
||
Bug fixes: | ||
|
||
+- Reduce field move failure logging from error to warning. | ||
+ Log more information like full rule. | ||
+- Fix: Do not log failing PIL image regognition as error, but as warning. | ||
+ [jensens] | ||
+ | ||
- Fix traceback in updateFieldsFromSchemata for forms with no schema. | ||
[davisagli] | ||
|
||
diff --git a/plone/autoform/base.py b/plone/autoform/base.py | ||
index e20ba54..7addd53 100644 | ||
--- a/plone/autoform/base.py | ||
+++ b/plone/autoform/base.py | ||
@@ -241,15 +241,21 @@ def _process_field_moves(self, rules): | ||
) | ||
try: | ||
move(self, name, before=before, after=after, prefix=prefix) | ||
- except KeyError: | ||
- # The relative_to field doesn't exist | ||
- logger.exception( | ||
- 'No field move possible for non-existing field named ' | ||
- '{0} with target {1}'.format( | ||
- prefix + '.' + name, | ||
- before or after | ||
+ except KeyError as e: | ||
+ if ( | ||
+ e.message.startswith('Field ') and | ||
+ e.message.endswith(' not found') | ||
+ ): | ||
+ # The relative_to field doesn't exist | ||
+ logger.warning( | ||
+ 'Field move to non-existing: ' | ||
+ 'field name: {0}, rule: {1}'.format( | ||
+ prefix + '.' + name, | ||
+ str(rule) | ||
+ ) | ||
) | ||
- ) | ||
+ else: | ||
+ raise | ||
self._process_field_moves(rule.get('with', {})) | ||
4.2.0 (2017-03-26) | ||
------------------ | ||
diff --git a/plone/namedfile/utils/__init__.py b/plone/namedfile/utils/__init__.py | ||
index 2ec9a8c..7ce3350 100644 | ||
--- a/plone/namedfile/utils/__init__.py | ||
+++ b/plone/namedfile/utils/__init__.py | ||
@@ -141,11 +141,14 @@ def getImageInfo(data): | ||
img = PIL.Image.open(StringIO(data)) | ||
width, height = img.size | ||
content_type = img.format | ||
- except Exception as e: | ||
+ except Exception: | ||
# TODO: determ wich error really happens | ||
# Should happen if data is to short --> first_bytes | ||
- log.error(e) | ||
- # return 'image/jpeg', -1, -1 | ||
+ # happens also if data is an svg or another special format. | ||
+ log.warn( | ||
+ 'PIL can not recognize the image. ' | ||
+ 'Image is probably broken or of a non-supported format.' | ||
+ ) | ||
|
||
def _process_group_order(self): | ||
log.debug('Image Info (Type: %s, Width: %s, Height: %s)', | ||
content_type, width, height) | ||
|
||
|
||
Repository: plone.autoform | ||
Repository: plone.namedfile | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2017-05-17T12:19:28+02:00 | ||
Date: 2017-05-19T14:13:30+02:00 | ||
Author: Robert Niederreiter (rnixx) <[email protected]> | ||
Commit: https://github.com/plone/plone.autoform/commit/84494fd0772107dd3c43474479479e4c61faf659 | ||
Commit: https://github.com/plone/plone.namedfile/commit/48541276399d7b0fc6aeceb59ba8c391ff56fbbe | ||
|
||
Merge pull request #27 from plone/jensens-fieldmovelogging | ||
Merge pull request #50 from plone/jensens-fix-logging | ||
|
||
Reduce field move failure logging from error to warning | ||
reduce logging level | ||
|
||
Files changed: | ||
M CHANGES.rst | ||
M plone/autoform/base.py | ||
M plone/namedfile/utils/__init__.py | ||
|
||
diff --git a/CHANGES.rst b/CHANGES.rst | ||
index 99c79ca..eb0e37f 100644 | ||
index 137cdad..b52c670 100644 | ||
--- a/CHANGES.rst | ||
+++ b/CHANGES.rst | ||
@@ -14,6 +14,10 @@ New features: | ||
|
||
Bug fixes: | ||
@@ -23,6 +23,9 @@ Bug fixes: | ||
- Fix bug on Image rotation if ImageIFD.XResolution or ImageIFD.YResolution are not set. | ||
[loechel] | ||
|
||
+- Reduce field move failure logging from error to warning. | ||
+ Log more information like full rule. | ||
+- Fix: Do not log failing PIL image regognition as error, but as warning. | ||
+ [jensens] | ||
+ | ||
- Fix traceback in updateFieldsFromSchemata for forms with no schema. | ||
[davisagli] | ||
|
||
diff --git a/plone/autoform/base.py b/plone/autoform/base.py | ||
index e20ba54..7addd53 100644 | ||
--- a/plone/autoform/base.py | ||
+++ b/plone/autoform/base.py | ||
@@ -241,15 +241,21 @@ def _process_field_moves(self, rules): | ||
) | ||
try: | ||
move(self, name, before=before, after=after, prefix=prefix) | ||
- except KeyError: | ||
- # The relative_to field doesn't exist | ||
- logger.exception( | ||
- 'No field move possible for non-existing field named ' | ||
- '{0} with target {1}'.format( | ||
- prefix + '.' + name, | ||
- before or after | ||
+ except KeyError as e: | ||
+ if ( | ||
+ e.message.startswith('Field ') and | ||
+ e.message.endswith(' not found') | ||
+ ): | ||
+ # The relative_to field doesn't exist | ||
+ logger.warning( | ||
+ 'Field move to non-existing: ' | ||
+ 'field name: {0}, rule: {1}'.format( | ||
+ prefix + '.' + name, | ||
+ str(rule) | ||
+ ) | ||
) | ||
- ) | ||
+ else: | ||
+ raise | ||
self._process_field_moves(rule.get('with', {})) | ||
4.2.0 (2017-03-26) | ||
------------------ | ||
diff --git a/plone/namedfile/utils/__init__.py b/plone/namedfile/utils/__init__.py | ||
index 2ec9a8c..7ce3350 100644 | ||
--- a/plone/namedfile/utils/__init__.py | ||
+++ b/plone/namedfile/utils/__init__.py | ||
@@ -141,11 +141,14 @@ def getImageInfo(data): | ||
img = PIL.Image.open(StringIO(data)) | ||
width, height = img.size | ||
content_type = img.format | ||
- except Exception as e: | ||
+ except Exception: | ||
# TODO: determ wich error really happens | ||
# Should happen if data is to short --> first_bytes | ||
- log.error(e) | ||
- # return 'image/jpeg', -1, -1 | ||
+ # happens also if data is an svg or another special format. | ||
+ log.warn( | ||
+ 'PIL can not recognize the image. ' | ||
+ 'Image is probably broken or of a non-supported format.' | ||
+ ) | ||
|
||
def _process_group_order(self): | ||
log.debug('Image Info (Type: %s, Width: %s, Height: %s)', | ||
content_type, width, height) | ||
|
||
|