def colorize_run_tests(self, line): cline = sanitize(line).rstrip() for p, r in self.filters: if p.match(cline): lines = [fmt(r).format(line) for line in cline.splitlines()] cline = '\n'.join(lines) return cline + '\n'
def colorize_cmake(line): """Colorizes output from CMake :param line: one, new line terminated, line from `cmake` which needs coloring. :type line: str """ cline = sanitize(line) if line.startswith('-- '): cline = '@{cf}-- @|' + cline[len('-- '):] if ':' in cline: split_cline = cline.split(':') cline = split_cline[0] + ':@{yf}' + ':'.join( split_cline[1:]) + '@|' if line.lower().startswith('warning'): # WARNING cline = fmt('@{yf}') + cline if line.startswith('CMake Warning'): # CMake Warning... cline = cline.replace('CMake Warning', '@{yf}@!CMake Warning@|') if line.startswith('ERROR:'): # ERROR: cline = cline.replace('ERROR:', '@!@{rf}ERROR:@|') if line.startswith('CMake Error'): # CMake Error... cline = cline.replace('CMake Error', '@{rf}@!CMake Error@|') if line.startswith('Call Stack (most recent call first):'): # CMake Call Stack cline = cline.replace('Call Stack (most recent call first):', '@{cf}@_Call Stack (most recent call first):@|') return fmt(cline)
def colorize_cmake(line): """Colorizes output from CMake :param line: one, new line terminated, line from `cmake` which needs coloring. :type line: str """ cline = sanitize(line) if line.startswith('-- '): cline = '@{cf}-- @|' + cline[len('-- '):] if ':' in cline: split_cline = cline.split(':') cline = split_cline[0] + ':@{yf}' + ':'.join(split_cline[1:]) + '@|' if line.lower().startswith('warning'): # WARNING cline = fmt('@{yf}') + cline if line.startswith('CMake Warning'): # CMake Warning... cline = cline.replace('CMake Warning', '@{yf}@!CMake Warning@|') if line.startswith('ERROR:'): # ERROR: cline = cline.replace('ERROR:', '@!@{rf}ERROR:@|') if line.startswith('CMake Error'): # CMake Error... cline = cline.replace('CMake Error', '@{rf}@!CMake Error@|') if line.startswith('Call Stack (most recent call first):'): # CMake Call Stack cline = cline.replace('Call Stack (most recent call first):', '@{cf}@_Call Stack (most recent call first):@|') return fmt(cline)
def colorize_cmake(self, line): """Colorizes output from CMake This also prepends the source path to the locations of warnings and errors. :param line: one, new line terminated, line from `cmake` which needs coloring. :type line: str """ # return line cline = sanitize(line) if len(cline.strip()) == 0: return cline if line.startswith('-- '): cline = '@{cf}--@| ' + cline[len('-- '):] if ':' in cline: split_cline = cline.split(':', 1) if len(split_cline[1].strip()) > 0: cline = split_cline[0] + (':@{yf}%s@|' % split_cline[1]) elif line.lower().startswith('warning'): # WARNING cline = fmt('@{yf}', reset=False) + cline elif line.startswith('CMake Warning at '): # CMake Warning at... cline = cline.replace('CMake Warning at ', '@{yf}@!CMake Warning@| at ' + self.source_path + os.path.sep) elif line.startswith('CMake Warning (dev) at '): # CMake Warning at... cline = cline.replace( 'CMake Warning (dev) at ', '@{yf}@!CMake Warning (dev)@| at ' + self.source_path + os.path.sep) elif line.startswith('CMake Warning'): # CMake Warning... cline = cline.replace('CMake Warning', '@{yf}@!CMake Warning@|') elif line.startswith('ERROR:'): # ERROR: cline = cline.replace('ERROR:', '@!@{rf}ERROR:@|') elif line.startswith('CMake Error at '): # CMake Error... cline = cline.replace('CMake Error at ', '@{rf}@!CMake Error@| at ' + self.source_path + os.path.sep) elif line.startswith('CMake Error'): # CMake Error... cline = cline.replace('CMake Error', '@{rf}@!CMake Error@|') elif line.startswith('Call Stack (most recent call first):'): # CMake Call Stack cline = cline.replace('Call Stack (most recent call first):', '@{cf}@_Call Stack (most recent call first):@|') return fmt(cline, reset=False)
def main(opts): try: # Determine if the user is trying to perform some action, in which # case, the workspace should be automatically initialized ignored_opts = ['main', 'verb'] actions = [v for k, v in vars(opts).items() if k not in ignored_opts] no_action = not any(actions) # Try to find a metadata directory to get context defaults # Otherwise use the specified directory context = Context.load(opts.workspace, opts.profile, opts, append=opts.append_args, remove=opts.remove_args) do_init = opts.init or not no_action summary_notes = [] if not context.initialized() and do_init: summary_notes.append( clr('@!@{cf}Initialized new catkin workspace in `%s`@|' % sanitize(context.workspace))) if context.initialized() or do_init: Context.save(context) if opts.mkdirs and not context.source_space_exists(): os.makedirs(context.source_space_abs) print(context.summary(notes=summary_notes)) except IOError as exc: # Usually happens if workspace is already underneath another catkin_tools workspace print('error: could not configure catkin workspace: %s' % exc.message) return 1 return 0
def colorize_cmake(self, line): """Colorizes output from CMake This also prepends the source path to the locations of warnings and errors. :param line: one, new line terminated, line from `cmake` which needs coloring. :type line: str """ # return line cline = sanitize(line).rstrip() if len(cline.strip()) > 0: for p, r, f in self.filters: match = p.match(cline) if match is not None: cline = fmt(r, reset=False) if f is not None: cline = cline.format(*f(match.groups())) else: cline = cline.format(*match.groups()) break return cline + '\r\n'
# distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """This module implements many of the colorization functions used by catkin clean""" from catkin_tools.terminal_color import ansi from catkin_tools.terminal_color import fmt from catkin_tools.terminal_color import sanitize from catkin_tools.terminal_color import ColorMapper # This map translates more human reable format strings into colorized versions _color_translation_map = { # 'output': 'colorized_output' '': fmt('@!' + sanitize('') + '@|'), "[{package}] ==> '{cmd.cmd_str}' in '{location}'": fmt("[@{cf}{package}@|] @!@{bf}==>@| '@!{cmd.cmd_str}@|' @{kf}@!in@| '@!{location}@|'" ), "Starting ==> {package}": fmt("Starting @!@{gf}==>@| @!@{cf}{package}@|"), "[{package}] {msg}": fmt("[@{cf}{package}@|] {msg}"), "[{package}] <== '{cmd.cmd_str}' failed with return code '{retcode}'": fmt("[@{cf}{package}@|] @!@{rf}<==@| '@!{cmd.cmd_str}@|' @{rf}failed with return code@| '@!{retcode}@|'" ), "[{package}] <== '{cmd.cmd_str}' finished with return code '{retcode}'": fmt("[@{cf}{package}@|] @{gf}<==@| '@!{cmd.cmd_str}@|' finished with return code '@!{retcode}@|'" ), "Finished <== {package:<": fmt("@!@{kf}Finished@| @{gf}<==@| @{cf}{package:<").rstrip(ansi('reset')),
from catkin_tools.common import terminal_width from catkin_tools.common import wide_log from catkin_tools.notifications import notify from catkin_tools.terminal_color import fmt from catkin_tools.terminal_color import sanitize from catkin_tools.terminal_color import ColorMapper from catkin_tools.execution import job_server # This map translates more human reable format strings into colorized versions _color_translation_map = { # 'output': 'colorized_output' '': fmt('@!' + sanitize('') + '@|'), # Job starting "Starting >>> {:<{}}": fmt("Starting @!@{gf}>>>@| @!@{cf}{:<{}}@|"), # Job finishing "Finished <<< {:<{}} [ {} ]": fmt("@!@{kf}Finished@| @{gf}<<<@| @{cf}{:<{}}@| [ @{yf}{}@| ]"), "Failed <<< {:<{}} [ {} ]": fmt("@!@{rf}Failed@| @{rf}<<<@| @{cf}{:<{}}@| [ @{yf}{}@| ]"), # Job abandoning "Abandoned <<< {:<{}} [ {} ]": fmt("@!@{rf}Abandoned@| @{rf}<<<@| @{cf}{:<{}}@| [ @{yf}{}@| ]"),
def main(opts): try: # Determine if the user is trying to perform some action, in which # case, the workspace should be automatically initialized ignored_opts = ['main', 'verb'] actions = [v for k, v in vars(opts).items() if k not in ignored_opts] no_action = not any(actions) # Try to find a metadata directory to get context defaults # Otherwise use the specified directory context = Context.load( opts.workspace, opts.profile, opts, append=opts.append_args, remove=opts.remove_args) do_init = opts.init or not no_action summary_notes = [] if not context.initialized() and do_init: summary_notes.append(clr('@!@{cf}Initialized new catkin workspace in `%s`@|' % sanitize(context.workspace))) if context.initialized() or do_init: Context.save(context) if opts.mkdirs and not context.source_space_exists(): os.makedirs(context.source_space_abs) print(context.summary(notes=summary_notes)) except IOError as exc: # Usually happens if workspace is already underneath another catkin_tools workspace print('error: could not configure catkin workspace: %s' % exc.message) return 1 return 0