本文整理汇总了Python中mlat.client.util.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: build_outputs
def build_outputs(args):
outputs = []
for s in args.results:
try:
factory = output_factory(s)
except ValueError as e:
log("Warning: Ignoring bad results output option '{0}': {1}",
s, str(e))
continue
try:
output = factory()
except Exception as e:
log("Warning: Could not create results output '{0}': {1}",
s, str(e))
continue
outputs.append(output)
return outputs
开发者ID:mutability,项目名称:mlat-client,代码行数:20,代码来源:options.py
示例17: start_connection
def start_connection(self):
log('Connected to multilateration server at {0}:{1}, handshaking', self.host, self.port)
self.state = 'handshaking'
self.last_data_received = monotonic_time()
compress_methods = ['none']
if self.offer_zlib:
compress_methods.append('zlib')
compress_methods.append('zlib2')
handshake_msg = {'version': 3,
'client_version': mlat.client.version.CLIENT_VERSION,
'compress': compress_methods,
'selective_traffic': True,
'heartbeat': True,
'return_results': self.return_results,
'udp_transport': 2 if self.offer_udp else False,
'return_result_format': 'ecef'}
handshake_msg.update(self.handshake_data)
self.writebuf += (json.dumps(handshake_msg) + '\n').encode('ascii') # linebuf not used yet
self.consume_readbuf = self.consume_readbuf_uncompressed
self.handle_server_line = self.handle_handshake_response
开发者ID:na5ss,项目名称:mlat-client,代码行数:22,代码来源:jsonclient.py
示例18: consume_readbuf_zlib
def consume_readbuf_zlib(self):
i = 0
while i + 2 < len(self.readbuf):
hlen, = struct.unpack_from('!H', self.readbuf, i)
end = i + 2 + hlen
if end > len(self.readbuf):
break
packet = self.readbuf[i + 2:end] + b'\x00\x00\xff\xff'
linebuf = self.decompressor.decompress(packet)
lines = linebuf.split(b'\n')
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)
i = end
del self.readbuf[:i]
开发者ID:na5ss,项目名称:mlat-client,代码行数:23,代码来源:jsonclient.py
示例19: log_and_reset
def log_and_reset(self):
now = monotonic_time()
elapsed = now - self.start
log('Receiver: {0:6.1f} msg/s received {1:4.1f}kB/s from receiver',
self.receiver_rx_messages / elapsed,
self.receiver_rx_bytes / elapsed / 1000.0)
log('Server: {0:6.1f} kB/s from server {1:4.1f}kB/s TCP to server {2:4.1f}kB/s UDP to server',
self.server_rx_bytes / elapsed / 1000.0,
self.server_tx_bytes / elapsed / 1000.0,
self.server_udp_bytes / elapsed / 1000.0)
if self.mlat_positions:
log('Results: {0:3.1f} positions/minute',
self.mlat_positions / elapsed * 60.0)
self.reset(now)
开发者ID:JonFear,项目名称:mlat-client,代码行数:14,代码来源:stats.py
示例20: log_and_reset
def log_and_reset(self):
now = monotonic_time()
elapsed = now - self.start
processed = self.receiver_rx_messages - self.receiver_rx_filtered
log('Receiver: {0:6.1f} msg/s received {1:6.1f} msg/s processed ({2:.0f}%)',
self.receiver_rx_messages / elapsed,
processed / elapsed,
0 if self.receiver_rx_messages == 0 else 100.0 * processed / self.receiver_rx_messages)
log('Server: {0:6.1f} kB/s from server {1:4.1f}kB/s TCP to server {2:6.1f}kB/s UDP to server',
self.server_rx_bytes / elapsed / 1000.0,
self.server_tx_bytes / elapsed / 1000.0,
self.server_udp_bytes / elapsed / 1000.0)
if self.mlat_positions:
log('Results: {0:3.1f} positions/minute',
self.mlat_positions / elapsed * 60.0)
self.reset(now)
开发者ID:Sondermannolaf,项目名称:mlat-client,代码行数:17,代码来源:stats.py
注:本文中的mlat.client.util.log函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论