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


Python CPL.error方法代码示例

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


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

示例1: setOutputFile

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import error [as 别名]
    def setOutputFile(self, f):
        """ Change the output file. Close and unregister any old file. Clear the output queue.

        This should be the only method which adjusts output registration.
        """
        
        if self.debug > 2:
            CPL.log("IOHandler.setOutput", "%s changing output %s to %s. queue=%s" % \
                    (self, self.out_f, f, self.outQueue))

        if self.out_f != None:
            self.poller.removeOutput(self)
            if f != self.out_f:
                try:
                    self.out_f.close()
                except:
                    CPL.error("IOHandler.setOutput", "failed to close output for %s", self)
            
        # Establish new .out_f
        #
        self.out_f = f
        if f == None:
            self.out_fd = None
        else:
            self.out_fd = f.fileno()
        self.outQueue = []
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:28,代码来源:IOHandler.py

示例2: setInputFile

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import error [as 别名]
    def setInputFile(self, f):
        """ Change the input file. Close and unregister any old file. Register the new one for input. """
        
        if self.debug > 2:
            CPL.log("IOHandler.setInput", "%s changing input %s to %s" % (self, self.in_f, f))

        # Detach and possibly close existing .in_f
        #
        if self.in_f != None:
            self.poller.removeInput(self)
            if self.in_f != f:
                try:
                    self.in_f.close()
                except:
                    CPL.error("IOHandler.setInput", "failed to close input for %s", self)

        # Establish new .in_f
        #
        self.in_f = f
        if f == None:
            self.in_fd = None
        else:
            self.in_fd = f.fileno()
            self.poller.addInput(self)
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:26,代码来源:IOHandler.py

示例3: decode

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import error [as 别名]
    def decode(self, buf, newData):

        if newData:
            buf += newData
        
        # The binary protocol encapsulates each message in a 10-byte header and a 2-byte trailer:
        #
        # 1(1 byte)
        #        I have no idea what this is about.
        # isfile(1 byte)
        #        Nor this, really. In the hub, if the value is > 1, the data is saved to a file.
        # length(4 bytes)
        #        Length of the complete packet, including the header and trailer.
        # mid(2 bytes) cid(2 bytes)
        #        Note the range: 0..64k
        #        We don't use the cid.
        # if (isfile <= 1):
        #     message
        # else:
        #     xpix(2 bytes)
        #     ypix(2 bytes)
        #     bitpix(2 bytes) (or 1?)
        #     data
        # 
        # checksum(1 byte)
        #        1-byte XOR of the message body.
        # 4(1 byte)
        #        No idea. Just send 4.

        # Quick check for minimal length.
        #
        if len(buf) < 12:
            return None, buf

        # Examine first part, especially the length
        #
        dummy, is_file, length, cid, mid = \
               struct.unpack('>BBihh', buf[:10])
        if dummy != 1:
            # Complain, but don't fail.
            CPL.log('Hub.decap', 'dummy=%d is_file=%d length=%d mid=%d cid=%d' % \
                    (dummy, is_file, length, mid, cid))
        is_file = is_file > 1
        
        if self.debug >= 5:
            CPL.log("Binary.decap", "is_file=%s length=%d (%d) cid=%d mid=%d" %\
                    (is_file, length, len(buf), cid, mid))

        fullLength = length + 10 + 2
            
        if len(buf) < fullLength:
            return None, buf

        # We don't have a complete command yet. Keep waiting.
        #
        if is_file:
            headerLength = 16
        else:
            headerLength = 10

        if is_file:
            xpix, ypix, bitpix = struct.unpack('>hhh', buf[10:16])
        msg = buf[headerLength:fullLength - 2]

        # Trailer parts.
        csum, trailer = struct.unpack('>BB', buf[fullLength-2:fullLength])

        # Calculate & check checksum of message body.
        #   Because images come through here, we need to C this. -- CPL
        #
        my_csum = 0
        if not is_file:
            for i in range(10, fullLength - 10 + 1):
                my_csum ^= ord(buf[i])
            if my_csum != csum:
                CPL.log('Hub.decap', 'csum(%d) != calculated csum(%d)' %
                        (csum, my_csum))

        # Magic trailer value. I don't know what this means, but ctrl-d can be Unix EOF.    
        #
        if trailer != 4:
            CPL.error('Hub.decap', 'trailer is not 4 (%d)' % (trailer))
            CPL.log('Hub.decap', "mid=%d cid=%d len=%d msg='%s'" \
                    % (mid, cid, length, msg))

        buf = buf[fullLength:]
        
        if self.debug >= 7:
            CPL.log("Binary.decap", "csum=%d match=%s trailer=%d left=%d (%r) msg=(%r)" %\
                    (csum, csum == my_csum, trailer, len(buf), buf, msg))
        elif self.debug >= 5:
            CPL.log("Binary.decap", "csum=%d match=%s trailer=%d left=%d (%r)" %\
                    (csum, csum == my_csum, trailer, len(buf), buf))

        d = {'mid':mid,
             'cid':cid
             }

        if is_file:
            d['flag'] = 'i'
#.........这里部分代码省略.........
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:103,代码来源:BinaryReplyDecoder.py


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