• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python rposix.get_errno函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pypy.rlib.rposix.get_errno函数的典型用法代码示例。如果您正苦于以下问题:Python get_errno函数的具体用法?Python get_errno怎么用?Python get_errno使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: time_sleep_llimpl

 def time_sleep_llimpl(secs):
     void = lltype.nullptr(rffi.VOIDP.TO)
     t = lltype.malloc(self.TIMEVAL, flavor='raw')
     try:
         frac = math.fmod(secs, 1.0)
         t.c_tv_sec = int(secs)
         t.c_tv_usec = int(frac*1000000.0)
         if rffi.cast(rffi.LONG, c_select(0, void, void, void, t)) != 0:
             errno = rposix.get_errno()
             if errno != EINTR:
                 raise OSError(rposix.get_errno(), "Select failed")
     finally:
         lltype.free(t, flavor='raw')
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:13,代码来源:ll_time.py


示例2: tcsetattr_llimpl

def tcsetattr_llimpl(fd, when, attributes):
    c_struct = lltype.malloc(TERMIOSP.TO, flavor='raw')
    c_struct.c_c_iflag, c_struct.c_c_oflag, c_struct.c_c_cflag, \
    c_struct.c_c_lflag, ispeed, ospeed, cc = attributes
    try:
        for i in range(NCCS):
            c_struct.c_c_cc[i] = rffi.r_uchar(ord(cc[i][0]))
        if c_cfsetispeed(c_struct, ispeed) < 0:
            raise OSError(rposix.get_errno(), 'tcsetattr failed')
        if c_cfsetospeed(c_struct, ospeed) < 0:
            raise OSError(rposix.get_errno(), 'tcsetattr failed')
        if c_tcsetattr(fd, when, c_struct) < 0:
            raise OSError(rposix.get_errno(), 'tcsetattr failed')
    finally:
        lltype.free(c_struct, flavor='raw')
开发者ID:ieure,项目名称:pypy,代码行数:15,代码来源:ll_termios.py


示例3: flush

    def flush(self, offset=0, size=0):
        self.check_valid()

        if size == 0:
            size = self.size
        if offset < 0 or size < 0 or offset + size > self.size:
            raise RValueError("flush values out of range")
        else:
            start = self.getptr(offset)
            if _MS_WINDOWS:
                res = FlushViewOfFile(start, size)
                # XXX res == 0 means that an error occurred, but in CPython
                # this is not checked
                return res
            elif _POSIX:
##                XXX why is this code here?  There is no equivalent in CPython
##                if _LINUX:
##                    # alignment of the address
##                    value = cast(self.data, c_void_p).value
##                    aligned_value = value & ~(PAGESIZE - 1)
##                    # the size should be increased too. otherwise the final
##                    # part is not "msynced"
##                    new_size = size + value & (PAGESIZE - 1)
                res = c_msync(start, size, MS_SYNC)
                if res == -1:
                    errno = rposix.get_errno()
                    raise OSError(errno, os.strerror(errno))
        
        return 0
开发者ID:ieure,项目名称:pypy,代码行数:29,代码来源:rmmap.py


示例4: startup

 def startup(self):
     if not OPROFILE_AVAILABLE:
         return
     agent = op_open_agent()
     if not agent:
         raise OProfileError(get_errno(), "startup")
     self.agent = agent
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:oprofile.py


示例5: bindtextdomain

    def bindtextdomain(space, domain, w_dir):
        """bindtextdomain(domain, dir) -> string
        Bind the C library's domain to dir."""

        if space.is_w(w_dir, space.w_None):
            dir = None
            domain_c = rffi.str2charp(domain)
            try:
                dirname = _bindtextdomain(domain_c, dir)
            finally:
                rffi.free_charp(domain_c)
        else:
            dir = space.str_w(w_dir)
            domain_c = rffi.str2charp(domain)
            dir_c = rffi.str2charp(dir)
            try:
                dirname = _bindtextdomain(domain_c, dir_c)
            finally:
                rffi.free_charp(domain_c)
                rffi.free_charp(dir_c)

        if not dirname:
            errno = rposix.get_errno()
            raise OperationError(space.w_OSError, space.wrap(errno))
        return space.wrap(rffi.charp2str(dirname))
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:25,代码来源:interp_locale.py


示例6: spawnv_llimpl

 def spawnv_llimpl(mode, path, args):
     mode = rffi.cast(rffi.INT, mode)
     l_args = rffi.liststr2charpp(args)
     childpid = os_spawnv(mode, path, l_args)
     rffi.free_charpp(l_args)
     if childpid == -1:
         raise OSError(rposix.get_errno(), "os_spawnv failed")
     return rffi.cast(lltype.Signed, childpid)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:8,代码来源:ll_os.py


示例7: mkdir_llimpl

 def mkdir_llimpl(pathname, mode):
     if IGNORE_MODE:
         res = os_mkdir(pathname)
     else:
         res = os_mkdir(pathname, mode)
     res = rffi.cast(lltype.Signed, res)
     if res < 0:
         raise OSError(rposix.get_errno(), "os_mkdir failed")
