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


Python Distribution.locate方法代码示例

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


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

示例1: get_two_distributions

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
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,代码行数:9,代码来源:test_distribution_integration.py

示例2: test_locate_trumps_path

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
 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,代码行数:10,代码来源:test_distribution.py

示例3: test_locate_java_home_trumps

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
 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,代码行数:12,代码来源:test_distribution.py

示例4: test_validate_live

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
  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,代码行数:14,代码来源:test_distribution.py

示例5: test_locate_jdk2

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
 def test_locate_jdk2(self):
   with env():
     with self.java_home_exe() as (_, jdk2_home):
       dist = Distribution.locate(minimum_version='2')
       self.assertEqual(jdk2_home, dist.home)
开发者ID:MathewJennings,项目名称:pants,代码行数:7,代码来源:test_distribution.py

示例6: test_locate_jdk1

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
 def test_locate_jdk1(self):
   with env():
     with self.java_home_exe() as (jdk1_home, _):
       dist = Distribution.locate()
       self.assertEqual(jdk1_home, dist.home)
开发者ID:MathewJennings,项目名称:pants,代码行数:7,代码来源:test_distribution.py

示例7: test_locate_none

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
 def test_locate_none(self):
   with env():
     with self.assertRaises(Distribution.Error):
       Distribution.locate()
开发者ID:MathewJennings,项目名称:pants,代码行数:6,代码来源:test_distribution.py

示例8: test_locate

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
  def test_locate(self):
    @contextmanager
    def env(**kwargs):
      environment = dict(JDK_HOME=None, JAVA_HOME=None, PATH=None)
      environment.update(**kwargs)
      with environment_as(**environment):
        yield

    with pytest.raises(Distribution.Error):
      with env():
        Distribution.locate()

    with pytest.raises(Distribution.Error):
      with self.distribution(files='java') as jdk:
        with env(PATH=jdk):
          Distribution.locate()

    with pytest.raises(Distribution.Error):
      with self.distribution(executables=self.exe('java')) as jdk:
        with env(PATH=jdk):
          Distribution.locate(jdk=True)

    with pytest.raises(Distribution.Error):
      with self.distribution(executables=self.exe('java', '1.6.0')) as jdk:
        with env(PATH=jdk):
          Distribution.locate(minimum_version='1.7.0')
      with self.distribution(executables=self.exe('java', '1.8.0')) as jdk:
        with env(PATH=jdk):
          Distribution.locate(maximum_version='1.7.999')

    with pytest.raises(Distribution.Error):
      with self.distribution(executables=self.exe('java')) as jdk:
        with env(JDK_HOME=jdk):
          Distribution.locate()

    with pytest.raises(Distribution.Error):
      with self.distribution(executables=self.exe('java')) as jdk:
        with env(JAVA_HOME=jdk):
          Distribution.locate()

    with self.distribution(executables=self.exe('java')) as jdk:
      with env(PATH=jdk):
        Distribution.locate()

    with self.distribution(executables=[self.exe('java'), self.exe('javac')]) as jdk:
      with env(PATH=jdk):
        Distribution.locate(jdk=True)

    with self.distribution(executables=self.exe('java', '1.7.0')) as jdk:
      with env(PATH=jdk):
        Distribution.locate(minimum_version='1.6.0')
      with env(PATH=jdk):
        Distribution.locate(maximum_version='1.7.999')
      with env(PATH=jdk):
        Distribution.locate(minimum_version='1.6.0', maximum_version='1.7.999')

    with self.distribution(executables=self.exe('bin/java')) as jdk:
      with env(JDK_HOME=jdk):
        Distribution.locate()

    with self.distribution(executables=self.exe('bin/java')) as jdk:
      with env(JAVA_HOME=jdk):
        Distribution.locate()
开发者ID:cheecheeo,项目名称:pants,代码行数:65,代码来源:test_distribution.py

示例9: test_locate_jdk_via_jre_path

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
 def test_locate_jdk_via_jre_path(self):
   with distribution(executables=[exe('jre/bin/java'), exe('bin/javac')],
                     java_home='jre') as dist_root:
     with env(PATH=os.path.join(dist_root, 'jre', 'bin')):
       Distribution.locate(jdk=True)
开发者ID:MathewJennings,项目名称:pants,代码行数:7,代码来源:test_distribution.py

示例10: test_locate_jdk_by_path

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
 def test_locate_jdk_by_path(self):
   with distribution(executables=[exe('bin/java'), exe('bin/javac')]) as dist_root:
     with env(PATH=os.path.join(dist_root, 'bin')):
       Distribution.locate(jdk=True)
开发者ID:MathewJennings,项目名称:pants,代码行数:6,代码来源:test_distribution.py

示例11: test_locate_jre_by_path

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
 def test_locate_jre_by_path(self):
   with distribution(executables=exe('bin/java')) as dist_root:
     with env(PATH=os.path.join(dist_root, 'bin')):
       Distribution.locate()
开发者ID:MathewJennings,项目名称:pants,代码行数:6,代码来源:test_distribution.py

示例12: test_locate_invalid_java_home

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
 def test_locate_invalid_java_home(self):
   with distribution(executables=exe('java')) as dist_root:
     with env(JAVA_HOME=dist_root):
       with self.assertRaises(Distribution.Error):
         Distribution.locate()
开发者ID:MathewJennings,项目名称:pants,代码行数:7,代码来源:test_distribution.py

示例13: test_locate_version_to_high

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
 def test_locate_version_to_high(self):
   with distribution(executables=exe('bin/java', '1.8.0')) as dist_root:
     with env(PATH=os.path.join(dist_root, 'bin')):
       with self.assertRaises(Distribution.Error):
         Distribution.locate(maximum_version='1.7.999')
开发者ID:MathewJennings,项目名称:pants,代码行数:7,代码来源:test_distribution.py

示例14: test_locate_jdk_is_jre

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
 def test_locate_jdk_is_jre(self):
   with distribution(executables=exe('bin/java')) as dist_root:
     with env(PATH=os.path.join(dist_root, 'bin')):
       with self.assertRaises(Distribution.Error):
         Distribution.locate(jdk=True)
开发者ID:MathewJennings,项目名称:pants,代码行数:7,代码来源:test_distribution.py

示例15: test_locate_java_not_executable

# 需要导入模块: from pants.java.distribution.distribution import Distribution [as 别名]
# 或者: from pants.java.distribution.distribution.Distribution import locate [as 别名]
 def test_locate_java_not_executable(self):
   with distribution(files='bin/java') as dist_root:
     with env(PATH=os.path.join(dist_root, 'bin')):
       with self.assertRaises(Distribution.Error):
         Distribution.locate()
开发者ID:MathewJennings,项目名称:pants,代码行数:7,代码来源:test_distribution.py


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