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


Python util.log函数代码示例

本文整理汇总了Python中mlat.client.util.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: detect

    def detect(self, data):
        n, detected_mode = detect_data_format(data)
        if detected_mode is not None:
            log("Detected {mode} format input".format(mode=detected_mode))
            if detected_mode == _modes.AVR:
                log("Input format is AVR with no timestamps. "
                    "This format does not contain enough information for multilateration. "
                    "Please enable mlat timestamps on your receiver.")
                self.close()
                return (0, (), False)

            self.reader.mode = detected_mode
            self.feed = self.reader.feed

            # synthesize a mode-change event before the real messages
            mode_change = (mode_change_event(self.reader), )

            try:
                m, messages, pending_error = self.feed(data[n:])
            except ValueError:
                # return just the mode change and keep the error pending
                return (n, mode_change, True)

            # put the mode change on the front of the message list
            return (n + m, mode_change + messages, pending_error)
        else:
            if len(data) > 512:
                raise ValueError('Unable to autodetect input message format')
            return (0, (), False)
开发者ID:mutability,项目名称:mlat-client,代码行数:29,代码来源:receiver.py

示例2: reconnect

    def reconnect(self):
        if self.state != 'disconnected':
            self.disconnect('About to reconnect')

        try:
            self.reset_connection()

            if len(self.addrlist) == 0:
                # ran out of addresses to try, resolve it again
                self.addrlist = socket.getaddrinfo(host=self.host,
                                                   port=self.port,
                                                   family=socket.AF_UNSPEC,
                                                   type=socket.SOCK_STREAM,
                                                   proto=0,
                                                   flags=0)

            # try the next available address
            a_family, a_type, a_proto, a_canonname, a_sockaddr = self.addrlist[0]
            del self.addrlist[0]

            sock = self.create_socket(a_family, a_type)
            self.connect(a_sockaddr)
        except socket.error as e:
            log('Connection to {host}:{port} failed: {ex!s}', host=self.host, port=self.port, ex=e)
            self.close()
开发者ID:Sondermannolaf,项目名称:mlat-client,代码行数:25,代码来源:net.py

示例3: __init__

    def __init__(self, port, connection_factory):
        asyncore.dispatcher.__init__(self)
        self.port = port

        self.a_type = socket.SOCK_STREAM
        try:
            # bind to V6 so we can accept both V4 and V6
            # (asyncore makes it a hassle to bind to more than
            # one address here)
            self.a_family = socket.AF_INET6
            self.create_socket(self.a_family, self.a_type)
        except socket.error:
            # maybe no v6 support?
            self.a_family = socket.AF_INET
            self.create_socket(self.a_family, self.a_type)

        try:
            self.set_reuse_addr()
            self.bind(('', port))
            self.listen(5)
        except:
            self.close()
            raise

        self.output_channels = set()
        self.connection_factory = connection_factory
        log('Listening for {0} on port {1}', connection_factory.describe(), port)
开发者ID:mutability,项目名称:mlat-client,代码行数:27,代码来源:output.py

示例4: handle_error

    def handle_error(self):
        t, v, tb = sys.exc_info()
        if isinstance(v, IOError):
            log("Connection to {host}:{port} lost: {ex!s}", host=self.host, port=self.port, ex=v)
        else:
            log_exc("Unexpected exception on connection to {host}:{port}", host=self.host, port=self.port)

        self.handle_close()
开发者ID:na5ss,项目名称:mlat-client,代码行数:8,代码来源:net.py

示例5: handle_accept

    def handle_accept(self):
        accepted = self.accept()
        if not accepted:
            return

        new_socket, address = accepted
        log('Accepted {0} from {1}:{2}', self.connection_factory.describe(), address[0], address[1])

        self.output_channels.add(self.connection_factory(self, new_socket, address))
开发者ID:na5ss,项目名称:mlat-client,代码行数:9,代码来源:output.py

