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


Python MogamiLog.error方法代码示例

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


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

示例1: flush

# 需要导入模块: from system import MogamiLog [as 别名]
# 或者: from 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_len:write_len + 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 OSError, e:
                    ans = e.errno
                    break
                #except Exception, e:
                #    ans = -1
                #    break

            self.c_channel.flush_answer(ans, write_len)
开发者ID:nukamu,项目名称:gxp4,代码行数:28,代码来源:data.py

示例2: release

# 需要导入模块: from system import MogamiLog [as 别名]
# 或者: from system.MogamiLog import error [as 别名]
    def release(self, path, fsize):
        """release handler.

        @param fd file discripter
        @param writelen size of data to be written
        """
        try:
            self.meta_rep.release(path, fsize)
        except Exception, e:
            MogamiLog.error("OSError in release (%s)" % (e))
开发者ID:nukamu,项目名称:gxp4,代码行数:12,代码来源:meta.py

示例3: truncate

# 需要导入模块: from system import MogamiLog [as 别名]
# 或者: from 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
开发者ID:nukamu,项目名称:gxp4,代码行数:12,代码来源:data.py

示例4: recv_msg

# 需要导入模块: from system import MogamiLog [as 别名]
# 或者: from system.MogamiLog import error [as 别名]
 def recv_msg(self, ):
     """receive packed message.
     """
     res_buf = cStringIO.StringIO()
     buf = ""
     while buf[-3:] != "end":
         buf = self.recvall(conf.bufsize)
         if len(buf) != conf.bufsize:
             MogamiLog.error("recv_msg error")
             return None
         res_buf.write(buf[:-3])
     ret = cPickle.loads(res_buf.getvalue())
     return ret
开发者ID:nukamu,项目名称:gxp4,代码行数:15,代码来源:channel.py

示例5: remove_data_server

# 需要导入模块: from system import MogamiLog [as 别名]
# 或者: from 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
开发者ID:nukamu,项目名称:gxp4,代码行数:15,代码来源:meta.py

示例6: send_msg

# 需要导入模块: from system import MogamiLog [as 别名]
# 或者: from system.MogamiLog import error [as 别名]
    def send_msg(self, data):
        """send packed message.

        @param data data to send
        """
        buf = cPickle.dumps(data)
        while conf.bufsize - 3 < len(buf):
            ret = self.sendall(buf[:conf.bufsize - 3] + "---")
            if ret == None:
                MogamiLog.error("send_msg error")
                break
            buf = buf[conf.bufsize - 3:]
        buf = buf + "-" * (conf.bufsize - len(buf) - 3) + "end"
        self.sendall(buf)
开发者ID:nukamu,项目名称:gxp4,代码行数:16,代码来源:channel.py

示例7: read

# 需要导入模块: from system import MogamiLog [as 别名]
# 或者: from 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
开发者ID:nukamu,项目名称:gxp4,代码行数:22,代码来源:data.py

示例8: recvall

# 需要导入模块: from system import MogamiLog [as 别名]
# 或者: from system.MogamiLog import error [as 别名]
    def recvall(self, length):
        """recv all data.

        This function may return less data than required.
        (when connection closed)
        @param length length of data to receive
        """
        buf = cStringIO.StringIO()
        recvlen = 0
        while recvlen < length:
            try:
                recvdata = self.sock.recv(length - recvlen)
            except Exception, e:
                MogamiLog.error("** Connection closed suddenly **")
                self.sock.close()
                break
            if recvdata == "":
                self.sock.close()
                break
            buf.write(recvdata)
            recvlen += len(recvdata)
开发者ID:nukamu,项目名称:gxp4,代码行数:23,代码来源:channel.py

示例9: run

# 需要导入模块: from system import MogamiLog [as 别名]
# 或者: from system.MogamiLog import error [as 别名]
    def run(self, ):
        while True:
            req = self.c_channel.recv_request()
            if req == None:  # failed to receive data
                MogamiLog.debug("Connection closed by failing recv data")
                self.c_channel.finalize()
                break
            elif req[0] == channel.REQ_CLOSE:  # close request
                MogamiLog.debug("Connection closed by close request")
                self.c_channel.finalize()
                break

            if req[0] in self.func_dict:
                MogamiLog.debug('** %s **' % (self.func_dict[req[0]]))
                method = getattr(self, self.func_dict[req[0]])
                req_args = list(req)
                req_args.pop(0)
                method(*req_args)

            else:  # doesn't match any expected request
                MogamiLog.error('** This is unexpected header **')
                self.c_channel.finalize()
                break
