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


Python errorcode.get方法代码示例

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


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

示例1: get_celery_worker_status

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def get_celery_worker_status():
    """
    Detects if working
    """
    # from
    # http://stackoverflow.com/questions/8506914/detect-whether-celery-is-available-running
    ERROR_KEY = "ERROR"
    try:
        from celery.task.control import inspect
        insp = inspect()
        d = insp.stats()
        if not d:
            d = {ERROR_KEY: 'No running Celery workers were found.'}
    except IOError as e:
        from errno import errorcode
        msg = "Error connecting to the backend: " + str(e)
        if len(e.args) > 0 and errorcode.get(e.args[0]) == 'ECONNREFUSED':
            msg += ' Check that the RabbitMQ server is running.'
        d = {ERROR_KEY: msg}
    except ImportError as e:
        d = {ERROR_KEY: str(e)}
    return d 
开发者ID:seanbell,项目名称:opensurfaces,代码行数:24,代码来源:utils.py

示例2: _final_handshake

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def _final_handshake(cls, handshake_state, buf, tx):
        if "session" not in handshake_state:
            logger.warning("Recv unexcept final handshake")
            return None

        data = msgpack.unpackb(buf, use_list=False, encoding="utf8",
                               unicode_errors="ignore")

        if data.get("session") == handshake_state["session"]:
            endpoint_profile = handshake_state["endpoint"]
            endpoint_profile["final"] = data
            logger.info("Host2Host USB Connected")
            logger.debug("Serial: %(serial)s {%(uuid)s}\nModel: %(model)s\n"
                         "Name: %(nickname)s\n", endpoint_profile)
            return endpoint_profile
        else:
            logger.info("USB final handshake error with wrong session "
                        "recv=%i, except=%i", data["session"],
                        endpoint_profile["session"])
            return None 
开发者ID:flux3dp,项目名称:fluxclient,代码行数:22,代码来源:host2host_usb.py

示例3: _write

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def _write(cls, tx, buf):
        # Low level send
        try:
            l = len(buf)
            ret = tx.write(buf[:512])
            while ret < l:
                ret += tx.write(buf[ret:ret + 512])

        except usb.core.USBError as e:
            if e.errno == ETIMEDOUT or e.backend_error_code == -116:
                raise FluxUSBError(*e.args, symbol=("TIMEOUT", ))
            else:
                logger.error("unhandle libusb error: %s", e)
                raise FluxUSBError(*e.args,
                                   symbol=("UNKNOWN_ERROR",
                                           errorcode.get(e.errno, e.errno))) 
开发者ID:flux3dp,项目名称:fluxclient,代码行数:18,代码来源:host2host_usb.py

示例4: _send

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def _send(self, buf):
        # Low level send
        try:
            l = len(buf)
            with self.tx_mutex:
                ret = self._tx.write(buf[:512])
                while ret < l:
                    ret += self._tx.write(buf[ret:ret + 512])

        except usb.core.USBError as e:
            self.close()
            if e.errno == ETIMEDOUT:
                raise FluxUSBError(*e.args, symbol=("TIMEOUT", ))
            else:
                raise FluxUSBError(*e.args,
                                   symbol=("UNKNOWN_ERROR",
                                           errorcode.get(e.errno, e.errno))) 
开发者ID:flux3dp,项目名称:fluxclient,代码行数:19,代码来源:host2host_usb.py

示例5: _on_channel_ctrl_response

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def _on_channel_ctrl_response(self, obj):
        index = obj.get(b"channel")
        status = obj.get(b"status")
        action = obj.get(b"action")
        if action == b"open":
            if status == b"ok":
                self.channels[index] = Channel(self, index)
                self.chl_semaphore.release()
                logger.info("Channel %i opened", index)
            else:
                logger.error("Channel %i open failed", index)
        elif action == b"close":
            if status == b"ok":
                self.channels.pop(index)
                logger.info("Channel %i closed", index)
            else:
                logger.error("Channel %i close failed", index)
        else:
            logger.error("Unknown channel action: %r", action) 
开发者ID:flux3dp,项目名称:fluxclient,代码行数:21,代码来源:host2host_usb.py

示例6: open_channel

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def open_channel(self, channel_type="robot", timeout=10.0):
        # Send request
        with self.chl_open_mutex:
            idx = None
            for i in range(len(self.channels) + 1):
                if self.channels.get(i) is None:
                    idx = i
            logger.info("Request channel %i with type %s", idx, channel_type)
            self.send_object(0xf0, {"channel": idx, "action": "open",
                                    "type": channel_type})

            self.chl_semaphore.acquire(timeout=timeout)
            channel = self.channels.get(idx)
            if channel:
                return self.channels[idx]
            else:
                raise FluxUSBError("Channel creation failed") 
