diff options
author | Peter Razumovsky <prazumovsky@mirantis.com> | 2016-08-16 14:40:11 +0300 |
---|---|---|
committer | Sergey Kraynev <skraynev@mirantis.com> | 2016-08-24 09:36:02 +0000 |
commit | 0ff37ff8599edb8208aa23df024dbe9b38a27111 (patch) | |
tree | 2d563e71c9983de8c3b1a0fa381b814dc6494f9c /tools/custom_guidelines.py | |
parent | 93afb9cc4017648f5016056177ea447ecd5f95fd (diff) | |
download | heat-0ff37ff8599edb8208aa23df024dbe9b38a27111.tar.gz |
Don't raise error in custom guidelines on IOError
In some merge issues files or modules can be removed, but
still registered in global env. In that cases custom guidelines
raises an error with the message "No such file or directory".
Add exception handling to avoid error raising. Instead of error,
call warning and skip such class.
Change-Id: I71af2fffc2bdec414cb68c40eaf3268fe81134de
Closes-bug: #1613669
Diffstat (limited to 'tools/custom_guidelines.py')
-rw-r--r-- | tools/custom_guidelines.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/custom_guidelines.py b/tools/custom_guidelines.py index 81e056975..39d39981a 100644 --- a/tools/custom_guidelines.py +++ b/tools/custom_guidelines.py @@ -13,15 +13,18 @@ import argparse import re +import sys +from oslo_log import log import six -import sys from heat.common.i18n import _ +from heat.common.i18n import _LW from heat.engine import constraints from heat.engine import resources from heat.engine import support +LOG = log.getLogger(__name__) class HeatCustomGuidelines(object): @@ -149,7 +152,12 @@ class HeatCustomGuidelines(object): def check_trailing_spaces(self): for cls in self.resources_classes: - cls_file = open(cls.__module__.replace('.', '/') + '.py') + try: + cls_file = open(cls.__module__.replace('.', '/') + '.py') + except IOError as ex: + LOG.warning(_LW('Cannot perform trailing spaces check on ' + 'resource module: %s') % six.text_type(ex)) + continue lines = [line.strip() for line in cls_file.readlines()] idx = 0 kwargs = {'path': cls.__module__} |