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


Python TRACER.log方法代码示例

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


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

示例1: _execute

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
  def _execute(self):
    force_interpreter = self._vars.PEX_INTERPRETER

    self.clean_environment()

    if force_interpreter:
      TRACER.log('PEX_INTERPRETER specified, dropping into interpreter')
      return self.execute_interpreter()

    if self._pex_info_overrides.script and self._pex_info_overrides.entry_point:
      die('Cannot specify both script and entry_point for a PEX!')

    if self._pex_info.script and self._pex_info.entry_point:
      die('Cannot specify both script and entry_point for a PEX!')

    if self._pex_info_overrides.script:
      return self.execute_script(self._pex_info_overrides.script)
    elif self._pex_info_overrides.entry_point:
      return self.execute_entry(self._pex_info_overrides.entry_point)
    elif self._pex_info.script:
      return self.execute_script(self._pex_info.script)
    elif self._pex_info.entry_point:
      return self.execute_entry(self._pex_info.entry_point)
    else:
      TRACER.log('No entry point specified, dropping into interpreter')
      return self.execute_interpreter()
开发者ID:jsirois,项目名称:pex,代码行数:28,代码来源:pex.py

示例2: set_script

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
  def set_script(self, script):
    """Set the entry point of this PEX environment based upon a distribution script.

    :param script: The script name as defined either by a console script or ordinary
      script within the setup.py of one of the distributions added to the PEX.
    :raises: :class:`PEXBuilder.InvalidExecutableSpecification` if the script is not found
      in any distribution added to the PEX.
    """

    # check if 'script' is a console_script
    dist, entry_point = get_entry_point_from_console_script(script, self._distributions)
    if entry_point:
      self.set_entry_point(entry_point)
      TRACER.log('Set entrypoint to console_script %r in %r' % (entry_point, dist))
      return

    # check if 'script' is an ordinary script
    dist, _, _ = get_script_from_distributions(script, self._distributions)
    if dist:
      if self._pex_info.entry_point:
        raise self.InvalidExecutableSpecification('Cannot set both entry point and script of PEX!')
      self._pex_info.script = script
      TRACER.log('Set entrypoint to script %r in %r' % (script, dist))
      return

    raise self.InvalidExecutableSpecification(
        'Could not find script %r in any distribution %s within PEX!' % (
            script, ', '.join(str(d) for d in self._distributions)))
开发者ID:jsirois,项目名称:pex,代码行数:30,代码来源:pex_builder.py

示例3: __init__

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
  def __init__(self, pex, pex_info, interpreter=None, **kw):
    self._internal_cache = os.path.join(pex, pex_info.internal_cache)
    self._pex = pex
    self._pex_info = pex_info
    self._activated = False
    self._working_set = None
    self._interpreter = interpreter or PythonInterpreter.get()
    self._inherit_path = pex_info.inherit_path
    self._supported_tags = []

    # For the bug this works around, see: https://bitbucket.org/pypy/pypy/issues/1686
    # NB: This must be installed early before the underlying pex is loaded in any way.
    if self._interpreter.identity.abbr_impl == 'pp' and zipfile.is_zipfile(self._pex):
      self._install_pypy_zipimporter_workaround(self._pex)

    platform = Platform.current()
    platform_name = platform.platform
    super(PEXEnvironment, self).__init__(
      search_path=[] if pex_info.inherit_path == 'false' else sys.path,
      # NB: Our pkg_resources.Environment base-class wants the platform name string and not the
      # pex.platform.Platform object.
      platform=platform_name,
      **kw
    )
    self._target_interpreter_env = self._interpreter.identity.pkg_resources_env(platform_name)
    self._supported_tags.extend(platform.supported_tags(self._interpreter))
    TRACER.log(
      'E: tags for %r x %r -> %s' % (self.platform, self._interpreter, self._supported_tags),
      V=9
    )
开发者ID:pantsbuild,项目名称:pex,代码行数:32,代码来源:environment.py

