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


Python Devices.from_device_number方法代码示例

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


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

示例1: test_from_device_number

# 需要导入模块: from pyudev import Devices [as 别名]
# 或者: from pyudev.Devices import from_device_number [as 别名]
 def test_from_device_number(self, a_context, device_datum):
     mode = os.stat(device_datum.device_node).st_mode
     typ = 'block' if stat.S_ISBLK(mode) else 'char'
     device = Devices.from_device_number(
         a_context, typ, device_datum.device_number)
     assert device.device_number == device_datum.device_number
     # make sure, we are really referring to the same device
     assert device.device_path == device_datum.device_path
开发者ID:cjmayo,项目名称:pyudev,代码行数:10,代码来源:_devices_tests.py

示例2: test_from_device_number_wrong_type

# 需要导入模块: from pyudev import Devices [as 别名]
# 或者: from pyudev.Devices import from_device_number [as 别名]
 def test_from_device_number_wrong_type(
     self,
     a_context,
     device_datum
 ):
     mode = os.stat(device_datum.device_node).st_mode
     # deliberately use the wrong type here to cause either failure
     # or at least device mismatch
     typ = 'char' if stat.S_ISBLK(mode) else 'block'
     try:
         # this either fails, in which case the caught exception is
         # raised, or succeeds, but returns a wrong device
         # (device numbers are not unique across device types)
         device = Devices.from_device_number(
             a_context, typ, device_datum.device_number)
         # if it succeeds, the resulting device must not match the
         # one, we are actually looking for!
         assert device.device_path != device_datum.device_path
     except DeviceNotFoundByNumberError as error:
         # check the correctness of the exception attributes
         assert error.device_type == typ
         assert error.device_number == device_datum.device_number
开发者ID:cjmayo,项目名称:pyudev,代码行数:24,代码来源:_devices_tests.py

示例3: test_from_device_number_invalid_type

# 需要导入模块: from pyudev import Devices [as 别名]
# 或者: from pyudev.Devices import from_device_number [as 别名]
 def test_from_device_number_invalid_type(self, a_context):
     with pytest.raises(DeviceNotFoundByNumberError):
         Devices.from_device_number(a_context, 'foobar', 100)
开发者ID:cjmayo,项目名称:pyudev,代码行数:5,代码来源:_devices_tests.py


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