开发者ID:nukamu,项目名称:gxp4,代码行数:25,代码来源:daemons.py

示例10: recvall_with_time

# 需要导入模块: from system import MogamiLog [as 别名]
# 或者: from system.MogamiLog import error [as 别名]
    def recvall_with_time(self, length):
        """receive data and measure time to receive

        This function seems to be called only in prefetching.
        @param length length of data to receive
        """
        buf = cStringIO.StringIO()
        recvlen = 0
        recv_time = 0
        while recvlen < length:
            try:
                start_t = time.time()
                recvdata = self.sock.recv(length - recvlen)
                end_t = time.time()
            except Exception, e:
                MogamiLog.error("** Connection closed suddenly **")
                self.sock.close()
                break
            if recvdata == "":
                self.sock.close()
                break
            buf.write(recvdata)
            recvlen += len(recvdata)
            recv_time += end_t - start_t
开发者ID:nukamu,项目名称:gxp4,代码行数:26,代码来源:channel.py

示例11: prefetch

# 需要导入模块: from system import MogamiLog [as 别名]
# 或者: from 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, blnum))
                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()
                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))
开发者ID:nukamu,项目名称:gxp4,代码行数:26,代码来源:data.py

示例12: rename

# 需要导入模块: from system import MogamiLog [as 别名]
# 或者: from system.MogamiLog import error [as 别名]
        try:
            (dest, dest_path) = self.meta_rep.unlink(path)
            if async is True:
                ans = 0
                if dest != None:
                    self.sysinfo.add_delfile(dest, dest_path)
            else:
                c_channel = channel.MogamiChanneltoData(dest)
                ans = c_channel.delfile_req([dest_path, ])
                c_channel.close_req()
                c_channel.finalize()
        except os.error, e:
            ans = e.errno
        except Exception, e:
            ans = e.errno
            MogamiLog.error("cannot remove file contents of %s" % path)

        self.c_channel.unlink_answer(ans)

    def rename(self, oldpath, newpath):
        MogamiLog.debug(oldpath + ' -> ' + newpath)
        try:
            self.meta_rep.rename(oldpath, newpath)
            ans = 0
        except os.error, e:
            ans = e.errno
        self.c_channel.rename_answer(ans)

    def chmod(self, path, mode):
        MogamiLog.debug("path = %s w/ mode %s" % (path, oct(mode)))
        try:
开发者ID:nukamu,项目名称:gxp4,代码行数:33,代码来源:meta.py

示例13: __init__

# 需要导入模块: from system import MogamiLog [as 别名]
# 或者: from 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 is True:
                start_t = time.time()

            # parse argurments
            self.path = path
            self.flag = flag
            self.mode = mode

            dest = None
            self.local = False

            if conf.local_request is True:
                try:
                    if local_ch.connected == False:
                        local_ch.connect('127.0.0.1')
                    (ans, data_path, fsize) = local_ch.filereq_req(path)
                    if ans == 0:  # exists on local
                        dest = 'self'
                        self.local = True
                        self.created = False
                        self.fsize = fsize
                except Exception:
                    pass

            if dest == None:
                # request for metadata server
                (ans, dest, data_path, self.fsize,
                 self.created) = m_channel.open_req(path, flag, *mode)
                if dest == 'self':
                    if local_ch.connected == False:
                        local_ch.connect('127.0.0.1')
                    local_ch.fileadd_req(self.path, data_path)
                        
                if ans != 0:  # error on metadata server
                    e = IOError()
                    e.errno = ans
                    raise e

            if dest == 'self':
                self.local = True
                self.mogami_file = filemanager.MogamiLocalFile(
                    self.fsize, local_ch, path, data_path, flag, *mode)
            else:
                self.local = False
                self.mogami_file = filemanager.MogamiRemoteFile(
                    self.fsize, dest, path, 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 is 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 proccess
                    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
开发者ID:nukamu,项目名称:gxp4,代码行数:85,代码来源:fs.py


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