當前位置: 首頁>>代碼示例>>Python>>正文


Python errno.ENODEV屬性代碼示例

本文整理匯總了Python中errno.ENODEV屬性的典型用法代碼示例。如果您正苦於以下問題:Python errno.ENODEV屬性的具體用法?Python errno.ENODEV怎麽用?Python errno.ENODEV使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在errno的用法示例。


在下文中一共展示了errno.ENODEV屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: net_if_stats

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def net_if_stats():
    """Get NIC stats (isup, duplex, speed, mtu)."""
    names = net_io_counters().keys()
    ret = {}
    for name in names:
        try:
            mtu = cext_posix.net_if_mtu(name)
            isup = cext_posix.net_if_flags(name)
            duplex, speed = cext_posix.net_if_duplex_speed(name)
        except OSError as err:
            # https://github.com/giampaolo/psutil/issues/1279
            if err.errno != errno.ENODEV:
                raise
        else:
            if hasattr(_common, 'NicDuplex'):
                duplex = _common.NicDuplex(duplex)
            ret[name] = _common.snicstats(isup, duplex, speed, mtu)
    return ret 
開發者ID:giampaolo,項目名稱:psutil,代碼行數:20,代碼來源:_psbsd.py

示例2: read

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def read(self, timeout=0):
        if self.usb_inp is not None:
            try:
                ep_addr = self.usb_inp.getAddress()
                frame = self.usb_dev.bulkRead(ep_addr, 300, timeout)
            except libusb.USBErrorTimeout:
                raise IOError(errno.ETIMEDOUT, os.strerror(errno.ETIMEDOUT))
            except libusb.USBErrorNoDevice:
                raise IOError(errno.ENODEV, os.strerror(errno.ENODEV))
            except libusb.USBError as error:
                log.error("%r", error)
                raise IOError(errno.EIO, os.strerror(errno.EIO))

            if len(frame) == 0:
                log.error("bulk read returned zero data")
                raise IOError(errno.EIO, os.strerror(errno.EIO))

            frame = bytearray(frame)
            log.log(logging.DEBUG-1, "<<< %s", hexlify(frame).decode())
            return frame 
開發者ID:nfcpy,項目名稱:nfcpy,代碼行數:22,代碼來源:transport.py

示例3: test_init_sam_cfg_ack_err

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def test_init_sam_cfg_ack_err(self, mocker, transport):  # noqa: F811
        mocker.patch('nfc.clf.pn532.Device.__init__').return_value = None
        sys.platform = ""

        transport.write.return_value = None
        transport.read.side_effect = [
            ACK(), RSP('03 32010607'),                    # GetFirmwareVersion
            ERR(),                                        # SAMConfiguration
        ]
        with pytest.raises(IOError) as excinfo:
            nfc.clf.pn532.init(transport)
        assert excinfo.value.errno == errno.ENODEV
        assert transport.write.mock_calls == [call(_) for _ in [
            HEX(10 * '00') + CMD('02'),                   # GetFirmwareVersion
            HEX(10 * '00') + CMD('14 010000'),            # SAMConfiguration
        ]] 
開發者ID:nfcpy,項目名稱:nfcpy,代碼行數:18,代碼來源:test_clf_pn532.py

示例4: test_init_sam_cfg_rsp_err

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def test_init_sam_cfg_rsp_err(self, mocker, transport):  # noqa: F811
        mocker.patch('nfc.clf.pn532.Device.__init__').return_value = None
        sys.platform = ""

        transport.write.return_value = None
        transport.read.side_effect = [
            ACK(), RSP('03 32010607'),                    # GetFirmwareVersion
            ACK(), ERR(),                                 # SAMConfiguration
        ]
        with pytest.raises(IOError) as excinfo:
            nfc.clf.pn532.init(transport)
        assert excinfo.value.errno == errno.ENODEV
        assert transport.write.mock_calls == [call(_) for _ in [
            HEX(10 * '00') + CMD('02'),                   # GetFirmwareVersion
            HEX(10 * '00') + CMD('14 010000'),            # SAMConfiguration
        ]] 
開發者ID:nfcpy,項目名稱:nfcpy,代碼行數:18,代碼來源:test_clf_pn532.py

示例5: net_if_stats

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def net_if_stats():
    """Get NIC stats (isup, duplex, speed, mtu)."""
    duplex_map = {cext.DUPLEX_FULL: NIC_DUPLEX_FULL,
                  cext.DUPLEX_HALF: NIC_DUPLEX_HALF,
                  cext.DUPLEX_UNKNOWN: NIC_DUPLEX_UNKNOWN}
    names = net_io_counters().keys()
    ret = {}
    for name in names:
        try:
            mtu = cext_posix.net_if_mtu(name)
            isup = cext_posix.net_if_flags(name)
            duplex, speed = cext.net_if_duplex_speed(name)
        except OSError as err:
            # https://github.com/giampaolo/psutil/issues/1279
            if err.errno != errno.ENODEV:
                raise
        else:
            ret[name] = _common.snicstats(isup, duplex_map[duplex], speed, mtu)
    return ret


# =====================================================================
# --- disks
# ===================================================================== 
開發者ID:giampaolo,項目名稱:psutil,代碼行數:26,代碼來源:_pslinux.py

示例6: net_if_stats

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def net_if_stats():
    """Get NIC stats (isup, duplex, speed, mtu)."""
    names = net_io_counters().keys()
    ret = {}
    for name in names:
        try:
            mtu = cext_posix.net_if_mtu(name)
            isup = cext_posix.net_if_flags(name)
            duplex, speed = cext_posix.net_if_duplex_speed(name)
        except OSError as err:
            # https://github.com/giampaolo/psutil/issues/1279
            if err.errno != errno.ENODEV:
                raise
        else:
            if hasattr(_common, 'NicDuplex'):
                duplex = _common.NicDuplex(duplex)
            ret[name] = _common.snicstats(isup, duplex, speed, mtu)
    return ret


