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


Python DRDFSLog.error方法代码示例

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


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

示例1: read

# 需要导入模块: from libs.system import DRDFSLog [as 别名]
# 或者: from libs.system.DRDFSLog import error [as 别名]
        def read(self, length, offset):
            DRDFSLog.debug("** read ** offset %d, length =%d" % (offset, length))
            requestl = self.cal_bl(offset, length)
            # prepare buffer to return
            ret_str = cStringIO.StringIO()
            DRDFSLog.debug("requestl = %s, with offset: %d, length: %d" % (str(requestl), offset, length))
            for req in requestl:
                reqbl = req[0]
                buf = ""  # buffer for block[reqbl]
                last_readbl = reqbl

                if self.bldata[reqbl].state == 2:
                    buf = self.bldata[reqbl].buf
                elif self.bldata[reqbl].state == 1:
                    DRDFSLog.debug("Waiting recv data %d block" % reqbl)
                    while self.bldata[reqbl].state == 1:
                        time.sleep(0.01)
                    buf = self.bldata[reqbl].buf
                else:
                    ret = self.request_block(reqbl)
                    if ret != 0:
                        DRDFSLog.error("read error! (%d)" % ret)
                        return ret
                    while self.bldata[reqbl].state == 1:
                        time.sleep(0.01)
                    with self.r_buflock:
                        buf = self.bldata[reqbl].buf

                # write strings to return and if reach EOF, break
                ret_str.write(buf[req[1] : req[2]])
                if len(buf) < conf.blsize:
                    break  # end of file

            return ret_str.getvalue()
开发者ID:nukamu,项目名称:dddfs,代码行数:36,代码来源:fs.py

示例2: flush

# 需要导入模块: from libs.system import DRDFSLog [as 别名]
# 或者: from libs.system.DRDFSLog import error [as 别名]
        def flush(self, fd, listlen, datalen):
            DRDFSLog.debug("flush: fd=%d, listlen=%d, datalen=%d" % (fd, listlen, datalen))

            buf = self.c_channel._recvall(listlen)
            writelist = cPickle.loads(buf)
            buf = self.c_channel._recvall(datalen)

            write = 0
            for wd in writelist:
                try:
                    os.lseek(fd, wd[0], os.SEEK_SET)
                    res = os.write(fd, buf[write:write+wd[1]])
                    write += res
                    if res != wd[1]:
                        DRDFSLog.error("write length error !!")
                    DRDFSLog.debug("write from offset %d (result %d)" % (wd[0], res))
                except Exception, e:
                    senddata = -e.errno
开发者ID:laysakura,项目名称:dddfs,代码行数:20,代码来源:data.py

示例3: read

# 需要导入模块: from libs.system import DRDFSLog [as 别名]
# 或者: from libs.system.DRDFSLog import error [as 别名]
        def read(self, fd, bl_num):
            DRDFSLog.debug("fd = %d, bl_num = %d" % (fd, bl_num))
            try:
                os.lseek(fd, bl_num * conf.blsize, os.SEEK_SET)

                buf = cStringIO.StringIO()
                readlen = 0
                while readlen < conf.blsize - 1:
                    os.lseek(fd, bl_num * conf.blsize + readlen, os.SEEK_SET)
                    tmpbuf = os.read(fd, conf.blsize - readlen)
                    if tmpbuf == '':   # end of file
                        break
                    buf.write(tmpbuf)
                    readlen += len(tmpbuf)
                sendbuf = buf.getvalue()
                DRDFSLog.debug("read from file offset %d len %d (result %d)" % 
                               (bl_num * conf.blsize, conf.blsize, len(sendbuf)))
                senddata = [0, bl_num, len(sendbuf)]
            except Exception, e:
                DRDFSLog.error("read have an error (%s)" % (e))
                senddata = [e.errno, 'null', 0, 0]
开发者ID:laysakura,项目名称:dddfs,代码行数:23,代码来源:data.py

示例4: len

# 需要导入模块: from libs.system import DRDFSLog [as 别名]
# 或者: from libs.system.DRDFSLog import error [as 别名]
                created = True
                try:
                    fd = 0
                    if mode:
                        fd = os.open(self.rootpath + path, os.O_RDWR | os.O_CREAT, mode[0])
                    else:
                        fd = os.open(self.rootpath + path, os.O_RDWR | os.O_CREAT)
                except os.error, e:
                    print "!! have fatal error @1!! (%s)" % (e)
                    raise
                try:
                    rand = 0
                    if len(self.datalist) > 0:
                        rand = random.randint(0, len(self.datalist) - 1)
                    else:
                        DRDFSLog.error("!! There are no data server to create file !!")
                    dist = self.datalist[rand]

                    # make a filename in a random manner
                    filename = ''.join(random.choice(string.letters) for i in xrange(16))
                    DRDFSLog.debug("filename is %s" % (filename,))
                    buf = dist + ',' + filename + ',' + '0,' + '\n'
                except Exception, e:
                    print "!! have fatal error @2!! (%s)" % (e)
                    raise
                DRDFSLog.debug("fd = " + str(fd))
                try:
                    os.write(fd, buf)
                    os.fsync(fd)
                except os.error, e:
                    print "!! have fatal error @3!! (%s)" % (e)
开发者ID:laysakura,项目名称:dddfs,代码行数:33,代码来源:meta.py


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