示例6: start_connection

    def start_connection(self):
        log('Input connected to {0}:{1}', self.host, self.port)
        self.last_data_received = monotonic_time()
        self.state = 'connected'
        self.coordinator.input_connected()

        # synthesize a mode change immediately if we are not autodetecting
        if self.reader.mode is not None:
            self.coordinator.input_received_messages((mode_change_event(self.reader),))
开发者ID:Sondermannolaf,项目名称:mlat-client,代码行数:9,代码来源:receiver.py

示例7: reconnect

    def reconnect(self):
        if self.state != "disconnected":
            self.disconnect("About to reconnect")

        try:
            self.reset_connection()
            self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
            self.connect((self.host, self.port))
        except socket.error as e:
            log("Connection to {host}:{port} failed: {ex!s}", host=self.host, port=self.port, ex=e)
            self.close()
开发者ID:na5ss,项目名称:mlat-client,代码行数:11,代码来源:net.py

示例8: consume_readbuf_uncompressed

    def consume_readbuf_uncompressed(self):
        lines = self.readbuf.split(b'\n')
        self.readbuf = lines[-1]
        for line in lines[:-1]:
            try:
                msg = json.loads(line.decode('ascii'))
            except ValueError:
                log("json parsing problem, line: >>{line}<<", line=line)
                raise

            self.handle_server_line(msg)
开发者ID:na5ss,项目名称:mlat-client,代码行数:11,代码来源:jsonclient.py

示例9: handle_connected_request

    def handle_connected_request(self, request):
        if DEBUG:
            log('Receive: {0}', request)
        if 'start_sending' in request:
            self.coordinator.server_start_sending([int(x, 16) for x in request['start_sending']])
        elif 'stop_sending' in request:
            self.coordinator.server_stop_sending([int(x, 16) for x in request['stop_sending']])
        elif 'heartbeat' in request:
            pass
        elif 'result' in request:
            result = request['result']
            ecef = result.get('ecef')
            if ecef is not None:
                # new format
                lat, lon, alt = mlat.geodesy.ecef2llh(ecef)
                alt = alt / 0.3038   # convert meters to feet
                ecef_cov = result.get('cov')
                if ecef_cov:
                    var_est = ecef_cov[0] + ecef_cov[3] + ecef_cov[5]
                    if var_est >= 0:
                        error_est = math.sqrt(var_est)
                    else:
                        error_est = -1
                else:
                    error_est = -1
                nstations = result['nd']
                callsign = None
                squawk = None
            else:
                lat = result['lat']
                lon = result['lon']
                alt = result['alt']
                error_est = result['gdop'] * 300   # make a guess
                nstations = result['nstations']
                callsign = result['callsign']
                squawk = result['squawk']

            self.coordinator.server_mlat_result(timestamp=result['@'],
                                                addr=int(result['addr'], 16),
                                                lat=lat,
                                                lon=lon,
                                                alt=alt,
                                                nsvel=None,
                                                ewvel=None,
                                                vrate=None,
                                                callsign=callsign,
                                                squawk=squawk,
                                                error_est=error_est,
                                                nstations=nstations,
                                                anon=False,
                                                modeac=False)
        else:
            log('ignoring request from server: {0}', request)
开发者ID:mutability,项目名称:mlat-client,代码行数:53,代码来源:jsonclient.py

示例10: handle_read

    def handle_read(self):
        try:
            moredata = self.recv(16384)
        except socket.error as e:
            if e.errno == errno.EAGAIN:
                return
            raise

        if not moredata:
            self.close()
            return

        global_stats.receiver_rx_bytes += len(moredata)

        if self.residual:
            moredata = self.residual + moredata

        self.last_data_received = monotonic_time()

        try:
            consumed, messages, pending_error = self.feed(moredata)
        except ValueError as e:
            log("Parsing receiver data failed: {e}", e=str(e))
            self.close()
            return

        if consumed < len(moredata):
            self.residual = moredata[consumed:]
            if len(self.residual) > 5120:
                raise RuntimeError('parser broken - buffer not being consumed')
        else:
            self.residual = None

        global_stats.receiver_rx_messages += self.reader.received_messages
        global_stats.receiver_rx_filtered += self.reader.suppressed_messages
        self.reader.received_messages = self.reader.suppressed_messages = 0

        if messages:
            self.coordinator.input_received_messages(messages)

        if pending_error:
            # call it again to get the exception
            # now that we've handled all the messages
            try:
                if self.residual is None:
                    self.feed(b'')
                else:
                    self.feed(self.residual)
            except ValueError as e:
                log("Parsing receiver data failed: {e}", e=str(e))
                self.close()
                return
