当前位置: 首页>>代码示例>>Python>>正文


Python Phase.execute方法代码示例

本文整理汇总了Python中twitter.pants.goal.Phase.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Phase.execute方法的具体用法?Python Phase.execute怎么用?Python Phase.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twitter.pants.goal.Phase的用法示例。


在下文中一共展示了Phase.execute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from twitter.pants.goal import Phase [as 别名]
# 或者: from twitter.pants.goal.Phase import execute [as 别名]
    def run(self, lock):
        if self.options.dry_run:
            print "****** Dry Run ******"

        logger = None
        if self.options.log or self.options.log_level:
            from twitter.common.log import init
            from twitter.common.log.options import LogOptions

            LogOptions.set_stderr_log_level((self.options.log_level or "info").upper())
            logdir = self.options.logdir or self.config.get("goals", "logdir", default=None)
            if logdir:
                safe_mkdir(logdir)
                LogOptions.set_log_dir(logdir)
                init("goals")
            else:
                init()
            logger = log

        if self.options.recursive_directory:
            log.warn("--all-recursive is deprecated, use a target spec with the form [dir]:: instead")
            for dir in self.options.recursive_directory:
                self.add_target_recursive(dir)

        if self.options.target_directory:
            log.warn("--all is deprecated, use a target spec with the form [dir]: instead")
            for dir in self.options.target_directory:
                self.add_target_directory(dir)

        context = Context(
            self.config,
            self.options,
            self.targets,
            requested_goals=self.requested_goals,
            lock=lock,
            log=logger,
            timer=self.timer if self.options.time else None,
        )

        unknown = []
        for phase in self.phases:
            if not phase.goals():
                unknown.append(phase)

        if unknown:
            print ("Unknown goal(s): %s" % " ".join(phase.name for phase in unknown))
            print ("")
            return Phase.execute(context, "goals")

        if logger:
            logger.debug("Operating on targets: %s", self.targets)

        ret = Phase.attempt(context, self.phases)
        if self.options.time:
            print ("Timing report")
            print ("=============")
            self.timer.print_timings()
        return ret
开发者ID:ewhauser,项目名称:commons,代码行数:60,代码来源:goal.py

示例2: run

# 需要导入模块: from twitter.pants.goal import Phase [as 别名]
# 或者: from twitter.pants.goal.Phase import execute [as 别名]
  def run(self, lock):
    with self.check_errors("Target contains a dependency cycle") as error:
      for target in self.targets:
        try:
          InternalTarget.check_cycles(target)
        except InternalTarget.CycleException as e:
          error(target.id)

    timer = None
    if self.options.time:
      class Timer(object):
        def now(self):
          return time.time()
        def log(self, message):
          print(message)
      timer = Timer()

    logger = None
    if self.options.log or self.options.log_level:
      from twitter.common.log import init
      from twitter.common.log.options import LogOptions
      LogOptions.set_stderr_log_level((self.options.log_level or 'info').upper())
      logdir = self.options.logdir or self.config.get('goals', 'logdir', default=None)
      if logdir:
        safe_mkdir(logdir)
        LogOptions.set_log_dir(logdir)
        init('goals')
      else:
        init()
      logger = log

    if self.options.recursive_directory:
      log.warn('--all-recursive is deprecated, use a target spec with the form [dir]:: instead')
      for dir in self.options.recursive_directory:
        self.add_target_recursive(dir)

    if self.options.target_directory:
      log.warn('--all is deprecated, use a target spec with the form [dir]: instead')
      for dir in self.options.target_directory:
        self.add_target_directory(dir)

    context = Context(self.config, self.options, self.targets, lock=lock, log=logger)

    unknown = []
    for phase in self.phases:
      if not phase.goals():
        unknown.append(phase)

    if unknown:
        print('Unknown goal(s): %s' % ' '.join(phase.name for phase in unknown))
        print('')
        return Phase.execute(context, 'goals')

    if logger:
      logger.debug('Operating on targets: %s', self.targets)

    return Phase.attempt(context, self.phases, timer=timer)
开发者ID:soheilhy,项目名称:commons,代码行数:59,代码来源:goal.py

示例3: execute

