clean pylints
This commit is contained in:
parent
ff4b240262
commit
cc6e2c6116
2
.gitignore
vendored
2
.gitignore
vendored
@ -160,3 +160,5 @@ cython_debug/
|
|||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
.pylint.err
|
||||||
|
.pylint.log
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
# -*- mode: text; indent-tabs-mode: nil; coding: utf-8 -*-
|
|
||||||
|
|
||||||
# tox_profile
|
# tox_profile
|
||||||
|
|
||||||
Read and manipulate tox profile files. It started as a simple script from
|
Read and manipulate tox profile files. It started as a simple script from
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
# -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*-
|
# -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*-
|
||||||
|
|
||||||
|
# originally from:
|
||||||
# https://stackoverflow.com/questions/30901873/what-format-are-tox-files-stored-in
|
# https://stackoverflow.com/questions/30901873/what-format-are-tox-files-stored-in
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
from socket import inet_ntop, AF_INET6, AF_INET
|
from socket import inet_ntop, AF_INET6, AF_INET
|
||||||
|
import logging
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# https://pypi.org/project/msgpack/
|
||||||
import msgpack
|
import msgpack
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
msgpack = None
|
msgpack = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# https://github.com/toxygen-project/toxygen
|
# https://github.com/toxygen-project/toxygen
|
||||||
from wrapper.toxencryptsave import ToxEncryptSave
|
from wrapper.toxencryptsave import ToxEncryptSave
|
||||||
@ -31,8 +35,6 @@ try:
|
|||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
coloredlogs = False
|
coloredlogs = False
|
||||||
|
|
||||||
global LOG
|
|
||||||
import logging
|
|
||||||
LOG = logging.getLogger()
|
LOG = logging.getLogger()
|
||||||
|
|
||||||
#messenger.c
|
#messenger.c
|
||||||
@ -137,9 +139,9 @@ def process_chunk(index, state):
|
|||||||
subtotal = 1 + alen + 2 + 32
|
subtotal = 1 + alen + 2 + 32
|
||||||
port = struct.unpack_from(">H", result, offset+8+1+alen)[0]
|
port = struct.unpack_from(">H", result, offset+8+1+alen)[0]
|
||||||
pk = bin_to_hex(result[offset+8+1+alen+2:offset+8+1+alen+2+32], 32)
|
pk = bin_to_hex(result[offset+8+1+alen+2:offset+8+1+alen+2+32], 32)
|
||||||
|
|
||||||
LOG.info(f"{dSTATE_TYPE[data_type]} #{relay} status={status} ipaddr={ipaddr} port={port} {pk}")
|
LOG.info(f"{dSTATE_TYPE[data_type]} #{relay} status={status} ipaddr={ipaddr} port={port} {pk}")
|
||||||
offset += subtotal
|
offset += subtotal
|
||||||
delta += total
|
delta += total
|
||||||
length -= total
|
length -= total
|
||||||
relay += 1
|
relay += 1
|
||||||
@ -149,24 +151,24 @@ def process_chunk(index, state):
|
|||||||
|
|
||||||
The integers in this structure are stored in Big Endian format.
|
The integers in this structure are stored in Big Endian format.
|
||||||
|
|
||||||
Length Contents
|
Length Contents
|
||||||
1 uint8_t Status
|
1 uint8_t Status
|
||||||
32 Long term public key
|
32 Long term public key
|
||||||
1024 Friend request message as a byte string
|
1024 Friend request message as a byte string
|
||||||
1 PADDING
|
1 PADDING
|
||||||
2 uint16_t Size of the friend request message
|
2 uint16_t Size of the friend request message
|
||||||
128 Name as a byte string
|
128 Name as a byte string
|
||||||
2 uint16_t Size of the name
|
2 uint16_t Size of the name
|
||||||
1007 Status message as a byte string
|
1007 Status message as a byte string
|
||||||
1 PADDING
|
1 PADDING
|
||||||
2 uint16_t Size of the status message
|
2 uint16_t Size of the status message
|
||||||
1 uint8_t User status (see also: USERSTATUS)
|
1 uint8_t User status (see also: USERSTATUS)
|
||||||
3 PADDING
|
3 PADDING
|
||||||
4 uint32_t Nospam (only used for sending a friend request)
|
4 uint32_t Nospam (only used for sending a friend request)
|
||||||
8 uint64_t Last seen time
|
8 uint64_t Last seen time
|
||||||
|
|
||||||
"""
|
"""
|
||||||
dStatus = { # Status Meaning
|
dStatus = { # Status Meaning
|
||||||
0: 'Not a friend ',
|
0: 'Not a friend ',
|
||||||
1: 'Friend added ',
|
1: 'Friend added ',
|
||||||
2: 'Friend request sent ',
|
2: 'Friend request sent ',
|
||||||
@ -182,7 +184,7 @@ The integers in this structure are stored in Big Endian format.
|
|||||||
status = struct.unpack_from(">b", result, delta)[0]
|
status = struct.unpack_from(">b", result, delta)[0]
|
||||||
o = delta+1; l = 32
|
o = delta+1; l = 32
|
||||||
pk = bin_to_hex(result[o:o+l], l)
|
pk = bin_to_hex(result[o:o+l], l)
|
||||||
|
|
||||||
o = delta+1+32+1024+1+2+128; l = 2
|
o = delta+1+32+1024+1+2+128; l = 2
|
||||||
nsize = struct.unpack_from(">H", result, o)[0]
|
nsize = struct.unpack_from(">H", result, o)[0]
|
||||||
o = delta+1+32+1024+1+2; l = 128
|
o = delta+1+32+1024+1+2; l = 128
|
||||||
@ -195,17 +197,17 @@ The integers in this structure are stored in Big Endian format.
|
|||||||
LOG.info(f"Friend #{i} {dStatus[status]} {name} {pk}")
|
LOG.info(f"Friend #{i} {dStatus[status]} {name} {pk}")
|
||||||
|
|
||||||
elif data_type == MESSENGER_STATE_TYPE_NAME:
|
elif data_type == MESSENGER_STATE_TYPE_NAME:
|
||||||
LOG.info("User name = {}".format(str(state[index + 8:index + 8 + length], 'utf-8')))
|
LOG.info("User name = " +str(state[index + 8:index + 8 + length], 'utf-8'))
|
||||||
|
|
||||||
elif data_type == MESSENGER_STATE_TYPE_STATUSMESSAGE:
|
elif data_type == MESSENGER_STATE_TYPE_STATUSMESSAGE:
|
||||||
LOG.info(f"StatusMessage = {str(state[index + 8:index + 8 + length], 'utf-8')}")
|
LOG.info(f"StatusMessage = {str(state[index + 8:index + 8 + length], 'utf-8')}")
|
||||||
|
|
||||||
elif data_type == MESSENGER_STATE_TYPE_STATUS:
|
elif data_type == MESSENGER_STATE_TYPE_STATUS:
|
||||||
# 1 uint8_t status (0 = online, 1 = away, 2 = busy)
|
# 1 uint8_t status (0 = online, 1 = away, 2 = busy)
|
||||||
dStatus = {0: 'online', 1: 'away', 2: 'busy'}
|
dStatus = {0: 'online', 1: 'away', 2: 'busy'}
|
||||||
status = struct.unpack_from(">b", state, index)[0]
|
status = struct.unpack_from(">b", state, index)[0]
|
||||||
LOG.info(f"{dSTATE_TYPE[data_type]} = {dStatus[status]}")
|
LOG.info(f"{dSTATE_TYPE[data_type]} = {dStatus[status]}")
|
||||||
|
|
||||||
elif data_type == MESSENGER_STATE_TYPE_GROUPS:
|
elif data_type == MESSENGER_STATE_TYPE_GROUPS:
|
||||||
result = state[index + 8:index + 8 + length]
|
result = state[index + 8:index + 8 + length]
|
||||||
if msgpack:
|
if msgpack:
|
||||||
@ -223,9 +225,9 @@ The integers in this structure are stored in Big Endian format.
|
|||||||
keys, \
|
keys, \
|
||||||
self_info, \
|
self_info, \
|
||||||
saved_peers, = group
|
saved_peers, = group
|
||||||
|
|
||||||
assert len(state_values) == 8, state_values
|
assert len(state_values) == 8, state_values
|
||||||
|
|
||||||
assert len(state_bin) == 5, state_bin
|
assert len(state_bin) == 5, state_bin
|
||||||
|
|
||||||
assert len(topic_info) == 6, topic_info
|
assert len(topic_info) == 6, topic_info
|
||||||
@ -242,14 +244,14 @@ The integers in this structure are stored in Big Endian format.
|
|||||||
for j in range(num_moderators):
|
for j in range(num_moderators):
|
||||||
mod = mods[j*32:j*32 + 32]
|
mod = mods[j*32:j*32 + 32]
|
||||||
LOG.info(f"{dSTATE_TYPE[data_type]} group#{i} mod#{j} sig_pk={bin_to_hex(mod)}")
|
LOG.info(f"{dSTATE_TYPE[data_type]} group#{i} mod#{j} sig_pk={bin_to_hex(mod)}")
|
||||||
|
|
||||||
assert len(keys) == 4, keys
|
assert len(keys) == 4, keys
|
||||||
LOG.info(f"{dSTATE_TYPE[data_type]} #{i} {repr(list(map(len, keys)))}")
|
LOG.info(f"{dSTATE_TYPE[data_type]} #{i} {repr(list(map(len, keys)))}")
|
||||||
chat_public_key, chat_secret_key, self_public_key, self_secret_key = keys
|
chat_public_key, chat_secret_key, self_public_key, self_secret_key = keys
|
||||||
LOG.info(f"{dSTATE_TYPE[data_type]} #{i} chat_public_key={bin_to_hex(chat_public_key)}")
|
LOG.info(f"{dSTATE_TYPE[data_type]} #{i} chat_public_key={bin_to_hex(chat_public_key)}")
|
||||||
if int(bin_to_hex(chat_secret_key), 16) != 0:
|
if int(bin_to_hex(chat_secret_key), 16) != 0:
|
||||||
LOG.info(f"{dSTATE_TYPE[data_type]} #{i} chat_secret_key={bin_to_hex(chat_secret_key)}")
|
LOG.info(f"{dSTATE_TYPE[data_type]} #{i} chat_secret_key={bin_to_hex(chat_secret_key)}")
|
||||||
|
|
||||||
LOG.info(f"{dSTATE_TYPE[data_type]} #{i} self_public_key={bin_to_hex(self_public_key)}")
|
LOG.info(f"{dSTATE_TYPE[data_type]} #{i} self_public_key={bin_to_hex(self_public_key)}")
|
||||||
LOG.info(f"{dSTATE_TYPE[data_type]} #{i} self_secret_key={bin_to_hex(self_secret_key)}")
|
LOG.info(f"{dSTATE_TYPE[data_type]} #{i} self_secret_key={bin_to_hex(self_secret_key)}")
|
||||||
|
|
||||||
@ -259,8 +261,8 @@ The integers in this structure are stored in Big Endian format.
|
|||||||
|
|
||||||
LOG.info(f"{dSTATE_TYPE[data_type]} #{i} self_nick={repr(self_nick)}")
|
LOG.info(f"{dSTATE_TYPE[data_type]} #{i} self_nick={repr(self_nick)}")
|
||||||
assert len(saved_peers) == 2, saved_peers
|
assert len(saved_peers) == 2, saved_peers
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.warn(f"process_chunk {dSTATE_TYPE[data_type]} #{i} error={e}")
|
LOG.warn(f"process_chunk {dSTATE_TYPE[data_type]} #{i} error={e}")
|
||||||
else:
|
else:
|
||||||
LOG.debug(f"TODO process_chunk {dSTATE_TYPE[data_type]} #{i} bytes={length}")
|
LOG.debug(f"TODO process_chunk {dSTATE_TYPE[data_type]} #{i} bytes={length}")
|
||||||
@ -272,12 +274,12 @@ Address, and a Public Key. This is sufficient information to start
|
|||||||
communicating with that node. The binary representation of a Node Info is
|
communicating with that node. The binary representation of a Node Info is
|
||||||
called the “packed node format”.
|
called the “packed node format”.
|
||||||
|
|
||||||
Length Type Contents
|
Length Type Contents
|
||||||
1 bit Transport Protocol UDP = 0, TCP = 1
|
1 bit Transport Protocol UDP = 0, TCP = 1
|
||||||
7 bit Address Family 2 = IPv4, 10 = IPv6
|
7 bit Address Family 2 = IPv4, 10 = IPv6
|
||||||
4 \| 16 IP address 4 bytes for IPv4, 16 bytes for IPv6
|
4 | 16 IP address 4 bytes for IPv4, 16 bytes for IPv6
|
||||||
2 Port Number Port number
|
2 Port Number Port number
|
||||||
32 Public Key Node ID
|
32 Public Key Node ID
|
||||||
|
|
||||||
"""
|
"""
|
||||||
delta = 0
|
delta = 0
|
||||||
@ -306,7 +308,7 @@ called the “packed node format”.
|
|||||||
delta += total
|
delta += total
|
||||||
length -= total
|
length -= total
|
||||||
relay += 1
|
relay += 1
|
||||||
|
|
||||||
elif data_type == MESSENGER_STATE_TYPE_PATH_NODE:
|
elif data_type == MESSENGER_STATE_TYPE_PATH_NODE:
|
||||||
LOG.debug(f"TODO process_chunk {dSTATE_TYPE[data_type]} bytes={length}")
|
LOG.debug(f"TODO process_chunk {dSTATE_TYPE[data_type]} bytes={length}")
|
||||||
elif data_type == MESSENGER_STATE_TYPE_CONFERENCES:
|
elif data_type == MESSENGER_STATE_TYPE_CONFERENCES:
|
||||||
|
Loading…
Reference in New Issue
Block a user