开发者ID:mutability,项目名称:mlat-client,代码行数:52,代码来源:receiver.py

示例11: __init__

    def __init__(self, port, connection_factory):
        asyncore.dispatcher.__init__(self)
        self.port = port

        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.set_reuse_addr()
        self.bind(('', port))
        self.listen(0)

        self.output_channels = set()
        self.connection_factory = connection_factory

        log('Listening for {0} on port {1}', connection_factory.describe(), port)
开发者ID:na5ss,项目名称:mlat-client,代码行数:13,代码来源:output.py

示例12: close

    def close(self, manual_close=False):
        asyncore.dispatcher.close(self)

        if self.state != 'disconnected':
            if not manual_close:
                log('Lost connection to {host}:{port}', host=self.host, port=self.port)

            self.state = 'disconnected'
            self.reset_connection()
            self.lost_connection()

        if not manual_close:
            self.schedule_reconnect()
开发者ID:Sondermannolaf,项目名称:mlat-client,代码行数:13,代码来源:net.py

示例13: periodic_stats

    def periodic_stats(self, now):
        log('Receiver status: {0}', self.receiver.state)
        log('Server status:   {0}', self.server.state)
        global_stats.log_and_reset()

        adsb_req = adsb_total = modes_req = modes_total = 0
        now = monotonic_time()
        for ac in self.aircraft.values():
            if ac.messages < 2:
                continue

            if now - ac.last_position_time < self.position_expiry_age:
                adsb_total += 1
                if ac.requested:
                    adsb_req += 1
            else:
                modes_total += 1
                if ac.requested:
                    modes_req += 1

        log('Aircraft: {modes_req} of {modes_total} Mode S, {adsb_req} of {adsb_total} ADS-B used',
            modes_req=modes_req,
            modes_total=modes_total,
            adsb_req=adsb_req,
            adsb_total=adsb_total)

        if self.recent_jumps > 0:
            log('Out-of-order timestamps: {recent}', recent=self.recent_jumps)
            self.recent_jumps = 0
开发者ID:Sondermannolaf,项目名称:mlat-client,代码行数:29,代码来源:coordinator.py

示例14: schedule_reconnect

    def schedule_reconnect(self):
        if self.reconnect_at is None:
            if len(self.addrlist) > 0:
                # we still have more addresses to try
                # nb: asyncore breaks in odd ways if you try
                # to reconnect immediately at this point
                # (pending events for the old socket go to
                # the new socket) so do it in 0.5s time
                # so the caller can clean up the old
                # socket and discard the events.
                interval = 0.5
            else:
                interval = self.reconnect_interval

            log('Reconnecting in {0} seconds', interval)
            self.reconnect_at = monotonic_time() + interval
开发者ID:Sondermannolaf,项目名称:mlat-client,代码行数:16,代码来源:net.py

示例15: close

    def close(self, manual_close=False):
        try:
            asyncore.dispatcher.close(self)
        except AttributeError:
            # blarg, try to eat asyncore bugs
            pass

        if self.state != 'disconnected':
            if not manual_close:
                log('Lost connection to {host}:{port}', host=self.host, port=self.port)

            self.state = 'disconnected'
            self.reset_connection()
            self.lost_connection()

        if not manual_close:
            self.schedule_reconnect()
开发者ID:mutability,项目名称:mlat-client,代码行数:17,代码来源:net.py


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