# 需要导入模块: from twitter.pants.goal import Phase [as 别名]
# 或者: from twitter.pants.goal.Phase import execute [as 别名]
  def execute(self):
    def add_targets(dir, buildfile):
      try:
        self.targets.extend(Target.get(addr) for addr in Target.get_all_addresses(buildfile))
      except (TypeError, ImportError):
        error(dir, include_traceback=True)
      except (IOError, SyntaxError):
        error(dir)

    if self.options.recursive_directory:
      with self.check_errors('There was a problem scanning the '
                             'following directories for targets:') as error:
        for dir in self.options.recursive_directory:
          for buildfile in BuildFile.scan_buildfiles(self.root_dir, dir):
            add_targets(dir, buildfile)

    if self.options.target_directory:
      with self.check_errors("There was a problem loading targets "
                             "from the following directory's BUILD files") as error:
        for dir in self.options.target_directory:
          add_targets(dir, BuildFile(self.root_dir, dir))

    timer = None
    if self.options.time:
      class Timer(object):
        def now(self):
          return time.time()
        def log(self, message):
          print(message)
      timer = Timer()

    logger = None
    if self.options.log or self.options.log_level:
      from twitter.common.log import init
      from twitter.common.log.options import LogOptions
      LogOptions.set_stderr_log_level((self.options.log_level or 'info').upper())
      logdir = self.config.get('goals', 'logdir')
      if logdir:
        safe_mkdir(logdir)
        LogOptions.set_log_dir(logdir)
      init('goals')
      logger = log

    context = Context(self.config, self.options, self.targets, log=logger)

    unknown = []
    for phase in self.phases:
      if not phase.goals():
        unknown.append(phase)

    if unknown:
        print('Unknown goal(s): %s' % ' '.join(phase.name for phase in unknown))
        print()
        return Phase.execute(context, 'goals')

    return Phase.attempt(context, self.phases, timer=timer)
开发者ID:adamsxu,项目名称:commons,代码行数:58,代码来源:goal.py

示例4: run

# 需要导入模块: from twitter.pants.goal import Phase [as 别名]
# 或者: from twitter.pants.goal.Phase import execute [as 别名]
    def run(self, lock):
        with self.check_errors("Target contains a dependency cycle") as error:
            with self.timer.timing("parse:check_cycles"):
                for target in self.targets:
                    try:
                        InternalTarget.check_cycles(target)
                    except InternalTarget.CycleException as e:
                        error(target.id)

        logger = None
        if self.options.log or self.options.log_level:
            from twitter.common.log import init
            from twitter.common.log.options import LogOptions

            LogOptions.set_stderr_log_level((self.options.log_level or "info").upper())
            logdir = self.options.logdir or self.config.get("goals", "logdir", default=None)
            if logdir:
                safe_mkdir(logdir)
                LogOptions.set_log_dir(logdir)
                init("goals")
            else:
                init()
            logger = log

        if self.options.recursive_directory:
            log.warn("--all-recursive is deprecated, use a target spec with the form [dir]:: instead")
            for dir in self.options.recursive_directory:
                self.add_target_recursive(dir)

        if self.options.target_directory:
            log.warn("--all is deprecated, use a target spec with the form [dir]: instead")
            for dir in self.options.target_directory:
                self.add_target_directory(dir)

        context = Context(self.config, self.options, self.targets, lock=lock, log=logger)

        unknown = []
        for phase in self.phases:
            if not phase.goals():
                unknown.append(phase)

        if unknown:
            print("Unknown goal(s): %s" % " ".join(phase.name for phase in unknown))
            print("")
            return Phase.execute(context, "goals")

        if logger:
            logger.debug("Operating on targets: %s", self.targets)

        ret = Phase.attempt(context, self.phases, timer=self.timer if self.options.time else None)
        if self.options.time:
            print("Timing report")
            print("=============")
            self.timer.print_timings()
        return ret
开发者ID:nsanch,项目名称:commons,代码行数:57,代码来源:goal.py

示例5: run

