當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。