开发者ID:flux3dp,项目名称:fluxclient,代码行数:19,代码来源:host2host_usb.py

示例7: send

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def send(self, buf, flags=0):
        """
        Send data on the connection. NOTE: If you get one of the WantRead,
        WantWrite or WantX509Lookup exceptions on this, you have to call the
        method again with the SAME buffer.

        :param buf: The string, buffer or memoryview to send
        :param flags: (optional) Included for compatibility with the socket
                      API, the value is ignored
        :return: The number of bytes written
        """
        # Backward compatibility
        buf = _text_to_bytes_and_warn("buf", buf)

        with _from_buffer(buf) as data:
            # check len(buf) instead of len(data) for testability
            if len(buf) > 2147483647:
                raise ValueError(
                    "Cannot send more than 2**31-1 bytes at once."
                )

            result = _lib.SSL_write(self._ssl, data, len(data))
            self._raise_ssl_error(self._ssl, result)

            return result 
开发者ID:pyca,项目名称:pyopenssl,代码行数:27,代码来源:SSL.py

示例8: get_celery_worker_status

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def get_celery_worker_status():
    ERROR_KEY = "ERROR"
    try:
        from celery.task.control import inspect
        insp = inspect()
        d = insp.stats()
        if not d:
            d = {ERROR_KEY: 'No running Celery workers were found.'}
    except IOError as e:
        from errno import errorcode
        msg = "Error connecting to the backend: " + str(e)
        if len(e.args) > 0 and errorcode.get(e.args[0]) == 'ECONNREFUSED':
            msg += ' Check that the RabbitMQ server is running.'
        d = {ERROR_KEY: msg}
    except ImportError as e:
        d = {ERROR_KEY: str(e)}
    return d 
开发者ID:neon-jungle,项目名称:wagtail-linkchecker,代码行数:19,代码来源:scanner.py

示例9: celery_check

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def celery_check(main):
    '''
    Function to check if Celery workers are up and running.
    '''
    try:
        from celery import Celery
        broker = main.CELERY_BROKER_URL
        backend = main.CELERY_RESULTS_BACKEND
        app = Celery('celery_tasks', broker=broker, backend=backend)
        app.config_from_object('celery_config')
        if not app.control.inspect().stats() and not app.control.inspect().ping():
            raise Exception("Start celery workers. None running.")
        return True

    except IOError as e:
        msg = "Error connecting to the backend: " + str(e)
        from errno import errorcode
        if len(e.args) > 0 and errorcode.get(e.args[0]) == 'ECONNREFUSED':
            raise Exception("Check that the RabbitMQ server is running.")

    except ImportError as e:
        raise Exception("Celery module not available. Please install")


###########################################################
# Usage
########################################################### 
开发者ID:osssanitizer,项目名称:osspolice,代码行数:29,代码来源:detector.py

示例10: __init__

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def __init__(self, callback):
        _CallbackExceptionHelper.__init__(self)

        @wraps(callback)
        def wrapper(ssl, out, outlen, arg):
            try:
                conn = Connection._reverse_mapping[ssl]
                protos = callback(conn)

                # Join the protocols into a Python bytestring, length-prefixing
                # each element.
                protostr = b''.join(
                    chain.from_iterable((int2byte(len(p)), p) for p in protos)
                )

                # Save our callback arguments on the connection object. This is
                # done to make sure that they don't get freed before OpenSSL
                # uses them. Then, return them appropriately in the output
                # parameters.
                conn._npn_advertise_callback_args = [
                    _ffi.new("unsigned int *", len(protostr)),
                    _ffi.new("unsigned char[]", protostr),
                ]
                outlen[0] = conn._npn_advertise_callback_args[0][0]
                out[0] = conn._npn_advertise_callback_args[1]
                return 0
            except Exception as e:
                self._problems.append(e)
                return 2  # SSL_TLSEXT_ERR_ALERT_FATAL

        self.callback = _ffi.callback(
            "int (*)(SSL *, const unsigned char **, unsigned int *, void *)",
            wrapper
        ) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:36,代码来源:SSL.py