# 需要导入模块: from twitter.pants.goal import Phase [as 别名]
# 或者: from twitter.pants.goal.Phase import execute [as 别名]
  def run(self, lock):
    if self.options.dry_run:
      print '****** Dry Run ******'

    logger = None
    if self.options.log or self.options.log_level:
      from twitter.common.log import init
      from twitter.common.log.options import LogOptions
      LogOptions.set_stderr_log_level((self.options.log_level or 'info').upper())
      logdir = self.options.logdir or self.config.get('goals', 'logdir', default=None)
      if logdir:
        safe_mkdir(logdir)
        LogOptions.set_log_dir(logdir)
        init('goals')
      else:
        init()
      logger = log

    if self.options.recursive_directory:
      log.warn('--all-recursive is deprecated, use a target spec with the form [dir]:: instead')
      for dir in self.options.recursive_directory:
        self.add_target_recursive(dir)

    if self.options.target_directory:
      log.warn('--all is deprecated, use a target spec with the form [dir]: instead')
      for dir in self.options.target_directory:
        self.add_target_directory(dir)

    context = Context(
      self.config,
      self.options,
      self.targets,
      lock=lock,
      log=logger,
      timer=self.timer if self.options.time else None)

    unknown = []
    for phase in self.phases:
      if not phase.goals():
        unknown.append(phase)

    if unknown:
        print('Unknown goal(s): %s' % ' '.join(phase.name for phase in unknown))
        print('')
        return Phase.execute(context, 'goals')

    if logger:
      logger.debug('Operating on targets: %s', self.targets)

    ret = Phase.attempt(context, self.phases)
    if self.options.time:
      print('Timing report')
      print('=============')
      self.timer.print_timings()
    return ret
开发者ID:SeungEun,项目名称:commons,代码行数:57,代码来源:goal.py

示例6: run

# 需要导入模块: from twitter.pants.goal import Phase [as 别名]
# 或者: from twitter.pants.goal.Phase import execute [as 别名]
  def run(self, lock):
    # Update the reporting settings, now that we have flags etc.
    def is_console_task():
      for phase in self.phases:
        for goal in phase.goals():
          if issubclass(goal.task_type, ConsoleTask):
            return True
      return False

    update_reporting(self.options, is_console_task(), self.run_tracker)

    if self.options.dry_run:
      print '****** Dry Run ******'

    context = Context(
      self.config,
      self.options,
      self.run_tracker,
      self.targets,
      requested_goals=self.requested_goals,
      lock=lock)

    # TODO: Time to get rid of this hack.
    if self.options.recursive_directory:
      context.log.warn(
        '--all-recursive is deprecated, use a target spec with the form [dir]:: instead')
      for dir in self.options.recursive_directory:
        self.add_target_recursive(dir)

    if self.options.target_directory:
      context.log.warn('--all is deprecated, use a target spec with the form [dir]: instead')
      for dir in self.options.target_directory:
        self.add_target_directory(dir)

    unknown = []
    for phase in self.phases:
      if not phase.goals():
        unknown.append(phase)

    if unknown:
      print('Unknown goal(s): %s' % ' '.join(phase.name for phase in unknown))
      print('')
      return Phase.execute(context, 'goals')

    ret = Phase.attempt(context, self.phases)

    if self.options.cleanup_nailguns or self.config.get('nailgun', 'autokill', default = False):
      if log:
        log.debug('auto-killing nailguns')
      if NailgunTask.killall:
        NailgunTask.killall(log)

    return ret
开发者ID:jalons,项目名称:commons,代码行数:55,代码来源:goal.py

示例7: list_goals

# 需要导入模块: from twitter.pants.goal import Phase [as 别名]
# 或者: from twitter.pants.goal.Phase import execute [as 别名]
 def list_goals(self, message):
   print(message)
   print()
   return Phase.execute(self.context, 'goals')
开发者ID:soheilhy,项目名称:commons,代码行数:6,代码来源:goal.py

示例8: _list_goals

# 需要导入模块: from twitter.pants.goal import Phase [as 别名]
# 或者: from twitter.pants.goal.Phase import execute [as 别名]
def _list_goals(context, message):
  """Show all installed goals."""
  context.log.error(message)
  # Execute as if the user had run "./pants goals".
  return Phase.execute(context, 'goals')
开发者ID:patricklaw,项目名称:twitter-commons,代码行数:7,代码来源:goal.py

示例9: run