示例4: _wrap_coverage

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
  def _wrap_coverage(self, runner, *args):
    if not self._vars.PEX_COVERAGE and self._vars.PEX_COVERAGE_FILENAME is None:
      return runner(*args)

    try:
      import coverage
    except ImportError:
      die('Could not bootstrap coverage module, aborting.')

    pex_coverage_filename = self._vars.PEX_COVERAGE_FILENAME
    if pex_coverage_filename is not None:
      cov = coverage.coverage(data_file=pex_coverage_filename)
    else:
      cov = coverage.coverage(data_suffix=True)

    TRACER.log('Starting coverage.')
    cov.start()

    try:
      return runner(*args)
    finally:
      TRACER.log('Stopping coverage')
      cov.stop()

      # TODO(wickman) Post-process coverage to elide $PEX_ROOT and make
      # the report more useful/less noisy.  #89
      if pex_coverage_filename:
        cov.save()
      else:
        cov.report(show_missing=False, ignore_errors=True, file=sys.stdout)
开发者ID:jsirois,项目名称:pex,代码行数:32,代码来源:pex.py

示例5: demote_bootstrap

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
  def demote_bootstrap(cls):
    TRACER.log('Bootstrap complete, performing final sys.path modifications...')

    should_log = {level: TRACER.should_log(V=level) for level in range(1, 10)}

    def log(msg, V=1):
      if should_log.get(V, False):
        print('pex: {}'.format(msg), file=sys.stderr)

    # Remove the third party resources pex uses and demote pex bootstrap code to the end of
    # sys.path for the duration of the run to allow conflicting versions supplied by user
    # dependencies to win during the course of the execution of user code.
    unregister_finders()
    third_party.uninstall()

    bootstrap = Bootstrap.locate()
    log('Demoting code from %s' % bootstrap, V=2)
    for module in bootstrap.demote():
      log('un-imported {}'.format(module), V=9)

    import pex
    log('Re-imported pex from {}'.format(pex.__path__), V=3)

    log('PYTHONPATH contains:')
    for element in sys.path:
      log('  %c %s' % (' ' if os.path.exists(element) else '*', element))
    log('  * - paths that do not exist or will be imported via zipimport')
开发者ID:jsirois,项目名称:pex,代码行数:29,代码来源:pex.py

示例6: crawl_link

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
 def crawl_link(cls, context, link):
   if link.local:
     return cls.crawl_local(link)
   elif link.remote:
     return cls.crawl_remote(context, link)
   else:
     TRACER.log('Failed to crawl %s: unknown scheme %s' % (link.url, link.scheme))
     return set(), set()
开发者ID:jsirois,项目名称:pex,代码行数:10,代码来源:crawler.py

示例7: crawl_local

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
 def crawl_local(cls, link):
   try:
     dirents = os.listdir(link.local_path)
   except OSError as e:
     TRACER.log('Failed to read %s: %s' % (link.local_path, e), V=1)
     return set(), set()
   files, dirs = partition([os.path.join(link.local_path, fn) for fn in dirents], os.path.isdir)
   return set(map(Link.from_filename, files)), set(map(Link.from_filename, dirs))
开发者ID:jsirois,项目名称:pex,代码行数:10,代码来源:crawler.py

示例8: get

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
 def get(cls):
   for context_class in cls._REGISTRY:
     try:
       context = context_class()
       TRACER.log('Constructed %s context %r' % (context.__class__.__name__, context), V=4)
       return context
     except cls.Error:
       continue
   raise cls.Error('Could not initialize a request context.')
开发者ID:jsirois,项目名称:pex,代码行数:11,代码来源:http.py

示例9: crawl_remote

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
 def crawl_remote(cls, context, link):
   try:
     link = context.resolve(link)
     content = context.content(link)
   except context.Error as e:
     TRACER.log('Failed to read %s: %s' % (link.url, e), V=1)
     return set(), set()
   links = set(link.join(href) for href in PageParser.links(content))
   rel_links = set(link.join(href) for href in PageParser.rel_links(content))
   return links, rel_links
开发者ID:jsirois,项目名称:pex,代码行数:12,代码来源:crawler.py

示例10: execute_script

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
  def execute_script(self, script_name):
    dists = list(self._activate())

    dist, entry_point = get_entry_point_from_console_script(script_name, dists)
    if entry_point:
      TRACER.log('Found console_script %r in %r' % (entry_point, dist))
      sys.exit(self.execute_entry(entry_point))

    dist, script_path, script_content = get_script_from_distributions(script_name, dists)
    if not dist:
      raise self.NotFound('Could not find script %r in pex!' % script_name)
    TRACER.log('Found script %r in %r' % (script_name, dist))
    return self.execute_content(script_path, script_content, argv0=script_name)
