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


Python distribution.Distribution类代码示例

本文整理汇总了Python中pants.java.distribution.distribution.Distribution的典型用法代码示例。如果您正苦于以下问题:Python Distribution类的具体用法?Python Distribution怎么用?Python Distribution使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: get_two_distributions

def get_two_distributions():
  try:
    java7 = Distribution.locate(minimum_version='1.7', maximum_version='1.7.9999')
    java8 = Distribution.locate(minimum_version='1.8', maximum_version='1.8.9999')
    return java7, java8
  except Distribution.Error:
    return None
开发者ID:areitz,项目名称:pants,代码行数:7,代码来源:test_distribution_integration.py

示例2: test_locate_trumps_path

 def test_locate_trumps_path(self):
   with self.java_home_exe() as (jdk1_home, jdk2_home):
     with distribution(executables=exe('bin/java', version='3')) as path_jdk:
       with env(PATH=os.path.join(path_jdk, 'bin')):
         dist = Distribution.locate()
         self.assertEqual(jdk1_home, dist.home)
         dist = Distribution.locate(minimum_version='3')
         self.assertEqual(path_jdk, dist.home)
开发者ID:MathewJennings,项目名称:pants,代码行数:8,代码来源:test_distribution.py

示例3: test_locate_java_home_trumps

 def test_locate_java_home_trumps(self):
   with self.java_home_exe() as (jdk1_home, jdk2_home):
     with distribution(executables=exe('bin/java', version='3')) as java_home:
       with env(JAVA_HOME=java_home):
         dist = Distribution.locate()
         self.assertEqual(java_home, dist.home)
         dist = Distribution.locate(maximum_version='1.1')
         self.assertEqual(jdk1_home, dist.home)
         dist = Distribution.locate(minimum_version='1.1', maximum_version='2')
         self.assertEqual(jdk2_home, dist.home)
开发者ID:MathewJennings,项目名称:pants,代码行数:10,代码来源:test_distribution.py

示例4: test_validate_live

  def test_validate_live(self):
    with pytest.raises(Distribution.Error):
      Distribution(bin_path=os.path.dirname(self.JAVA), minimum_version='999.9.9').validate()
    with pytest.raises(Distribution.Error):
      Distribution(bin_path=os.path.dirname(self.JAVA), maximum_version='0.0.1').validate()

    Distribution(bin_path=os.path.dirname(self.JAVA)).validate()
    Distribution(bin_path=os.path.dirname(self.JAVA), minimum_version='1.3.1').validate()
    Distribution(bin_path=os.path.dirname(self.JAVA), maximum_version='999.999.999').validate()
    Distribution(bin_path=os.path.dirname(self.JAVA), minimum_version='1.3.1',
                 maximum_version='999.999.999').validate()
    Distribution.locate(jdk=False)
开发者ID:WamBamBoozle,项目名称:pants,代码行数:12,代码来源:test_distribution.py

示例5: requirements

 def requirements(cls, tools):
   sdk_home = os.environ.get('ANDROID_HOME')
   android_sdk = os.path.abspath(sdk_home) if sdk_home else None
   if android_sdk:
     for tool in tools:
       if not os.path.isfile(os.path.join(android_sdk, tool)):
         return False
   else:
     return False
   try:
     Distribution.cached(minimum_version=cls.JAVA_MIN, maximum_version=cls.JAVA_MAX)
   except:
     return False
   return True
开发者ID:MathewJennings,项目名称:pants,代码行数:14,代码来源:android_integration_test.py

示例6: _run_tests

  def _run_tests(self, tests_to_targets, main, extra_jvm_options=None, classpath_prepend=(),
                 classpath_append=()):
    extra_jvm_options = extra_jvm_options or []

    tests_by_properties = self._tests_by_properties(tests_to_targets,
                                                    self._infer_workdir,
                                                    lambda target: target.test_platform)

    result = 0
    for (workdir, platform), tests in tests_by_properties.items():
      for batch in self._partition(tests):
        # Batches of test classes will likely exist within the same targets: dedupe them.
        relevant_targets = set(map(tests_to_targets.get, batch))
        classpath = self._task_exports.classpath(relevant_targets,
                                                 cp=self._task_exports.tool_classpath('junit'))
        complete_classpath = OrderedSet()
        complete_classpath.update(classpath_prepend)
        complete_classpath.update(classpath)
        complete_classpath.update(classpath_append)
        if self._strict_jvm_version:
          max_version = Revision(*(platform.target_level.components + [9999]))
          distribution = Distribution.cached(minimum_version=platform.target_level,
                                             maximum_version=max_version)
        else:
          distribution = Distribution.cached(minimum_version=platform.target_level)
        with binary_util.safe_args(batch, self._task_exports.task_options) as batch_tests:
          self._context.log.debug('CWD = {}'.format(workdir))
          self._context.log.debug('platform = {}'.format(platform))
          result += abs(execute_java(
            classpath=complete_classpath,
            main=main,
            jvm_options=self._task_exports.jvm_options + extra_jvm_options,
            args=self._args + batch_tests + [u'-xmlreport'],
            workunit_factory=self._context.new_workunit,
            workunit_name='run',
            workunit_labels=[WorkUnitLabel.TEST],
            cwd=workdir,
            distribution=distribution,
          ))

          if result != 0 and self._fail_fast:
            break

    if result != 0:
      failed_targets = self._get_failed_targets(tests_to_targets)
      raise TestFailedTaskError(
        'java {0} ... exited non-zero ({1}); {2} failed targets.'
        .format(main, result, len(failed_targets)),
        failed_targets=failed_targets
      )