# =====================================================================
# --- other system functions
# ===================================================================== 
開發者ID:giampaolo,項目名稱:psutil,代碼行數:25,代碼來源:_psosx.py

示例7: play_sound_file

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def play_sound_file(path):
    fp = open(path, 'r')
    size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
    data = fp.read()
    fp.close()

    if enc != SND_FORMAT_MULAW_8:
        print "Expect .au file with 8-bit mu-law samples"
        return

    try:
        a = linuxaudiodev.open('w')
    except linuxaudiodev.error, msg:
        if msg[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY):
            raise TestSkipped, msg
        raise TestFailed, msg

    # convert the data to 16-bit signed 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:20,代碼來源:test_linuxaudiodev.py

示例8: get_interface_mac

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def get_interface_mac(sock: socket.socket, ifname: str) -> str:
    """Obtain a network interface's MAC address, as a string."""
    ifreq = struct.pack(b"256s", ifname.encode("utf-8")[:15])
    try:
        info = fcntl.ioctl(sock.fileno(), SIOCGIFHWADDR, ifreq)
    except OSError as e:
        if e.errno is not None and e.errno == errno.ENODEV:
            raise InterfaceNotFound("Interface not found: '%s'." % ifname)
        else:
            raise MACAddressNotAvailable(
                "Failed to get MAC address for '%s': %s."
                % (ifname, strerror(e.errno))
            )
    else:
        # Of course we're sure these are the correct indexes into the `ifreq`.
        # Also, your lack of faith is disturbing.
        mac = "".join("%02x:" % char for char in info[18:24])[:-1]
    return mac 
開發者ID:maas,項目名稱:maas,代碼行數:20,代碼來源:detect.py

示例9: play_sound_file

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def play_sound_file(self, data, rate, ssize, nchannels):
        try:
            dsp = ossaudiodev.open('w')
        except IOError, msg:
            if msg.args[0] in (errno.EACCES, errno.ENOENT,
                               errno.ENODEV, errno.EBUSY):
                raise unittest.SkipTest(msg)
            raise

        # at least check that these methods can be invoked 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:12,代碼來源:test_ossaudiodev.py

示例10: test_main

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def test_main():
    try:
        dsp = ossaudiodev.open('w')
    except (ossaudiodev.error, IOError), msg:
        if msg.args[0] in (errno.EACCES, errno.ENOENT,
                           errno.ENODEV, errno.EBUSY):
            raise unittest.SkipTest(msg)
        raise 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:10,代碼來源:test_ossaudiodev.py

示例11: test_main

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def test_main():
    try:
        dsp = linuxaudiodev.open('w')
    except linuxaudiodev.error, msg:
        if msg.args[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY):
            raise unittest.SkipTest(msg)
        raise 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:test_linuxaudiodev.py

示例12: __init__

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def __init__(self, path=None):
        self.device = None
        self.target = None
        self.lock = threading.Lock()
        if path and not self.open(path):
            raise IOError(errno.ENODEV, os.strerror(errno.ENODEV)) 
開發者ID:nfcpy,項目名稱:nfcpy,代碼行數:8,代碼來源:__init__.py

示例13: exchange

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def exchange(self, send_data, timeout):
        """Exchange data with an activated target (*send_data* is a command
        frame) or as an activated target (*send_data* is a response
        frame). Returns a target response frame (if data is send to an
        activated target) or a next command frame (if data is send
        from an activated target). Returns None if the communication
        link broke during exchange (if data is sent as a target). The
        timeout is the number of seconds to wait for data to return,
        if the timeout expires an nfc.clf.TimeoutException is
        raised. Other nfc.clf.CommunicationError exceptions may be raised if
        an error is detected during communication.

        """
        with self.lock:
            if self.device is None:
                raise IOError(errno.ENODEV, os.strerror(errno.ENODEV))

            log.debug(">>> %s timeout=%s", print_data(send_data), str(timeout))

            if isinstance(self.target, RemoteTarget):
                exchange = self.device.send_cmd_recv_rsp
            elif isinstance(self.target, LocalTarget):
                exchange = self.device.send_rsp_recv_cmd
            else:
                log.error("no target for data exchange")
                return None

            send_time = time.time()
            rcvd_data = exchange(self.target, send_data, timeout)
            recv_time = time.time() - send_time

            log.debug("<<< %s %.3fs", print_data(rcvd_data), recv_time)
            return rcvd_data 
開發者ID:nfcpy,項目名稱:nfcpy,代碼行數:35,代碼來源:__init__.py

示例14: max_send_data_size

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def max_send_data_size(self):
        """The maximum number of octets that can be send with the
        :meth:`exchange` method in the established operating mode.

        """
        with self.lock:
            if self.device is None:
                raise IOError(errno.ENODEV, os.strerror(errno.ENODEV))
            else:
                return self.device.get_max_send_data_size(self.target) 
開發者ID:nfcpy,項目名稱:nfcpy,代碼行數:12,代碼來源:__init__.py

示例15: max_recv_data_size

# 需要導入模塊: import errno [as 別名]
# 或者: from errno import ENODEV [as 別名]
def max_recv_data_size(self):
        """The maximum number of octets that can be received with the
        :meth:`exchange` method in the established operating mode.

        """
        with self.lock:
            if self.device is None:
                raise IOError(errno.ENODEV, os.strerror(errno.ENODEV))
            else:
                return self.device.get_max_recv_data_size(self.target) 
開發者ID:nfcpy,項目名稱:nfcpy,代碼行數:12,代碼來源:__init__.py


注:本文中的errno.ENODEV屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。