开发者ID:jsirois,项目名称:pex,代码行数:15,代码来源:pex.py

示例11: vendor_runtime

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
def vendor_runtime(chroot, dest_basedir, label, root_module_names):
  """Includes portions of vendored distributions in a chroot.

  The portion to include is selected by root module name. If the module is a file, just it is
  included. If the module represents a package, the package and all its sub-packages are added
  recursively.

  :param chroot: The chroot to add vendored code to.
  :type chroot: :class:`pex.common.Chroot`
  :param str dest_basedir: The prefix to store the vendored code under in the ``chroot``.
  :param str label: The chroot label for the vendored code fileset.
  :param root_module_names: The names of the root vendored modules to include in the chroot.
  :type root_module_names: :class:`collections.Iterable` of str
  :raise: :class:`ValueError` if any of the given ``root_module_names`` could not be found amongst
          the vendored code and added to the chroot.
  """
  vendor_module_names = {root_module_name: False for root_module_name in root_module_names}
  for spec in iter_vendor_specs():
    for root, dirs, files in os.walk(spec.target_dir):
      if root == spec.target_dir:
        dirs[:] = [pkg_name for pkg_name in dirs if pkg_name in vendor_module_names]
        files[:] = [mod_name for mod_name in files if mod_name[:-3] in vendor_module_names]
        vendored_names = dirs + files
        if vendored_names:
          pkg_path = ''
          for pkg in spec.relpath.split(os.sep):
            pkg_path = os.path.join(pkg_path, pkg)
            pkg_file = os.path.join(pkg_path, '__init__.py')
            src = os.path.join(VendorSpec.ROOT, pkg_file)
            dest = os.path.join(dest_basedir, pkg_file)
            if os.path.exists(src):
              chroot.copy(src, dest, label)
            else:
              # We delete `pex/vendor/_vendored/<dist>/__init__.py` when isolating third_party.
              chroot.touch(dest, label)
          for name in vendored_names:
            vendor_module_names[name] = True
            TRACER.log('Vendoring {} from {} @ {}'.format(name, spec, spec.target_dir), V=3)

      for filename in files:
        if not filename.endswith('.pyc'):  # Sources and data only.
          src = os.path.join(root, filename)
          dest = os.path.join(dest_basedir, spec.relpath, os.path.relpath(src, spec.target_dir))
          chroot.copy(src, dest, label)

  if not all(vendor_module_names.values()):
    raise ValueError('Failed to extract {module_names} from:\n\t{specs}'.format(
      module_names=', '.join(module
                             for module, written in vendor_module_names.items() if not written),
      specs='\n\t'.join('{} @ {}'.format(spec, spec.target_dir) for spec in iter_vendor_specs())))
开发者ID:jsirois,项目名称:pex,代码行数:52,代码来源:__init__.py

示例12: __init__

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
 def __init__(self, allow_prereleases=None, interpreter=None, platform=None, use_manylinux=None):
   self._interpreter = interpreter or PythonInterpreter.get()
   self._platform = self._maybe_expand_platform(self._interpreter, platform)
   self._allow_prereleases = allow_prereleases
   platform_name = self._platform.platform
   self._target_interpreter_env = self._interpreter.identity.pkg_resources_env(platform_name)
   self._supported_tags = self._platform.supported_tags(
     self._interpreter,
     use_manylinux
   )
   TRACER.log(
     'R: tags for %r x %r -> %s' % (self._platform, self._interpreter, self._supported_tags),
     V=9
   )
开发者ID:jsirois,项目名称:pex,代码行数:16,代码来源:resolver.py

示例13: from_env

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
  def from_env(cls, hashbang):
    """Resolve a PythonInterpreter as /usr/bin/env would.

       :param hashbang: A string, e.g. "python3.3" representing some binary on the $PATH.
    """
    paths = os.getenv('PATH', '').split(':')
    for path in paths:
      for fn in cls.expand_path(path):
        basefile = os.path.basename(fn)
        if hashbang == basefile:
          try:
            return cls.from_binary(fn)
          except Exception as e:
            TRACER.log('Could not identify %s: %s' % (fn, e))