开发者ID:antoine1fr,项目名称:pygirl,代码行数:8,代码来源:ll_os.py


示例8: native_code_written

 def native_code_written(self, name, address, size):
     assert size > 0
     if not OPROFILE_AVAILABLE:
         return
     uaddress = rffi.cast(rffi.ULONG, address)
     success = op_write_native_code(self.agent, name, uaddress, rffi.cast(rffi.VOIDP, 0), size)
     if success != 0:
         raise OProfileError(get_errno(), "write")
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:8,代码来源:oprofile.py


示例9: _check_error

def _check_error(x):
    errno = rposix.get_errno()
    if errno:
        if errno == ERANGE:
            if not x:
                return # we consider underflow to not be an error, like CPython
            raise OverflowError("math range error")
        else:
            raise ValueError("math domain error")
开发者ID:alkorzt,项目名称:pypy,代码行数:9,代码来源:ll_math.py


示例10: sh_cmd

def sh_cmd(vm):
    (cmd_o,),_ = vm.decode_args("S")
    assert isinstance(cmd_o, Con_String)

    r = system(cmd_o.v)
    if r == -1:
        vm.raise_helper("Exception", [Con_String(vm, os.strerror(rposix.get_errno()))])

    return Con_Int(vm, os.WEXITSTATUS(r))
开发者ID:cfbolz,项目名称:converge,代码行数:9,代码来源:Con_C_Platform_Exec.py


示例11: flush

 def flush(self):
     if self.buf_count > 0:
         bytes = self.buf_count * rffi.sizeof(rffi.LONG)
         count = raw_os_write(self.fd,
                              rffi.cast(llmemory.Address, self.writebuffer),
                              rffi.cast(rffi.SIZE_T, bytes))
         if rffi.cast(lltype.Signed, count) != bytes:
             raise OSError(rposix.get_errno(), "raw_os_write failed")
         self.buf_count = 0
开发者ID:ieure,项目名称:pypy,代码行数:9,代码来源:inspector.py


示例12: lseek_llimpl

 def lseek_llimpl(fd, pos, how):
     how = fix_seek_arg(how)
     res = os_lseek(rffi.cast(rffi.INT,      fd),
                    rffi.cast(rffi.LONGLONG, pos),
                    rffi.cast(rffi.INT,      how))
     res = rffi.cast(lltype.SignedLongLong, res)
     if res < 0:
         raise OSError(rposix.get_errno(), "os_lseek failed")
     return res
开发者ID:antoine1fr,项目名称:pygirl,代码行数:9,代码来源:ll_os.py


示例13: PyOS_string_to_double

def PyOS_string_to_double(space, s, endptr, w_overflow_exception):
    """Convert a string s to a double, raising a Python
    exception on failure.  The set of accepted strings corresponds to
    the set of strings accepted by Python's float() constructor,
    except that s must not have leading or trailing whitespace.
    The conversion is independent of the current locale.

    If endptr is NULL, convert the whole string.  Raise
    ValueError and return -1.0 if the string is not a valid
    representation of a floating-point number.

    If endptr is not NULL, convert as much of the string as
    possible and set *endptr to point to the first unconverted
    character.  If no initial segment of the string is the valid
    representation of a floating-point number, set *endptr to point
    to the beginning of the string, raise ValueError, and return
    -1.0.

    If s represents a value that is too large to store in a float
    (for example, "1e500" is such a string on many platforms) then
    if overflow_exception is NULL return Py_HUGE_VAL (with
    an appropriate sign) and don't set any exception.  Otherwise,
    overflow_exception must point to a Python exception object;
    raise that exception and return -1.0.  In both cases, set
    *endptr to point to the first character after the converted value.

    If any other error occurs during the conversion (for example an
    out-of-memory error), set the appropriate Python exception and
    return -1.0.
    """
    user_endptr = True
    try:
        if not endptr:
            endptr = lltype.malloc(rffi.CCHARPP.TO, 1, flavor='raw')
            user_endptr = False
        result = rdtoa.dg_strtod(s, endptr)
        endpos = (rffi.cast(rffi.LONG, endptr[0]) -
                  rffi.cast(rffi.LONG, s))
        if endpos == 0 or (not user_endptr and not endptr[0][0] == '\0'):
            raise OperationError(
                space.w_ValueError,
                space.wrap('invalid input at position %s' % endpos))
        if rposix.get_errno() == errno.ERANGE:
            rposix.set_errno(0)
            if w_overflow_exception is None:
                if result > 0:
                    return rfloat.INFINITY
                else:
                    return -rfloat.INFINITY
            else:
                raise OperationError(w_overflow_exception,
                                     space.wrap('value too large'))
        return result
    finally:
        if not user_endptr:
            lltype.free(endptr, flavor='raw')
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:56,代码来源:pystrtod.py


