Пример #1
0
 def shutdown(self):
     """
     Shutdown B3.
     """
     try:
         ## erase Altitude command file content so the Altitude
         ## server wron't try to redo those commands on restart
         self.output.clear()
     except Exception as e:
         self.error(e)
     finally:
         ## call original shutdown()
         Parser.shutdown(self)
Пример #2
0
class BuildCommand(CommandBase):
  """This class represents build command."""

  DEFAULT_TARGETS = [":all"]

  def __init__(self, config=None, project_filesystem=None, console=None,
               artifact_cache=None, step_runner=None):
    CommandBase.__init__(self, config, project_filesystem, console)
    self._artifact_cache   = artifact_cache or ArtifactCachePlug()
    self._step_runner      = step_runner or DefaultStepRunner()
    self._dependency_graph = None
    self._parser           = None

  def get_dependency_graph(self):
    return self._dependency_graph

  def get_parser(self):
    return self._parser

  @classmethod
  def setup_command_line_arguments_parser(cls, parser):
    parser.epilog = "Builds the specified target(s)."
    parser.usage = "\n%(prog)s (options) [targets]\n"
    parser.add_argument("targets", metavar="TARGET", type=str, nargs="*")

  def execute(self, arguments):
    """Executes build process. By default DEFAULT_TARGETS will be taken as
    starting points.
    """
    names = (arguments.get("targets") if len(arguments.get("targets"))
             else BuildCommand.DEFAULT_TARGETS)
    known_rule_types = KnownRuleTypes()
    self._parser = Parser(self._config, self._project_filesystem, self._console,
                          known_rule_types)
    targets = self._parser.parse_build_files_for_target_names(names)
    raw_build_target_table = self._parser.get_raw_build_target_table()
    self._dependency_graph = DependencyGraphBuilder(self._config).build(
      raw_build_target_table, known_rule_types)
    build_context = BuildContext(artifact_cache=self._artifact_cache,
                                 console=self._console,
                                 project_filesystem=self._project_filesystem,
                                 dependency_graph=self._dependency_graph,
                                 step_runner=self._step_runner)
    for target in targets:
      rule = self._dependency_graph.find_rule_by_target(target)
      rule.build(build_context)
    return 0

  def cleanup(self):
    pass
Пример #3
0
 def execute(self, arguments):
   """Executes build process. By default DEFAULT_TARGETS will be taken as
   starting points.
   """
   names = (arguments.get("targets") if len(arguments.get("targets"))
            else BuildCommand.DEFAULT_TARGETS)
   known_rule_types = KnownRuleTypes()
   self._parser = Parser(self._config, self._project_filesystem, self._console,
                         known_rule_types)
   targets = self._parser.parse_build_files_for_target_names(names)
   raw_build_target_table = self._parser.get_raw_build_target_table()
   self._dependency_graph = DependencyGraphBuilder(self._config).build(
     raw_build_target_table, known_rule_types)
   build_context = BuildContext(artifact_cache=self._artifact_cache,
                                console=self._console,
                                project_filesystem=self._project_filesystem,
                                dependency_graph=self._dependency_graph,
                                step_runner=self._step_runner)
   for target in targets:
     rule = self._dependency_graph.find_rule_by_target(target)
     rule.build(build_context)
   return 0
Пример #4
0
    #                                                                                                                  #
    ####################################################################################################################

    def shutdown(self):
        """
        Shutdown B3.
        """
        try:
            ## erase Altitude command file content so the Altitude
            ## server wron't try to redo those commands on restart
            self.output.clear()
        except Exception, e:
            self.error(e)
        finally:
            ## call original shutdown()
            Parser.shutdown(self)

    ####################################################################################################################
    #                                                                                                                  #
    #   OTHER METHODS                                                                                                  #
    #                                                                                                                  #
    ####################################################################################################################

    def getTeam(self, teamAltitudeId):
        """
        Convert an Altitude team ID into a B3 team ID
        doc: http://altitudegame.com/forums/showpost.php?p=82191&postcount=30
        """
        if teamAltitudeId == 2:
            return b3.TEAM_SPEC
        elif teamAltitudeId == 3:
Пример #5
0
 def __new__(cls, *args, **kwargs):
     ChivParser.patch_admin_plugin_doList()
     ChivParser.patch_admin_plugin_cmd_find()
     return Parser.__new__(cls)
Пример #6
0
    
    #===========================================================================
    # overwriting some Parser methods
    #===========================================================================

    def shutdown(self):
        """Shutdown B3"""
        try:
            ## erase Altitude command file content so the Altitude
            ## server wron't try to redo those commands on restart
            self.output.clear()
        except Exception, e:
            self.error(e)
        finally:
            ## call original shutdown()
            Parser.shutdown(self)


    #===========================================================================
    # other methods
    #===========================================================================

    def getTeam(self, teamAltitudeId):
        """convert an Altitude team ID into a B3 team ID
        doc: http://altitudegame.com/forums/showpost.php?p=82191&postcount=30
        """
        if teamAltitudeId == 2:
            return b3.TEAM_SPEC
        elif teamAltitudeId == 3:
            # red
            return b3.TEAM_FREE
Пример #7
0
 def __new__(cls, *args, **kwargs):
     ChivParser.patch_admin_plugin_doList()
     ChivParser.patch_admin_plugin_cmd_find()
     return Parser.__new__(cls)
Пример #8
0
 def shutdown(self):
     self.game_event_queue.put(
         (None, None, self.game_event_queue_stop_token))
     Parser.shutdown(self)
Пример #9
0
 def __new__(cls, *args, **kwargs):
     patch_b3()
     return Parser.__new__(cls)