开发者ID:areitz,项目名称:pants,代码行数:50,代码来源:junit_run.py

示例7: locate_tools_jar

 def locate_tools_jar():
   try:
     return Distribution.cached(jdk=True).find_libs(['tools.jar'])
   except Distribution.Error:
     self.context.log.info('Failed to locate tools.jar. '
                           'Install a JDK to increase performance of Zinc.')
     return []
开发者ID:TansyArron,项目名称:pants,代码行数:7,代码来源:zinc_compile.py

示例8: distribution

 def distribution(self):
   if self._dist is None:
     # Currently no Java 8 for Android. I considered max=1.7.0_50. See comment in _render_args().
     self._dist = Distribution.cached(minimum_version='1.6.0_00',
                                      maximum_version='1.7.0_99',
                                      jdk=True)
   return self._dist
开发者ID:areitz,项目名称:pants,代码行数:7,代码来源:sign_apk.py

示例9: execute_junit_runner

  def execute_junit_runner(self, content):

    # Create the temporary base test directory
    test_rel_path = 'tests/java/org/pantsbuild/foo'
    test_abs_path = os.path.join(self.build_root, test_rel_path)
    self.create_dir(test_rel_path)

    # Generate the temporary java test source code.
    test_java_file_rel_path = os.path.join(test_rel_path, 'FooTest.java')
    test_java_file_abs_path = os.path.join(self.build_root, test_java_file_rel_path)
    self.create_file(test_java_file_rel_path, content)

    # Invoke ivy to resolve classpath for junit.
    distribution = Distribution.cached(jdk=True)
    executor = SubprocessExecutor(distribution=distribution)
    classpath_file_abs_path = os.path.join(test_abs_path, 'junit.classpath')
    ivy = Bootstrapper.default_ivy()
    ivy.execute(args=['-cachepath', classpath_file_abs_path,
                      '-dependency', 'junit', 'junit-dep', '4.10'], executor=executor)
    with open(classpath_file_abs_path) as fp:
      classpath = fp.read()

    # Now directly invoking javac to compile the test java code into java class
    # so later we can inject the class into products mapping for JUnitRun to execute
    # the test on.
    javac = distribution.binary('javac')
    subprocess.check_call(
      [javac, '-d', test_abs_path, '-cp', classpath, test_java_file_abs_path])

    # Create a java_tests target and a synthetic resource target.
    java_tests = self.create_library(test_rel_path, 'java_tests', 'foo_test', ['FooTest.java'])
    resources = self.make_target('some_resources', Resources)

    # Set the context with the two targets, one java_tests target and
    # one synthetic resources target.
    # The synthetic resources target is to make sure we won't regress
    # in the future with bug like https://github.com/pantsbuild/pants/issues/508. Note
    # in that bug, the resources target must be the first one in the list.
    context = self.context(target_roots=[resources, java_tests])

    # Before we run the task, we need to inject the "classes_by_target" with
    # the compiled test java classes that JUnitRun will know which test
    # classes to execute. In a normal run, this "classes_by_target" will be
    # populated by java compiling step.
    class_products = context.products.get_data(
      'classes_by_target', lambda: defaultdict(MultipleRootedProducts))
    java_tests_products = MultipleRootedProducts()
    java_tests_products.add_rel_paths(test_abs_path, ['FooTest.class'])
    class_products[java_tests] = java_tests_products

    # Also we need to add the FooTest.class's classpath to the compile_classpath
    # products data mapping so JUnitRun will be able to add that into the final
    # classpath under which the junit will be executed.
    self.populate_compile_classpath(
      context=context,
      classpath=[test_abs_path])

    # Finally execute the task.
    self.execute(context)
开发者ID:WamBamBoozle,项目名称:pants,代码行数:59,代码来源:test_junit_run.py

