Import error consumed - needs to be output

Bug #604880 reported by brad103
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
waferslim
New
Undecided
Unassigned

Bug Description

Troubleshooting tests run using waferslim is made difficult because of the ImportError consumption that currently happens in ExecutionContext of execution.py. We have modified our code version to output the logging.error message as below.

Cheers Tim
Brad

    def get_type(self, fully_qualified_name):
        ''' Get a type instance from the context '''
        dot_pos = fully_qualified_name.rfind('.')
        if dot_pos == -1:
            for prefix in self._type_prefixes:
                try:
                    prefixed_name = '%s.%s' % (prefix, fully_qualified_name)
                    return self.get_type(prefixed_name)
                except (TypeError):
                    pass
                except ImportError, err:
                    logging.error(err)
            msg = 'Type %s is not in a module: perhaps you want to Import it?'
            raise TypeError(msg % fully_qualified_name)

        module_part = fully_qualified_name[:dot_pos]
        type_part = fully_qualified_name[dot_pos + 1:]
        module = self.get_module(module_part)
        try:
            _type = getattr(module, type_part)
            return _type
        except AttributeError:
            msg = '%s could not be found in %s' % (type_part, module_part)
            raise TypeError(msg)

Tags: logging
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.