Don't modify peers[foo].lastseen unless peers[foo] exists
This commit is contained in:
parent
a7f841b0a0
commit
0adee9fc54
10
ethermess.py
10
ethermess.py
|
@ -244,7 +244,8 @@ def handle_user_command(backend, line):
|
|||
# Request status
|
||||
mac = mac_from_name(rest)
|
||||
if mac in peers:
|
||||
print('%s === ~%s (%s) [%s]' % (timestamp(), peers[mac].nick, peers[mac].status.name, format_mac(mac)))
|
||||
peer = peers[mac]
|
||||
print('%s === ~%s (%s) [%s]' % (timestamp(), peer.nick, peer.status.name, format_mac(mac)))
|
||||
send_status_request(backend, mac)
|
||||
|
||||
else:
|
||||
|
@ -329,7 +330,6 @@ def handle_status(mac, status, nick):
|
|||
# Never seen before
|
||||
peers[mac] = Peer(nick = None, status = None, lastseen = None)
|
||||
|
||||
|
||||
if peers[mac].nick is not None and peers[mac].status != statuses.offline and nick != peers[mac].nick:
|
||||
print('%s === ~%s -> ~%s [%s]' % (timestamp(), peers[mac].nick, nick, format_mac(mac)))
|
||||
|
||||
|
@ -462,7 +462,8 @@ def eventloop(proc):
|
|||
source_mac = readall(proc.stdout, 6)
|
||||
msgid = readall_u16(proc.stdout)
|
||||
|
||||
peers[source_mac].lastseen = time.monotonic()
|
||||
if source_mac in peers:
|
||||
peers[source_mac].lastseen = time.monotonic()
|
||||
|
||||
# Was it for a message currently waiting?
|
||||
if len(send_queue) > 0 and send_queue[0].msgid == msgid:
|
||||
|
@ -504,7 +505,8 @@ def eventloop(proc):
|
|||
|
||||
handle_message(source_mac, message.decode('utf-8'))
|
||||
|
||||
peers[source_mac].lastseen = time.monotonic()
|
||||
if source_mac in peers:
|
||||
peers[source_mac].lastseen = time.monotonic()
|
||||
|
||||
else:
|
||||
raise ValueError('Unknown event type from backend: %s' % repr(event_type))
|
||||
|
|
Loading…
Reference in New Issue