示例10: test_validated_library

  def test_validated_library(self):
    with distribution(executables=EXE('bin/java')) as dist_root:
      with self.assertRaises(Distribution.Error):
        Distribution(bin_path=os.path.join(dist_root, 'bin')).find_libs(['tools.jar'])

    with distribution(executables=EXE('bin/java'), files='lib/tools.jar') as dist_root:
      dist = Distribution(bin_path=os.path.join(dist_root, 'bin'))
      self.assertEqual([os.path.join(dist_root, 'lib', 'tools.jar')],
                       dist.find_libs(['tools.jar']))

    with distribution(executables=[EXE('jre/bin/java'), EXE('bin/javac')],
                      files=['lib/tools.jar', 'jre/lib/rt.jar'],
                      java_home='jre') as dist_root:
      dist = Distribution(bin_path=os.path.join(dist_root, 'jre/bin'))
      self.assertEqual([os.path.join(dist_root, 'lib', 'tools.jar'),
                        os.path.join(dist_root, 'jre', 'lib', 'rt.jar')],
                       dist.find_libs(['tools.jar', 'rt.jar']))
开发者ID:aaronmitchell,项目名称:pants,代码行数:17,代码来源:test_distribution.py

示例11: java_sysprops

 def java_sysprops(self):
   """The system properties of the JVM we use."""
   # TODO: In the future we can use these to hermeticize the Java enivronment rather than relying
   # on whatever's on the shell's PATH. E.g., you either specify a path to the Java home via a
   # cmd-line flag or .pantsrc, or we infer one from java.home but verify that the java.version
   # is a supported version.
   if self._java_sysprops is None:
     # TODO(John Sirois): Plumb a sane default distribution through 1 point of control
     self._java_sysprops = Distribution.cached().system_properties
   return self._java_sysprops
开发者ID:jcoveney,项目名称:pants,代码行数:10,代码来源:context.py

示例12: __init__

 def __init__(self, *args, **kwargs):
   """
   :param context: inherited parameter from Task
   :param workdir: inherited parameter from Task
   """
   super(JaxbGen, self).__init__(*args, **kwargs)
   self.gen_langs = set()
   lang = 'java'
   if self.context.products.isrequired(lang):
     self.gen_langs.add(lang)
   self.jar_location = os.path.join(Distribution.cached().home, '..', 'lib', 'tools.jar')
开发者ID:arloherrine,项目名称:pants,代码行数:11,代码来源:jaxb_gen.py

示例13: __init__

  def __init__(self, distribution=None):
    """Constructs an Executor that can be used to launch java programs.

    :param distribution: an optional validated java distribution to use when launching java
      programs
    """
    if distribution:
      if not isinstance(distribution, Distribution):
        raise ValueError('A valid distribution is required, given: %s' % distribution)
      distribution.validate()
    else:
      distribution = Distribution.cached()

    self._distribution = distribution
开发者ID:Yasumoto,项目名称:pants,代码行数:14,代码来源:executor.py

示例14: __init__

  def __init__(self, context, workdir, minimum_version=None,
               maximum_version=None, jdk=False, nailgun_name=None):
    super(NailgunTaskBase, self).__init__(context, workdir)
    self._executor_workdir = os.path.join(context.config.getdefault('pants_workdir'), 'ng',
                                          nailgun_name or self.__class__.__name__)
    self._nailgun_bootstrap_key = 'nailgun'
    self.register_jvm_tool(self._nailgun_bootstrap_key, [':nailgun-server'])

    with self.context.new_workunit(name='jvm-locate'):
      try:
        self._dist = Distribution.cached(minimum_version=minimum_version,
                                         maximum_version=maximum_version, jdk=jdk)
      except Distribution.Error as e:
        raise TaskError(e)
开发者ID:cheecheeo,项目名称:pants,代码行数:14,代码来源:nailgun_task.py

示例15: create_javadoc_command

    def create_javadoc_command(self, classpath, gendir, *targets):
        sources = []
        for target in targets:
            sources.extend(target.sources_relative_to_buildroot())

        if not sources:
            return None

        # Without a JDK/tools.jar we have no javadoc tool and cannot proceed, so check/acquire early.
        jdk = Distribution.cached(jdk=True)
        tool_classpath = jdk.find_libs(["tools.jar"])

        args = ["-quiet", "-encoding", "UTF-8", "-notimestamp", "-use", "-classpath", ":".join(classpath), "-d", gendir]

        # Always provide external linking for java API
        offlinelinks = {"http://download.oracle.com/javase/6/docs/api/"}

        def link(target):
            for jar in target.jar_dependencies:
                if jar.apidocs:
                    offlinelinks.add(jar.apidocs)

        for target in targets:
            target.walk(link, lambda t: t.is_jvm)

        for link in offlinelinks:
            args.extend(["-linkoffline", link, link])

        args.extend(self.args)

        args.extend(sources)

        java_executor = SubprocessExecutor(jdk)
        runner = java_executor.runner(
            jvm_options=self.jvm_options, classpath=tool_classpath, main="com.sun.tools.javadoc.Main", args=args
        )
        return runner.command
开发者ID:pcurry,项目名称:pants,代码行数:37,代码来源:javadoc_gen.py


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