开发者ID:jsirois,项目名称:pex,代码行数:16,代码来源:interpreter.py

示例14: matched_interpreters

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
def matched_interpreters(interpreters, constraints):
  """Given some filters, yield any interpreter that matches at least one of them.

  :param interpreters: a list of PythonInterpreter objects for filtering
  :param constraints: A sequence of strings that constrain the interpreter compatibility for this
    pex. Each string uses the Requirement-style format, e.g. 'CPython>=3' or '>=2.7,<3' for
    requirements agnostic to interpreter class. Multiple requirement strings may be combined
    into a list to OR the constraints, such as ['CPython>=2.7,<3', 'CPython>=3.4'].
  :return interpreter: returns a generator that yields compatible interpreters
  """
  for interpreter in interpreters:
    if any(interpreter.identity.matches(filt) for filt in constraints):
      TRACER.log("Constraints on interpreters: %s, Matching Interpreter: %s"
                 % (constraints, interpreter.binary), V=3)
      yield interpreter
开发者ID:jsirois,项目名称:pex,代码行数:17,代码来源:interpreter_constraints.py

示例15: maybe_reexec_pex

# 需要导入模块: from pex.tracer import TRACER [as 别名]
# 或者: from pex.tracer.TRACER import log [as 别名]
def maybe_reexec_pex(compatibility_constraints):
  """
  Handle environment overrides for the Python interpreter to use when executing this pex.

  This function supports interpreter filtering based on interpreter constraints stored in PEX-INFO
  metadata. If PEX_PYTHON is set in a pexrc, it attempts to obtain the binary location of the
  interpreter specified by PEX_PYTHON. If PEX_PYTHON_PATH is set, it attempts to search the path for
  a matching interpreter in accordance with the interpreter constraints. If both variables are
  present in a pexrc, this function gives precedence to PEX_PYTHON_PATH and errors out if no
  compatible interpreters can be found on said path.

  If neither variable is set, we fall back to plain PEX execution using PATH searching or the
  currently executing interpreter. If compatibility constraints are used, we match those constraints
  against these interpreters.

  :param compatibility_constraints: list of requirements-style strings that constrain the
  Python interpreter to re-exec this pex with.
  """
  if os.environ.pop('SHOULD_EXIT_BOOTSTRAP_REEXEC', None):
    # We've already been here and selected an interpreter. Continue to execution.
    return

  target = None
  with TRACER.timed('Selecting runtime interpreter based on pexrc', V=3):
    if ENV.PEX_PYTHON and not ENV.PEX_PYTHON_PATH:
      # preserve PEX_PYTHON re-exec for backwards compatibility
      # TODO: Kill this off completely in favor of PEX_PYTHON_PATH
      # https://github.com/pantsbuild/pex/issues/431
      target = _select_pex_python_interpreter(ENV.PEX_PYTHON,
                                              compatibility_constraints=compatibility_constraints)
    elif ENV.PEX_PYTHON_PATH:
      target = _select_interpreter(pex_python_path=ENV.PEX_PYTHON_PATH,
                                   compatibility_constraints=compatibility_constraints)

    elif compatibility_constraints:
      # Apply constraints to target using regular PATH
      target = _select_interpreter(compatibility_constraints=compatibility_constraints)

  if target and os.path.realpath(target) != os.path.realpath(sys.executable):
    cmdline = [target] + sys.argv
    TRACER.log('Re-executing: cmdline="%s", sys.executable="%s", PEX_PYTHON="%s", '
               'PEX_PYTHON_PATH="%s", COMPATIBILITY_CONSTRAINTS="%s"'
               % (cmdline, sys.executable, ENV.PEX_PYTHON, ENV.PEX_PYTHON_PATH,
                  compatibility_constraints))
    ENV.delete('PEX_PYTHON')
    ENV.delete('PEX_PYTHON_PATH')
    os.environ['SHOULD_EXIT_BOOTSTRAP_REEXEC'] = '1'
    os.execve(target, cmdline, ENV.copy())
开发者ID:jsirois,项目名称:pex,代码行数:50,代码来源:pex_bootstrapper.py


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