示例14: os_pipe_llimpl

 def os_pipe_llimpl():
     filedes = lltype.malloc(INT_ARRAY_P.TO, 2, flavor='raw')
     error = rffi.cast(lltype.Signed, os_pipe(filedes))
     read_fd = filedes[0]
     write_fd = filedes[1]
     lltype.free(filedes, flavor='raw')
     if error != 0:
         raise OSError(rposix.get_errno(), "os_pipe failed")
     return (rffi.cast(lltype.Signed, read_fd),
             rffi.cast(lltype.Signed, write_fd))
开发者ID:antoine1fr,项目名称:pygirl,代码行数:10,代码来源:ll_os.py


示例15: os_listdir_llimpl

 def os_listdir_llimpl(path):
     dirp = os_opendir(path)
     if not dirp:
         raise OSError(rposix.get_errno(), "os_opendir failed")
     rposix.set_errno(0)
     result = []
     while True:
         direntp = os_readdir(dirp)
         if not direntp:
             error = rposix.get_errno()
             break
         namep = rffi.cast(rffi.CCHARP, direntp.c_d_name)
         name = rffi.charp2str(namep)
         if name != '.' and name != '..':
             result.append(name)
     os_closedir(dirp)
     if error:
         raise OSError(error, "os_readdir failed")
     return result
开发者ID:antoine1fr,项目名称:pygirl,代码行数:19,代码来源:ll_os.py


示例16: os_utime_llimpl

 def os_utime_llimpl(path, tp):
     # NB. this function is specialized; we get one version where
     # tp is known to be None, and one version where it is known
     # to be a tuple of 2 floats.
     if tp is None:
         error = os_utime(path, lltype.nullptr(UTIMBUFP.TO))
     else:
         actime, modtime = tp
         error = os_utime_platform(path, actime, modtime)
     error = rffi.cast(lltype.Signed, error)
     if error == -1:
         raise OSError(rposix.get_errno(), "os_utime failed")
开发者ID:antoine1fr,项目名称:pygirl,代码行数:12,代码来源:ll_os.py


示例17: posix_stat_llimpl

 def posix_stat_llimpl(arg):
     stresult = lltype.malloc(STAT_STRUCT.TO, flavor='raw')
     try:
         if arg_is_path:
             arg = rffi.str2charp(arg)
         error = rffi.cast(rffi.LONG, posix_mystat(arg, stresult))
         if arg_is_path:
             rffi.free_charp(arg)
         if error != 0:
             raise OSError(rposix.get_errno(), "os_?stat failed")
         return build_stat_result(stresult)
     finally:
         lltype.free(stresult, flavor='raw')
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:13,代码来源:ll_os_stat.py


示例18: os_waitpid_llimpl

 def os_waitpid_llimpl(pid, options):
     status_p = lltype.malloc(rffi.INTP.TO, 1, flavor='raw')
     status_p[0] = rffi.cast(rffi.INT, 0)
     result = os_waitpid(rffi.cast(rffi.PID_T, pid),
                         status_p,
                         rffi.cast(rffi.INT, options))
     result = rffi.cast(lltype.Signed, result)
     status = status_p[0]
     lltype.free(status_p, flavor='raw')
     if result == -1:
         raise OSError(rposix.get_errno(), "os_waitpid failed")
     return (rffi.cast(lltype.Signed, result),
             rffi.cast(lltype.Signed, status))
开发者ID:antoine1fr,项目名称:pygirl,代码行数:13,代码来源:ll_os.py


示例19: uname_llimpl

 def uname_llimpl():
     l_utsbuf = lltype.malloc(UTSNAMEP.TO, flavor='raw')
     result = os_uname(l_utsbuf)
     if result == -1:
         raise OSError(rposix.get_errno(), "os_uname failed")
     retval = (
         rffi.charp2str(rffi.cast(rffi.CCHARP, l_utsbuf.c_sysname)),
         rffi.charp2str(rffi.cast(rffi.CCHARP, l_utsbuf.c_nodename)),
         rffi.charp2str(rffi.cast(rffi.CCHARP, l_utsbuf.c_release)),
         rffi.charp2str(rffi.cast(rffi.CCHARP, l_utsbuf.c_version)),
         rffi.charp2str(rffi.cast(rffi.CCHARP, l_utsbuf.c_machine)),
         )
     lltype.free(l_utsbuf, flavor='raw')
     return retval
开发者ID:antoine1fr,项目名称:pygirl,代码行数:14,代码来源:ll_os.py


示例20: os_read_llimpl

 def os_read_llimpl(fd, count):
     if count < 0:
         raise OSError(errno.EINVAL, None)
     inbuf = lltype.malloc(rffi.CCHARP.TO, count, flavor='raw')
     try:
         got = rffi.cast(lltype.Signed, os_read(rffi.cast(rffi.INT, fd),
                         inbuf, rffi.cast(rffi.SIZE_T, count)))
         if got < 0:
             raise OSError(rposix.get_errno(), "os_read failed")
         # XXX too many copies of the data!
         l = [inbuf[i] for i in range(got)]
     finally:
         lltype.free(inbuf, flavor='raw')
     return ''.join(l)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:14,代码来源:ll_os.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python rsre_core.match函数代码示例发布时间:2022-05-27
下一篇:
Python rope.strip函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap