本文整理汇总了Python中libs.System.MogamiLog.error方法的典型用法代码示例。如果您正苦于以下问题:Python MogamiLog.error方法的具体用法?Python MogamiLog.error怎么用?Python MogamiLog.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libs.System.MogamiLog
的用法示例。
在下文中一共展示了MogamiLog.error方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from libs.System import MogamiLog [as 别名]
# 或者: from libs.System.MogamiLog import error [as 别名]
def __init__(self, path, flag, *mode):
"""Initializer called when opened.
@param path file path
@param flag flags with open(2)
@param *mode file open mode (may not be specified)
"""
MogamiLog.debug("** open ** path = %s, flag = %s, mode = %s" %
(path, str(flag), str(mode)))
if conf.ap == True:
start_t = time.time()
# parse argurments
self.path = path
self.flag = flag
self.mode = mode
(ans, dest, self.metafd, data_path, self.fsize,
self.created) = m_channel.open_req(path, flag, *mode)
if ans != 0: # error on metadata server
e = IOError()
e.errno = ans
raise e
if dest == 'self':
self.mogami_file = FileManager.MogamiLocalFile(
self.fsize, data_path, flag, *mode)
else:
self.mogami_file = FileManager.MogamiRemoteFile(
self.fsize, dest, data_path, flag, *mode)
ans = self.mogami_file.create_connections(channels)
if ans != 0:
MogamiLog.error("open error !!")
e = IOError()
e.errno = ans
raise e
# register file size to file size dictionary
file_size_dict[path] = self.fsize
if conf.ap == True:
"""Get Id list to know pid.
list = {gid: pid: uid}
And then get the command from pid.
"""
try:
id_list = self.GetContext()
pid = id_list['pid']
f = open(os.path.join("/proc", str(pid), "cmdline"), 'r')
cmd_args = f.read().rsplit('\x00')[:-1]
except Exception, e:
# with any error, pass this part of process
cmd_args = None
pid = -1
self.access_pattern = FileManager.MogamiAccessPattern(
path, cmd_args, pid)
end_t = time.time()
self.took_time = end_t - start_t
示例2: unlink
# 需要导入模块: from libs.System import MogamiLog [as 别名]
# 或者: from libs.System.MogamiLog import error [as 别名]
def unlink(self, path):
MogamiLog.debug("path = %s" % path)
if os.path.isfile(path):
try:
(dest, data_path, fsize) = meta_file_info(path)
self.sysinfo.add_delfile(dest, data_path)
except Exception, e:
MogamiLog.error("cannot remove file contents of %s", path)
示例3: truncate
# 需要导入模块: from libs.System import MogamiLog [as 别名]
# 或者: from libs.System.MogamiLog import error [as 别名]
def truncate(self, path, length):
MogamiLog.debug("path = %s. length = %d" % (path, length))
try:
f = open(path, "r+")
f.truncate(length)
f.close()
ans = 0
except Exception, e:
MogamiLog.error("have an error (%s)" % (e))
ans = e.errno
示例4: remove_data_server
# 需要导入模块: from libs.System import MogamiLog [as 别名]
# 或者: from libs.System.MogamiLog import error [as 别名]
def remove_data_server(self, ip):
"""remove a data server from Mogami system
@param ip ip address of node to remove
@return 0 with success, -1 with error
"""
try:
self.data_list.remove(ip)
del self.data_rootpath[ip]
return True
except Exception, e:
MogamiLog.error("cannot find %s from data servers" % (ip))
return False
示例5: read
# 需要导入模块: from libs.System import MogamiLog [as 别名]
# 或者: from libs.System.MogamiLog import error [as 别名]
def read(self, fd, blnum):
MogamiLog.debug("fd = %d, bl_num = %d" % (fd, blnum))
sendbuf = ""
try:
os.lseek(fd, blnum * conf.blsize, os.SEEK_SET)
buf = cStringIO.StringIO()
readlen = 0
while readlen < conf.blsize - 1:
os.lseek(fd, blnum * 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()
ans = 0
except Exception, e:
MogamiLog.error("read have an error (%s)" % (e))
ans = e.errno
示例6: flush
# 需要导入模块: from libs.System import MogamiLog [as 别名]
# 或者: from libs.System.MogamiLog import error [as 别名]
def flush(self, fd, listlen, datalen):
MogamiLog.debug("fd=%d, listlen=%d, datalen=%d" %
(fd, listlen, datalen))
(write_list, buf) = self.c_channel.flush_recv_data(listlen, datalen)
if len(write_list) != 0:
write_len = 0
for wd in write_list:
try:
ans = 0
os.lseek(fd, wd[0], os.SEEK_SET)
ret = os.write(fd, buf[write:write + wd[1]])
write_len += ret
if ret != wd[1]:
MogamiLog.error("write length error !!")
break
MogamiLog.debug("write from offset %d (result %d)" %
(wd[0], ret))
except Exception, e:
ans = e.errno
break
self.c_channel.flush_answer(ans, write_len)
示例7: prefetch
# 需要导入模块: from libs.System import MogamiLog [as 别名]
# 或者: from libs.System.MogamiLog import error [as 别名]
def prefetch(self, fd, blnum_list):
for blnum in blnum_list:
try:
sendbuf = ""
start_t = time.time()
MogamiLog.debug("fd = %d, blnum = %d" % (fd, bl_num))
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()
end_t = time.time()
# send data read from file (only in case w/o error)
self.c_channel.data_send(0, blnum, len(sendbuf), sendbuf)
except Exception, e:
MogamiLog.error("Prefetch Error!! with %d-th block" % (blnum))
示例8: run
# 需要导入模块: from libs.System import MogamiLog [as 别名]
# 或者: from libs.System.MogamiLog import error [as 别名]
def run(self, ):
while True:
req = self.c_channel.recv_request()
if req == None:
MogamiLog.debug("Connection closed")
self.c_channel.finalize()
break
if req[0] == Channel.REQ_GETATTR:
MogamiLog.debug("** getattr **")
self.getattr(self.rootpath + req[1])
elif req[0] == Channel.REQ_READDIR:
MogamiLog.debug("** readdir **")
self.readdir(self.rootpath + req[1])
elif req[0] == Channel.REQ_ACCESS:
MogamiLog.debug("** access **")
self.access(self.rootpath + req[1], req[2])
elif req[0] == Channel.REQ_MKDIR:
MogamiLog.debug("** mkdir **")
self.mkdir(self.rootpath + req[1], req[2])
elif req[0] == Channel.REQ_RMDIR:
MogamiLog.debug("** rmdir **")
self.rmdir(self.rootpath + req[1])
elif req[0] == Channel.REQ_UNLINK:
MogamiLog.debug("** unlink **")
self.unlink(self.rootpath + req[1])
elif req[0] == Channel.REQ_RENAME:
MogamiLog.debug("** rename **")
self.rename(self.rootpath + req[1],
self.rootpath + req[2])
elif req[0] == Channel.REQ_MKNOD:
MogamiLog.debug("** mknod **")
self.mknod(self.rootpath + req[1], req[2], req[3])
elif req[0] == Channel.REQ_CHMOD:
MogamiLog.debug("** chmod **")
self.chmod(self.rootpath + req[1], req[2])
elif req[0] == Channel.REQ_CHOWN:
MogamiLog.debug("** chown **")
self.chown(self.rootpath + req[1], req[2], req[3])
elif req[0] == Channel.REQ_LINK:
self.link(self.rootpath + req[1],
self.rootpath + req[2])
elif req[0] == Channel.REQ_SYMLINK:
self.symlink(req[1], self.rootpath + req[2])
elif req[0] == Channel.REQ_READLINK:
self.readlink(self.rootpath + req[1])
elif req[0] == Channel.REQ_TRUNCATE:
self.truncate(self.rootpath + req[1], req[2])
elif req[0] == Channel.REQ_UTIME:
self.utime(self.rootpath + req[1], req[2])
elif req[0] == Channel.REQ_FSYNC:
self.fsync(self.rootpath + req[1], req[2])
elif req[0] == Channel.REQ_OPEN:
self.open(self.rootpath + req[1], req[2], req[3])
elif req[0] == Channel.REQ_RELEASE:
MogamiLog.debug("** release **")
self.release(req[1], req[2])
elif req[0] == Channel.REQ_FGETATTR:
self.fgetattr(req[1])
elif req[0] == Channel.REQ_FTRUNCATE:
MogamiLog.error("** ftruncate **")
elif req[0] == Channel.REQ_DATAADD:
MogamiLog.debug("** dataadd **")
ip = self.c_channel.getpeername()
self.data_add(ip, req[1])
elif req[0] == Channel.REQ_DATADEL:
MogamiLog.debug("** datadel **")
ip = self.c_channel.getpeername()
self.data_del(ip)
elif req[0] == Channel.REQ_RAMFILEADD:
MogamiLog.debug("** ramfile add **")
self.register_ramfiles(req[1])
elif req[0] == Channel.REQ_FILEASK:
MogamiLog.debug("** fileask **")
self.file_ask(req[1])
else:
#.........这里部分代码省略.........