def attempt(self, explain):
    """Attempts to execute the goal's tasks in installed order.

    :param bool explain: If ``True`` then the goal plan will be explained instead of being
                         executed.
    """
    goal_workdir = os.path.join(self._context.options.for_global_scope().pants_workdir,
                                self._goal.name)
    with self._context.new_workunit(name=self._goal.name, labels=[WorkUnitLabel.GOAL]):
      for name, task_type in reversed(list(self._tasktypes_by_name.items())):
        task_workdir = os.path.join(goal_workdir, name)
        task = task_type(self._context, task_workdir)
        log_config = WorkUnit.LogConfig(level=task.get_options().level, colors=task.get_options().colors)
        with self._context.new_workunit(name=name, labels=[WorkUnitLabel.TASK], log_config=log_config):
          if explain:
            self._context.log.debug('Skipping execution of {} in explain mode'.format(name))
          elif task.skip_execution:
            self._context.log.info('Skipping {}'.format(name))
          else:
            task.execute()

      if explain:
        reversed_tasktypes_by_name = reversed(list(self._tasktypes_by_name.items()))
        goal_to_task = ', '.join(
            '{}->{}'.format(name, task_type.__name__) for name, task_type in reversed_tasktypes_by_name)
        print('{goal} [{goal_to_task}]'.format(goal=self._goal.name, goal_to_task=goal_to_task))
def attempt ( self , explain ) : goal_workdir = os . path . join ( self . _context . options . for_global_scope ( ) . pants_workdir , self . _goal . name ) with self . _context . new_workunit ( name = self . _goal . name , labels = [ WorkUnitLabel . GOAL ] ) : for name , task_type in reversed ( list ( self . _tasktypes_by_name . items ( ) ) ) : task_workdir = os . path . join ( goal_workdir , name ) task = task_type ( self . _context , task_workdir ) log_config = WorkUnit . LogConfig ( level = task . get_options ( ) . level , colors = task . get_options ( ) . colors ) with self . _context . new_workunit ( name = name , labels = [ WorkUnitLabel . TASK ] , log_config = log_config ) : if explain : self . _context . log . debug ( 'Skipping execution of {} in explain mode' . format ( name ) ) elif task . skip_execution : self . _context . log . info ( 'Skipping {}' . format ( name ) ) else : task . execute ( ) if explain : reversed_tasktypes_by_name = reversed ( list ( self . _tasktypes_by_name . items ( ) ) ) goal_to_task = ', ' . join ( '{}->{}' . format ( name , task_type . __name__ ) for name , task_type in reversed_tasktypes_by_name ) print ( '{goal} [{goal_to_task}]' . format ( goal = self . _goal . name , goal_to_task = goal_to_task ) )
Attempts to execute the goal's tasks in installed order.

    :param bool explain: If ``True`` then the goal plan will be explained instead of being
                         executed.