<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def trace_modules(self, modules, pattern=r".*", flags=re.IGNORECASE):
 """ Traces given modules using given filter pattern. :param modules: Modules to trace. :type modules: list :param pattern: Matching pattern. :type pattern: unicode :param flags: Matching regex flags. :type flags: int :return: Method success. :rtype: bool """


        try:
            pattern = re.compile(pattern, flags)
        except Exception:
            raise foundations.exceptions.UserError(
                "{0} | Invalid objects trace filter pattern: Regex compilation failed!".format(self.__class__.__name__))

        for module in modules:
            foundations.trace.trace_module(module, foundations.verbose.tracer, pattern)
        self.__model__refresh_attributes()
        return True