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
This commit is contained in:
Peter Razumovsky 2016-08-16 14:40:11 +03:00 committed by Sergey Kraynev
parent 93afb9cc40
commit 0ff37ff859

View File

@ -13,15 +13,18 @@
import argparse
import re
import six
import sys
from oslo_log import log
import six
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__}