Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Apr 10, 2024
1 parent 9ca45d6 commit f27531c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
2 changes: 2 additions & 0 deletions counterparty-lib/counterpartylib/lib/api/api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@ class APIServer(threading.Thread):
def __init__(self, db=None):
self.db = db
self.is_ready = False
self.server = None
self.ctx = None
threading.Thread.__init__(self)

def stop(self):
Expand Down
4 changes: 2 additions & 2 deletions counterparty-lib/counterpartylib/lib/messages/rps.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def compose(db, source, possible_moves, wager, move_random_hash, expiration):
return (source, [], data)


def upack(message, return_dict=False):
def unpack(message, return_dict=False):
try:
if len(message) != LENGTH:
raise exceptions.UnpackError
Expand All @@ -322,7 +322,7 @@ def upack(message, return_dict=False):
def parse(db, tx, message):
rps_parse_cursor = db.cursor()
# Unpack message.
possible_moves, wager, move_random_hash, expiration, status = upack(message)
possible_moves, wager, move_random_hash, expiration, status = unpack(message)

if status == "open":
move_random_hash = binascii.hexlify(move_random_hash).decode("utf8")
Expand Down
34 changes: 17 additions & 17 deletions counterparty-lib/counterpartylib/lib/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,69 +1056,69 @@ def unpack(db, datahex, block_index=None):
message_data = {"error": "Unknown message type"}
# Bet
if message_type_id == messages.bet.ID:
message_type = "bet"
message_type_name = "bet"
message_data = messages.bet.unpack(message, return_dict=True)
# Broadcast
elif message_type_id == messages.broadcast.ID:
message_type = "broadcast"
message_type_name = "broadcast"
message_data = messages.broadcast.unpack(message, block_index, return_dict=True)
# BTCPay
elif message_type_id == messages.btcpay.ID:
message_type = "btcpay"
message_type_name = "btcpay"
message_data = messages.btcpay.unpack(message, return_dict=True)
# Cancel
elif message_type_id == messages.cancel.ID:
message_type = "cancel"
message_type_name = "cancel"
message_data = messages.cancel.unpack(message, return_dict=True)
# Destroy
elif message_type_id == messages.destroy.ID:
message_type = "destroy"
message_type_name = "destroy"
message_data = messages.destroy.unpack(db, message, return_dict=True)
# Dispenser
elif message_type_id == messages.dispenser.ID:
message_type = "dispenser"
message_type_name = "dispenser"
message_data = messages.dispenser.unpack(message, return_dict=True)
# Dividend
elif message_type_id == messages.dividend.ID:
message_type = "dividend"
message_data = messages.dividend.unpack(db, message, return_dict=True)
message_type_name = "dividend"
message_data = messages.dividend.unpack(db, message, block_index, return_dict=True)
# Issuance
elif message_type_id in issuance_ids:
message_type = "issuance"
message_type_name = "issuance"
message_data = messages.issuance.unpack(
db, message, message_type_id, block_index, return_dict=True
)
# Order
elif message_type_id == messages.order.ID:
message_type = "order"
message_type_name = "order"
message_data = messages.order.unpack(db, message, block_index, return_dict=True)
# Send
elif message_type_id == messages.send.ID:
message_type = "send"
message_type_name = "send"
message_data = messages.send.unpack(db, message, block_index)
# Enhanced send
elif message_type_id == messages.versions.enhanced_send.ID:
message_type = "enhanced_send"
message_type_name = "enhanced_send"
message_data = messages.versions.enhanced_send.unpack(message, block_index)
# MPMA send
elif message_type_id == messages.versions.mpma.ID:
message_type = "mpma_send"
message_type_name = "mpma_send"
message_data = messages.versions.mpma.unpack(message, block_index)
# RPS
elif message_type_id == messages.rps.ID:
message_type = "rps"
message_type_name = "rps"
message_data = messages.rps.unpack(message, return_dict=True)
# RPS Resolve
elif message_type_id == messages.rpsresolve.ID:
message_type = "rpsresolve"
message_type_name = "rpsresolve"
message_data = messages.rpsresolve.unpack(message, return_dict=True)
# Sweep
elif message_type_id == messages.sweep.ID:
message_type = "sweep"
message_type_name = "sweep"
message_data = messages.sweep.unpack(message)

return {
"message_type": message_type,
"message_type": message_type_name,
"message_type_id": message_type_id,
"message_data": message_data,
}
6 changes: 4 additions & 2 deletions counterparty-lib/counterpartylib/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class ConfigurationError(Exception):

SIGTERM_CALLBACKS = []

global api_server_v1, api_server, api_status_poller # noqa: PLW0603

Check warning

Code scanning / pylint

Using the global statement at the module level. Warning

Using the global statement at the module level.


def sigterm_handler(_signo, _stack_frame):
if _signo == 15:
Expand Down Expand Up @@ -492,10 +494,10 @@ def initialise_config(
config.API_PORT = int(config.API_PORT)
if not (int(config.API_PORT) > 1 and int(config.API_PORT) < 65535):
raise ConfigurationError("invalid server API port number")
except: # noqa: E722
except ConfigurationError as e: # noqa: E722
raise ConfigurationError( # noqa: B904
"Please specific a valid port number api-port configuration parameter"
)
) from e

if api_user:
config.API_USER = api_user
Expand Down

0 comments on commit f27531c

Please sign in to comment.