示例11: _raise_ssl_error

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def _raise_ssl_error(self, ssl, result):
        if self._context._verify_helper is not None:
            self._context._verify_helper.raise_if_problem()
        if self._context._npn_advertise_helper is not None:
            self._context._npn_advertise_helper.raise_if_problem()
        if self._context._npn_select_helper is not None:
            self._context._npn_select_helper.raise_if_problem()
        if self._context._alpn_select_helper is not None:
            self._context._alpn_select_helper.raise_if_problem()

        error = _lib.SSL_get_error(ssl, result)
        if error == _lib.SSL_ERROR_WANT_READ:
            raise WantReadError()
        elif error == _lib.SSL_ERROR_WANT_WRITE:
            raise WantWriteError()
        elif error == _lib.SSL_ERROR_ZERO_RETURN:
            raise ZeroReturnError()
        elif error == _lib.SSL_ERROR_WANT_X509_LOOKUP:
            # TODO: This is untested.
            raise WantX509LookupError()
        elif error == _lib.SSL_ERROR_SYSCALL:
            if _lib.ERR_peek_error() == 0:
                if result < 0:
                    if platform == "win32":
                        errno = _ffi.getwinerror()[0]
                    else:
                        errno = _ffi.errno
                    raise SysCallError(errno, errorcode.get(errno))
                else:
                    raise SysCallError(-1, "Unexpected EOF")
            else:
                # TODO: This is untested.
                _raise_current_error()
        elif error == _lib.SSL_ERROR_NONE:
            pass
        else:
            _raise_current_error() 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:39,代码来源:SSL.py

示例12: recv

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def recv(self, bufsiz, flags=None):
        """
        Receive data on the connection. NOTE: If you get one of the WantRead,
        WantWrite or WantX509Lookup exceptions on this, you have to call the
        method again with the SAME buffer.

        :param bufsiz: The maximum number of bytes to read
        :param flags: (optional) Included for compatibility with the socket
                      API, the value is ignored
        :return: The string read from the Connection
        """
        buf = _ffi.new("char[]", bufsiz)
        result = _lib.SSL_read(self._ssl, buf, bufsiz)
        self._raise_ssl_error(self._ssl, result)
        return _ffi.buffer(buf, result)[:] 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:17,代码来源:SSL.py

示例13: _raise_ssl_error

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def _raise_ssl_error(self, ssl, result):
        if self._context._verify_helper is not None:
            self._context._verify_helper.raise_if_problem()
        if self._context._npn_advertise_helper is not None:
            self._context._npn_advertise_helper.raise_if_problem()
        if self._context._npn_select_helper is not None:
            self._context._npn_select_helper.raise_if_problem()
        if self._context._alpn_select_helper is not None:
            self._context._alpn_select_helper.raise_if_problem()

        error = _lib.SSL_get_error(ssl, result)
        if error == _lib.SSL_ERROR_WANT_READ:
            raise WantReadError()
        elif error == _lib.SSL_ERROR_WANT_WRITE:
            raise WantWriteError()
        elif error == _lib.SSL_ERROR_ZERO_RETURN:
            raise ZeroReturnError()
        elif error == _lib.SSL_ERROR_WANT_X509_LOOKUP:
            # TODO: This is untested.
            raise WantX509LookupError()
        elif error == _lib.SSL_ERROR_SYSCALL:
            if _lib.ERR_peek_error() == 0:
                if result < 0:
                    if platform == "win32":
                        errno = _ffi.getwinerror()[0]
                    else:
                        errno = _ffi.errno

                    if errno != 0:
                        raise SysCallError(errno, errorcode.get(errno))
                raise SysCallError(-1, "Unexpected EOF")
            else:
                # TODO: This is untested.
                _raise_current_error()
        elif error == _lib.SSL_ERROR_NONE:
            pass
        else:
            _raise_current_error() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:40,代码来源:SSL.py

示例14: _check_env_vars_set

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def _check_env_vars_set(self, dir_env_var, file_env_var):
        """
        Check to see if the default cert dir/file environment vars are present.

        :return: bool
        """
        return (
            os.environ.get(file_env_var) is not None or
            os.environ.get(dir_env_var) is not None
        ) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:12,代码来源:SSL.py

示例15: send

# 需要导入模块: from errno import errorcode [as 别名]
# 或者: from errno.errorcode import get [as 别名]
def send(self, buf, flags=0):
        """
        Send data on the connection. NOTE: If you get one of the WantRead,
        WantWrite or WantX509Lookup exceptions on this, you have to call the
        method again with the SAME buffer.

        :param buf: The string, buffer or memoryview to send
        :param flags: (optional) Included for compatibility with the socket
                      API, the value is ignored
        :return: The number of bytes written
        """
        # Backward compatibility
        buf = _text_to_bytes_and_warn("buf", buf)

        if isinstance(buf, memoryview):
            buf = buf.tobytes()
        if isinstance(buf, _buffer):
            buf = str(buf)
        if not isinstance(buf, bytes):
            raise TypeError("data must be a memoryview, buffer or byte string")
        if len(buf) > 2147483647:
            raise ValueError("Cannot send more than 2**31-1 bytes at once.")

        result = _lib.SSL_write(self._ssl, buf, len(buf))
        self._raise_ssl_error(self._ssl, result)
        return result 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:28,代码来源:SSL.py


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