本文整理汇总了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()
示例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
示例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]
示例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)