本文整理匯總了Python中rospkg.os_detect.OsDetect類的典型用法代碼示例。如果您正苦於以下問題:Python OsDetect類的具體用法?Python OsDetect怎麽用?Python OsDetect使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了OsDetect類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_OsDetect
def test_OsDetect():
from rospkg.os_detect import OsDetect
detect = OsDetect()
try:
detect.get_detector('fake')
assert False, "should raise"
except KeyError: pass
示例2: test_OsDetect_ROS_OVERRIDE
def test_OsDetect_ROS_OVERRIDE():
from rospkg.os_detect import OsDetect
detect = OsDetect([('TrueOs', TrueOs())])
env = {'ROS_OS_OVERRIDE': 'arch'}
assert detect.detect_os(env=env) == ('arch', '', ''), detect.detect_os(env=env)
env = {'ROS_OS_OVERRIDE': 'fubuntu:04.10'}
assert detect.detect_os(env=env) == ('fubuntu', '04.10', '')
env = {'ROS_OS_OVERRIDE': 'fubuntu:04.10:opaque'}
assert detect.detect_os(env=env) == ('fubuntu', '04.10', 'opaque')
示例3: test_OsDetect_single
def test_OsDetect_single():
# test each method twice with new instance b/c of caching
from rospkg.os_detect import OsDetect
detect = OsDetect([('TrueOs', TrueOs())])
assert "TrueOs" == detect.get_name()
assert "TrueOs" == detect.get_name()
detect = OsDetect([('TrueOs', TrueOs())])
assert "os_version" == detect.get_version()
assert "os_version" == detect.get_version()
detect = OsDetect([('TrueOs', TrueOs())])
assert "os_codename" == detect.get_codename()
assert "os_codename" == detect.get_codename()
detect = OsDetect([('TrueOs', TrueOs())])
assert isinstance(detect.get_detector(), TrueOs)
assert isinstance(detect.get_detector('TrueOs'), TrueOs)
示例4: test_ubuntu
def test_ubuntu():
from rospkg.os_detect import OsDetect, OsNotDetected
os_detector = OsDetect()
detect = os_detector.get_detector('ubuntu')
detect.lsb_info = ('Ubuntu', '10.04', 'lucid')
assert detect.get_version() == '10.04', detect.get_version()
assert detect.get_codename() == 'lucid', detect.get_codename()
# test freely
if not detect.is_os():
try:
detect.get_version()
assert False
except OsNotDetected:
pass
try:
detect.get_codename()
assert False
except OsNotDetected:
pass
示例5: test_OsDetect_nomatch
def test_OsDetect_nomatch():
from rospkg.os_detect import OsDetect, OsNotDetected
detect = OsDetect([('Dummy', FalseOs())])
assert isinstance(detect.get_detector('Dummy'), FalseOs)
try:
detect.get_name()
assert False
except OsNotDetected: pass
try:
detect.get_version()
assert False
except OsNotDetected: pass
try:
detect.get_detector()
assert False
except OsNotDetected: pass
示例6: test_ubuntu
def test_ubuntu():
import rospkg.os_detect
from rospkg.os_detect import LsbDetect, OsDetect, OsNotDetected
test_dir = os.path.join(get_test_dir(), 'ubuntu')
rospkg.os_detect._lsb_release = os.path.join(test_dir, 'lsb_release')
detect = OsDetect().get_detector('ubuntu')
assert detect.is_os()
assert detect.get_version() == '10.04'
assert detect.get_codename() == 'lucid'
# test freely
if not detect.is_os():
try:
detect.get_version()
assert False
except OsNotDetected: pass
try:
detect.get_codename()
assert False
except OsNotDetected: pass
示例7: test_tripwire_freebsd
def test_tripwire_freebsd():
from rospkg.os_detect import OsDetect
os_detect = OsDetect()
os_detect.get_detector('freebsd')
示例8: test_tripwire_rhel
def test_tripwire_rhel():
from rospkg.os_detect import OsDetect
os_detect = OsDetect()
os_detect.get_detector('rhel')
示例9: test_tripwire_fedora
def test_tripwire_fedora():
from rospkg.os_detect import OsDetect
os_detect = OsDetect()
os_detect.get_detector('fedora')
示例10: test_tripwire_gentoo
def test_tripwire_gentoo():
from rospkg.os_detect import OsDetect
os_detect = OsDetect()
os_detect.get_detector('gentoo')
示例11: test_tripwire_opensuse
def test_tripwire_opensuse():
from rospkg.os_detect import OsDetect
os_detect = OsDetect()
os_detect.get_detector('opensuse')
示例12: test_tripwire_slackware
def test_tripwire_slackware():
from rospkg.os_detect import OsDetect
os_detect = OsDetect()
os_detect.get_detector('slackware')
示例13: test_tripwire_osx
def test_tripwire_osx():
from rospkg.os_detect import OsDetect
os_detect = OsDetect()
os_detect.get_detector('osx')
示例14: test_tripwire_debian
def test_tripwire_debian():
from rospkg.os_detect import OsDetect
os_detect = OsDetect()
os_detect.get_detector('debian')
示例15: test_OsDetect_register_default_add_detector
def test_OsDetect_register_default_add_detector():
# test behavior of register_default and add_detector. Both take
# precedence over previous detectors, but at different scopes.
from rospkg.os_detect import OsDetect
o1 = TrueOs()
o2 = TrueOs2()
key = 'TrueOs'
detect = OsDetect([(key, o1)])
assert detect.get_detector(key) == o1
detect.register_default(key, o2)
assert detect.get_detector(key) == o1
detect.add_detector(key, o2)
assert detect.get_detector(key) == o2
detect = OsDetect()
assert detect.get_detector(key) == o2
detect.add_detector(key, o1)
assert detect.get_detector(key) == o1
# restore precendence of o1 in default list
detect.register_default(key, o1)
detect = OsDetect()
assert detect.get_detector(key) == o1