# 需要导入模块: from twitter.pants.goal import Phase [as 别名]
# 或者: from twitter.pants.goal.Phase import execute [as 别名]
  def run(self, lock):
    if self.options.dry_run:
      print('****** Dry Run ******')

    logger = None
    if self.options.log or self.options.log_level:
      log.LogOptions.set_stderr_log_level((self.options.log_level or 'info').upper())
      logdir = self.options.logdir or self.config.get('goals', 'logdir', default=None)
      if logdir:
        safe_mkdir(logdir)
        log.LogOptions.set_log_dir(logdir)
        log.init('goals')
      else:
        log.init()
      logger = log

      if not self.options.no_color:
        def colorwrapper(func, clrname):
          @wraps(func)
          def wrapper(msg, *args, **kwargs):
            return func(clrname(msg), *args, **kwargs)
          return wrapper

        log.info = colorwrapper(log.info, green)
        log.warn = colorwrapper(log.warn, yellow)
        log.debug = colorwrapper(log.debug, cyan)

    if self.options.recursive_directory:
      log.warn('--all-recursive is deprecated, use a target spec with the form [dir]:: instead')
      for dir in self.options.recursive_directory:
        self.add_target_recursive(dir)

    if self.options.target_directory:
      log.warn('--all is deprecated, use a target spec with the form [dir]: instead')
      for dir in self.options.target_directory:
        self.add_target_directory(dir)

    context = Context(
      self.config,
      self.options,
      self.targets,
      requested_goals=self.requested_goals,
      lock=lock,
      log=logger,
      timer=self.timer if self.options.time else None)

    unknown = []
    for phase in self.phases:
      if not phase.goals():
        unknown.append(phase)

    if unknown:
      print('Unknown goal(s): %s' % ' '.join(phase.name for phase in unknown))
      print('')
      return Phase.execute(context, 'goals')

    if logger:
      logger.debug('Operating on targets: %s' % self.targets)

    ret = Phase.attempt(context, self.phases)

    if self.options.cleanup_nailguns or self.config.get('nailgun', 'autokill', default = False):
      if log:
        log.debug('auto-killing nailguns')
      if NailgunTask.killall:
        NailgunTask.killall(log)

    if self.options.time:
      print('Timing report')
      print('=============')
      self.timer.print_timings()

    return ret
开发者ID:steliokontos,项目名称:commons,代码行数:75,代码来源:goal.py

示例10: run

# 需要导入模块: from twitter.pants.goal import Phase [as 别名]
# 或者: from twitter.pants.goal.Phase import execute [as 别名]
  def run(self, lock):
    # Update the reporting settings, now that we have flags etc.

    log_level = Report.log_level_from_string(self.options.log_level or 'info')
    color = not self.options.no_color
    timing = self.options.time
    cache_stats = self.options.time  # TODO: Separate flag for this?

    settings_updates_map = {
      'console': {
        'log_level': log_level, 'color': color, 'timing': timing, 'cache_stats': cache_stats
      },
      'html': {
        'log_level': log_level
      }
    }
    self.run_tracker.update_report_settings(settings_updates_map)
    # TODO: Do something useful with --logdir.

    if self.options.dry_run:
      print '****** Dry Run ******'

    context = Context(
      self.config,
      self.options,
      self.run_tracker,
      self.targets,
      requested_goals=self.requested_goals,
      lock=lock)

    # TODO: Time to get rid of this hack.
    if self.options.recursive_directory:
      context.log.warn(
        '--all-recursive is deprecated, use a target spec with the form [dir]:: instead')
      for dir in self.options.recursive_directory:
        self.add_target_recursive(dir)

    if self.options.target_directory:
      context.log.warn('--all is deprecated, use a target spec with the form [dir]: instead')
      for dir in self.options.target_directory:
        self.add_target_directory(dir)

    unknown = []
    for phase in self.phases:
      if not phase.goals():
        unknown.append(phase)

    if unknown:
      print('Unknown goal(s): %s' % ' '.join(phase.name for phase in unknown))
      print('')
      return Phase.execute(context, 'goals')

    ret = Phase.attempt(context, self.phases)

    if self.options.cleanup_nailguns or self.config.get('nailgun', 'autokill', default = False):
      if log:
        log.debug('auto-killing nailguns')
      if NailgunTask.killall:
        NailgunTask.killall(log)

    return ret
开发者ID:wickman,项目名称:commons,代码行数:63,代码来源:goal.py


注:本文中的twitter.pants.goal.Phase.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。