本文整理汇总了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
示例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)
示例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)
示例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)
示例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)
示例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)
示例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()
示例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()
示例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)
示例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)
示例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()
示例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()
示例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')
示例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)
示例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()