From 9c5dabc1666b581fe8ccd6423866f3476b3a7ad4 Mon Sep 17 00:00:00 2001 From: zebra-lucky Date: Fri, 28 Nov 2025 21:35:20 +0200 Subject: [PATCH] replace deprecated log.warn to warning --- src/jmclient/blockchaininterface.py | 27 ++++----- src/jmclient/client_protocol.py | 10 ++-- src/jmclient/frost_clients.py | 2 +- src/jmclient/jsonrpc.py | 10 ++-- src/jmclient/payjoin.py | 9 +-- src/jmclient/support.py | 6 +- src/jmclient/taker.py | 19 ++++--- src/jmclient/taker_utils.py | 2 +- src/jmclient/wallet.py | 2 +- src/jmclient/wallet_rpc.py | 23 ++++---- src/jmclient/wallet_service.py | 4 +- src/jmclient/websocketserver.py | 4 +- src/jmdaemon/irc.py | 2 +- src/jmdaemon/message_channel.py | 8 +-- src/jmdaemon/onionmc.py | 85 ++++++++++++++++------------- 15 files changed, 115 insertions(+), 98 deletions(-) diff --git a/src/jmclient/blockchaininterface.py b/src/jmclient/blockchaininterface.py index 7cb9a29..caccee9 100644 --- a/src/jmclient/blockchaininterface.py +++ b/src/jmclient/blockchaininterface.py @@ -288,8 +288,8 @@ class BlockchainInterface(ABC): msg = msg + " (randomized for privacy)" fallback_fee_randomized = random.uniform( fallback_fee, fallback_fee * float(1 + tx_fees_factor)) - log.warn(msg + ": " + - btc.fee_per_kb_to_str(fallback_fee_randomized) + ".") + log.warning(msg + ": " + + btc.fee_per_kb_to_str(fallback_fee_randomized) + ".") return int(fallback_fee_randomized) feerate, blocks = retval @@ -477,7 +477,7 @@ class BitcoinCoreInterface(BlockchainInterface): if row['success'] == False: num_failed += 1 # don't try/catch, assume failure always has error message - log.warn(row['error']['message']) + log.warning(row['error']['message']) if num_failed > 0: fatal_msg = ("Fatal sync error: import of {} address(es) failed for " "some reason. To prevent coin or privacy loss, " @@ -520,7 +520,7 @@ class BitcoinCoreInterface(BlockchainInterface): if row['success'] == False: num_failed += 1 # don't try/catch, assume failure always has error message - log.warn(row['error']['message']) + log.warning(row['error']['message']) if num_failed > 0: fatal_msg = ("Fatal sync error: import of {} address(es) failed for " "some reason. To prevent coin or privacy loss, " @@ -561,11 +561,11 @@ class BitcoinCoreInterface(BlockchainInterface): res = self._rpc("gettransaction", [htxid, True]) except JsonRpcError as e: #This should never happen (gettransaction is a wallet rpc). - log.warn("Failed gettransaction call; JsonRpcError: " + repr(e)) + log.warning("Failed gettransaction call; JsonRpcError: " + repr(e)) return None except Exception as e: - log.warn("Failed gettransaction call; unexpected error:") - log.warn(str(e)) + log.warning("Failed gettransaction call; unexpected error:") + log.warning(str(e)) return None if res is None: # happens in case of rpc connection failure: @@ -580,11 +580,12 @@ class BitcoinCoreInterface(BlockchainInterface): try: res = self._rpc("getrawtransaction", [htxid]) except JsonRpcError as e: - log.warn("Failed getrawtransaction call; JsonRpcError: " + repr(e)) + log.warning("Failed getrawtransaction call; JsonRpcError: " + + repr(e)) return None except Exception as e: - log.warn("Failed getrawtransaction call; unexpected error:") - log.warn(str(e)) + log.warning("Failed getrawtransaction call; unexpected error:") + log.warning(str(e)) return None if res is None: # happens in case of rpc connection failure: @@ -616,13 +617,13 @@ class BitcoinCoreInterface(BlockchainInterface): for txo in txouts: txo_hex = bintohex(txo[0]) if len(txo_hex) != 64: - log.warn("Invalid utxo format, ignoring: {}".format(txo)) + log.warning("Invalid utxo format, ignoring: {}".format(txo)) result.append(None) continue try: txo_idx = int(txo[1]) except ValueError: - log.warn("Invalid utxo format, ignoring: {}".format(txo)) + log.warning("Invalid utxo format, ignoring: {}".format(txo)) result.append(None) continue ret = self._rpc('gettxout', [txo_hex, txo_idx, include_mempool]) @@ -674,7 +675,7 @@ class BitcoinCoreInterface(BlockchainInterface): if estimate and estimate > 0: return (btc.btc_to_sat(estimate), rpc_result.get('blocks')) # cannot get a valid estimate after `tries` tries: - log.warn("Could not source a fee estimate from Core") + log.warning("Could not source a fee estimate from Core") return None def get_current_block_height(self) -> int: diff --git a/src/jmclient/client_protocol.py b/src/jmclient/client_protocol.py index 30230e7..2c0abfb 100644 --- a/src/jmclient/client_protocol.py +++ b/src/jmclient/client_protocol.py @@ -273,7 +273,8 @@ class SNICKERClientProtocol(BaseClientProtocol): try: proposals = proposals.split("\n") except: - jlog.warn("Error in parsing proposals from server: " + str(server)) + jlog.warning("Error in parsing proposals from" + " server: " + str(server)) return {"accepted": True} reactor.callLater(0.0, self.process_proposals, proposals) return {"accepted": True} @@ -421,7 +422,7 @@ class JMClientProtocol(BaseClientProtocol): if session_id is None: session_id, _, session = self.dkg_init(*md_type_idx) if session_id is None: - jlog.warn('could not get session_id from dkg_init}') + jlog.warning('could not get session_id from dkg_init}') await asyncio.sleep(5) continue @@ -1209,8 +1210,9 @@ def start_reactor(host, port, factory=None, snickerfactory=None, name, str(p[0] - port_offset))) break except Exception: - jlog.warn("Cannot listen on port " + str( - p[0] - port_offset) + ", trying next port") + jlog.warning("Cannot listen on port " + + str(p[0] - port_offset) + + ", trying next port") if p[0] >= (orgp + 100): jlog.error("Tried 100 ports but cannot " "listen on any of them. Quitting.") diff --git a/src/jmclient/frost_clients.py b/src/jmclient/frost_clients.py index 439f820..fe8fbba 100644 --- a/src/jmclient/frost_clients.py +++ b/src/jmclient/frost_clients.py @@ -465,7 +465,7 @@ class DKGClient: f'{session_id.hex()}') return session.dkg_output.threshold_pubkey except Exception as e: - jlog.warn(f'wait_on_dkg_output: {repr(e)}') + jlog.warning(f'wait_on_dkg_output: {repr(e)}') finally: sess_id = self.dkg_sessions.pop(session_id, None) if not sess_id: diff --git a/src/jmclient/jsonrpc.py b/src/jmclient/jsonrpc.py index 7a98018..a4eedf1 100644 --- a/src/jmclient/jsonrpc.py +++ b/src/jmclient/jsonrpc.py @@ -108,17 +108,17 @@ class JsonRpc(object): return "CONNFAILURE" except socket.error as e: if e.errno == errno.ECONNRESET: - jlog.warn('Connection was reset, attempting reconnect.') + jlog.warning('Connection was reset, attempting reconnect.') self.conn.close() self.conn.connect() elif e.errno == errno.EPIPE: - jlog.warn('Connection had broken pipe, attempting ' - 'reconnect.') + jlog.warning('Connection had broken pipe, attempting ' + 'reconnect.') self.conn.close() self.conn.connect() elif e.errno == errno.EPROTOTYPE: - jlog.warn('Connection had protocol wrong type for socket ' - 'error, attempting reconnect.') + jlog.warning('Connection had protocol wrong type for' + ' socket error, attempting reconnect.') self.conn.close() self.conn.connect() elif e.errno == errno.ECONNREFUSED: diff --git a/src/jmclient/payjoin.py b/src/jmclient/payjoin.py index 996a005..391d28b 100644 --- a/src/jmclient/payjoin.py +++ b/src/jmclient/payjoin.py @@ -576,8 +576,9 @@ async def fallback_nonpayjoin_broadcast(err, manager): def quit(): if manager.mode == "command-line" and reactor.running: process_shutdown() - log.warn("Payjoin did not succeed, falling back to non-payjoin payment.") - log.warn("Error message was: " + err.decode("utf-8")) + log.warning("Payjoin did not succeed, falling back to non-payjoin" + " payment.") + log.warning("Error message was: " + err.decode("utf-8")) original_tx = manager.initial_psbt.extract_transaction() if not jm_single().bc_interface.pushtx(original_tx.serialize()): errormsg = ("Unable to broadcast original payment. Check your wallet\n" @@ -600,8 +601,8 @@ async def process_error_from_server(errormsg, errorcode, manager): assert isinstance(manager, JMPayjoinManager) # payjoin attempt has failed, we revert to standard payment. assert int(errorcode) != 200 - log.warn("Receiver returned error code: {}, message: {}".format( - errorcode, errormsg)) + log.warning("Receiver returned error code: {}, message:" + " {}".format(errorcode, errormsg)) await fallback_nonpayjoin_broadcast(errormsg.encode("utf-8"), manager) return diff --git a/src/jmclient/support.py b/src/jmclient/support.py index d5d088b..b5e6366 100644 --- a/src/jmclient/support.py +++ b/src/jmclient/support.py @@ -269,9 +269,9 @@ def choose_orders(offers, cj_amount, n, chooseOrdersBy, ignored_makers=None, counterparties = set(o['counterparty'] for o, f in orders_fees) if n > len(counterparties): - log.warn(('ERROR not enough liquidity in the orderbook n=%d ' - 'suitable-counterparties=%d amount=%d totalorders=%d') % - (n, len(counterparties), cj_amount, len(orders_fees))) + log.warning(('ERROR not enough liquidity in the orderbook n=%d ' + 'suitable-counterparties=%d amount=%d totalorders=%d') % + (n, len(counterparties), cj_amount, len(orders_fees))) # TODO handle not enough liquidity better, maybe an Exception return None, 0 """ diff --git a/src/jmclient/taker.py b/src/jmclient/taker.py index 8344f3d..ae1531c 100644 --- a/src/jmclient/taker.py +++ b/src/jmclient/taker.py @@ -471,8 +471,8 @@ class Taker(object): try: self.nonrespondants.remove(maker_inputs.nick) except Exception as e: - jlog.warn( - "Failure to remove counterparty from nonrespondants list:" + jlog.warning( + f"Failure to remove counterparty from nonrespondants list:" f" {maker_inputs.nick}), error message: {repr(e)})") #Apply business logic of how many counterparties are enough; note that @@ -554,10 +554,11 @@ class Taker(object): sweep_delta = float(jm_single().config.get("POLICY", "max_sweep_fee_change")) if feeratio < 1 - sweep_delta or feeratio > 1 + sweep_delta: - jlog.warn("Transaction fee for sweep: {} too far from expected:" - " {}; check the setting 'max_sweep_fee_change'" - " in joinmarket.cfg. Aborting this attempt.".format( - new_total_fee, self.total_txfee)) + jlog.warning("Transaction fee for sweep: {} too far from" + " expected: {}; check the setting" + " 'max_sweep_fee_change' in joinmarket.cfg." + " Aborting this ""attempt." + "".format(new_total_fee, self.total_txfee)) return (False, "Unacceptable feerate for sweep, giving up.") else: self.outputs.append({'address': self.my_change_addr, @@ -601,8 +602,8 @@ class Taker(object): if not validate_address(cj_addr)[0]\ or not validate_address(change_addr)[0]: - jlog.warn("Counterparty provided invalid address: {}".format( - (cj_addr, change_addr))) + jlog.warning("Counterparty provided invalid address:" + " {}".format((cj_addr, change_addr))) # Interpreted as malicious self.add_ignored_makers([nick]) continue @@ -1004,7 +1005,7 @@ class Taker(object): if asyncio.iscoroutine(info_cb_res): info_cb_res = await info_cb_res # warning is arguably not correct but it will stand out more: - jlog.warn(warnmsg) + jlog.warning(warnmsg) jlog.info(btc.human_readable_transaction(tx)) return if not self.push_ourselves(): diff --git a/src/jmclient/taker_utils.py b/src/jmclient/taker_utils.py index 91d0abf..29d9dcf 100644 --- a/src/jmclient/taker_utils.py +++ b/src/jmclient/taker_utils.py @@ -315,7 +315,7 @@ def restart_wait(txid): if res["confirmations"] == 0: return False if res["confirmations"] < 0: - log.warn("Tx: " + txid + " has a conflict, abandoning.") + log.warning("Tx: " + txid + " has a conflict, abandoning.") twisted_sys_exit(EXIT_SUCCESS) else: log.debug("Tx: " + str(txid) + " has " + str( diff --git a/src/jmclient/wallet.py b/src/jmclient/wallet.py index b5d1d2e..b90b8c9 100644 --- a/src/jmclient/wallet.py +++ b/src/jmclient/wallet.py @@ -694,7 +694,7 @@ class DKGManager: 'session_params': session_params, } except Exception as e: - jlog.warn(f'recdkg_ls: Can not recover data{repr(e)}') + jlog.warning(f'recdkg_ls: Can not recover data{repr(e)}') recovery_data = recovery_data.hex() if decoded_ext_rec: dec_res.append([session_id.hex(), dec_ext_rec, recovery_data]) diff --git a/src/jmclient/wallet_rpc.py b/src/jmclient/wallet_rpc.py index 1f1ba6d..e002258 100644 --- a/src/jmclient/wallet_rpc.py +++ b/src/jmclient/wallet_rpc.py @@ -488,7 +488,8 @@ class JMWalletDaemon(Service): # balances; there are various approaches to passing warnings # or requesting rescans, none are implemented yet. def dummy_restart_callback(msg): - jlog.warn("Ignoring rescan request from backend wallet service: " + msg) + jlog.warning("Ignoring rescan request from backend wallet" + " service: " + msg) self.services["wallet"].add_restart_callback(dummy_restart_callback) self.active_session = True self.wss_factory.active_session = True @@ -562,7 +563,7 @@ class JMWalletDaemon(Service): except Exception as e: # Should not happen, but avoid crash if trying to # shut down something that already disconnected: - jlog.warn("Failed to shut down connection: " + repr(e)) + jlog.warning("Failed to shut down connection: " + repr(e)) self.coinjoin_connection = None def filter_orders_callback(self,orderfees, cjamount): @@ -666,10 +667,10 @@ class JMWalletDaemon(Service): print_req(request) self.check_cookie(request) if not self.services["wallet"]: - jlog.warn("displaywallet called, but no wallet loaded") + jlog.warning("displaywallet called, but no wallet loaded") raise NoWalletFound() if not self.wallet_name == walletname: - jlog.warn("called displaywallet with wrong wallet") + jlog.warning("called displaywallet with wrong wallet") raise InvalidRequestFormat() else: walletinfo = await wallet_display( @@ -690,10 +691,10 @@ class JMWalletDaemon(Service): print_req(request) self.check_cookie(request) if not self.services["wallet"]: - jlog.warn("rescanblockchain called, but no wallet service active.") + jlog.warning("rescanblockchain called, but no wallet service active.") raise NoWalletFound() if not self.wallet_name == walletname: - jlog.warn("called rescanblockchain with wrong wallet") + jlog.warning("called rescanblockchain with wrong wallet") raise InvalidRequestFormat() else: self.services["wallet"].rescanblockchain(blockheight) @@ -706,10 +707,11 @@ class JMWalletDaemon(Service): print_req(request) self.check_cookie(request) if not self.services["wallet"]: - jlog.warn("getrescaninfo called, but no wallet service active.") + jlog.warning("getrescaninfo called, but no wallet" + " service active.") raise NoWalletFound() if not self.wallet_name == walletname: - jlog.warn("called getrescaninfo with wrong wallet") + jlog.warning("called getrescaninfo with wrong wallet") raise InvalidRequestFormat() else: rescanning, progress = \ @@ -964,7 +966,8 @@ class JMWalletDaemon(Service): yigen_data = f.readlines() return yigen_data except Exception as e: - jlog.warn("Yigen report failed to find file: {}".format(repr(e))) + jlog.warning("Yigen report failed to find" + " file: {}".format(repr(e))) raise YieldGeneratorDataUnreadable() @app.route('/wallet/yieldgen/report', methods=['GET']) @@ -988,7 +991,7 @@ class JMWalletDaemon(Service): if self.services["wallet"] and not self.wallet_name == walletname: raise InvalidRequestFormat() if not self.services["wallet"]: - jlog.warn("Called lock, but no wallet loaded") + jlog.warning("Called lock, but no wallet loaded") # we could raise NoWalletFound here, but is # easier for clients if they can gracefully call # lock multiple times: diff --git a/src/jmclient/wallet_service.py b/src/jmclient/wallet_service.py index c6e6610..5810704 100644 --- a/src/jmclient/wallet_service.py +++ b/src/jmclient/wallet_service.py @@ -132,8 +132,8 @@ class WalletService(Service): assert isinstance(self.current_blockheight, Integral) assert self.current_blockheight >= 0 if self.current_blockheight < old_blockheight: - jlog.warn("Bitcoin Core is reporting a lower blockheight, " - "possibly a reorg.") + jlog.warning("Bitcoin Core is reporting a lower blockheight, " + "possibly a reorg.") return True def startService(self): diff --git a/src/jmclient/websocketserver.py b/src/jmclient/websocketserver.py index f160487..575cf73 100644 --- a/src/jmclient/websocketserver.py +++ b/src/jmclient/websocketserver.py @@ -20,8 +20,8 @@ class JmwalletdWebSocketServerProtocol(WebSocketServerProtocol): if not self.active_session: # not sending any data if the session is # not active, i.e. client hasn't authenticated. - jlog.warn("Websocket not sending notification, " - "the session is not active.") + jlog.warning("Websocket not sending notification, " + "the session is not active.") return self.sendMessage(json.dumps(info).encode()) diff --git a/src/jmdaemon/irc.py b/src/jmdaemon/irc.py index 7b090f3..f00c34c 100644 --- a/src/jmdaemon/irc.py +++ b/src/jmdaemon/irc.py @@ -26,7 +26,7 @@ def wlog(*x): if x[0] == "WARNING": msg = " ".join([conv(a) for a in x[1:]]) - log.warn(msg) + log.warning(msg) elif x[0] == "INFO": msg = " ".join([conv(a) for a in x[1:]]) log.info(msg) diff --git a/src/jmdaemon/message_channel.py b/src/jmdaemon/message_channel.py index 11a2d8a..6212e8e 100644 --- a/src/jmdaemon/message_channel.py +++ b/src/jmdaemon/message_channel.py @@ -82,8 +82,8 @@ class MessageChannelCollection(object): #but should not kill the bot. So, we don't raise an #exception, but rather allow sending to continue, which #should usually result in tx completion just timing out. - log.warn("Couldn't find a route to send privmsg") - log.warn("For counterparty: " + str(cp)) + log.warning("Couldn't find a route to send privmsg") + log.warning("For counterparty: " + str(cp)) return func_wrapper @@ -651,8 +651,8 @@ class MessageChannelCollection(object): """ matched_channels = [x for x in self.mchannels if hostid == x.hostid] if len(matched_channels) != 1: - log.warn("Channel on which privmsg was received is now inactive; " - "continuing to process this message") + log.warning("Channel on which privmsg was received is now" + " inactive; continuing to process this message") mc = matched_channels[0] mc.on_verified_privmsg(nick, message) diff --git a/src/jmdaemon/onionmc.py b/src/jmdaemon/onionmc.py index ca5110d..176ea57 100644 --- a/src/jmdaemon/onionmc.py +++ b/src/jmdaemon/onionmc.py @@ -206,14 +206,15 @@ class OnionLineProtocolFactory(protocol.ServerFactory): peer_location = network_addr_to_string(p.transport.getPeer()) self.client.register_disconnection(peer_location) if peer_location not in self.peers: - log.warn("Disconnection event registered for non-existent peer.") + log.warning("Disconnection event registered for" + " non-existent peer.") return del self.peers[peer_location] def disconnect_inbound_peer(self, inbound_peer_str: str) -> None: if inbound_peer_str not in self.peers: - log.warn("cannot disconnect peer at {}, not found".format( - inbound_peer_str)) + log.warning("cannot disconnect peer at {}, not" + " found".format(inbound_peer_str)) proto = self.peers[inbound_peer_str] proto.transport.loseConnection() @@ -224,8 +225,9 @@ class OnionLineProtocolFactory(protocol.ServerFactory): def send(self, message: OnionCustomMessage, destination: str) -> bool: if destination not in self.peers: - log.warn("sending message {}, destination {} was not in peers {}".format( - message.encode(), destination, self.peers)) + log.warning( + "sending message {}, destination {} was not in peers" + " {}".format(message.encode(), destination, self.peers)) return False proto = self.peers[destination] proto.message(message) @@ -479,8 +481,9 @@ class OnionPeer(object): code; no action is triggered. """ name = "directory" if self.directory else "peer" - log.warn("Failure to send message to {}: {}.".format( - name, self.peer_location())) + log.warning( + "Failure to send message to" + " {}: {}.".format(name, self.peer_location())) def connect(self) -> None: """ This method is called to connect, over Tor, to the remote @@ -553,8 +556,8 @@ class OnionPeer(object): # TODO remove message or change it. log.debug("Tried to connect but failed: {}".format(repr(e))) except Exception as e: - log.warn("Got unexpected exception in connect attempt: {}".format( - repr(e))) + log.warning("Got unexpected exception in connect" + " attempt: {}".format(repr(e))) def disconnect(self) -> None: if self._status in [PEER_STATUS_UNCONNECTED, PEER_STATUS_DISCONNECTED]: @@ -824,8 +827,8 @@ class OnionMessageChannel(MessageChannel): try: peer_sendable = self.get_directory_for_nick(nick) except OnionDirectoryPeerNotFound: - log.warn("Failed to send privmsg because no " - "directory peer is connected.") + log.warning("Failed to send privmsg because no " + "directory peer is connected.") return self._send(peer_sendable, encoded_privmsg) @@ -946,8 +949,8 @@ class OnionMessageChannel(MessageChannel): except Exception as e: # This can happen when a peer disconnects, depending # on the timing: - log.warn("Failed to send message to: {}, error: {}".format( - peer.peer_location(), repr(e))) + log.warning("Failed to send message to: {}, error:" + " {}".format(peer.peer_location(), repr(e))) return False def receive_msg(self, message: OnionCustomMessage, peer_location: str) -> None: @@ -961,7 +964,8 @@ class OnionMessageChannel(MessageChannel): log.debug("received message as directory: {}".format(message.encode())) peer = self.get_peer_by_id(peer_location) if not peer: - log.warn("Received message but could not find peer: {}".format(peer_location)) + log.warning("Received message but could not find peer:" + " {}".format(peer_location)) return msgtype = message.msgtype msgval = message.text @@ -1153,7 +1157,8 @@ class OnionMessageChannel(MessageChannel): # returning True whether raised or not - see docstring return True elif msgtype == CONTROL_MESSAGE_TYPES["getpeerlist"]: - log.warn("getpeerlist request received, currently not supported.") + log.warning("getpeerlist request received, currently" + " not supported.") return True elif msgtype == CONTROL_MESSAGE_TYPES["handshake"]: # sent by non-directory peers on startup, also to @@ -1202,15 +1207,15 @@ class OnionMessageChannel(MessageChannel): peer = self.get_peer_by_id(peerid) if not peer: # rando sent us a handshake? - log.warn("Unexpected handshake from unknown peer: {}, " - "ignoring.".format(peerid)) + log.warning("Unexpected handshake from unknown peer: {}, " + "ignoring.".format(peerid)) return assert isinstance(peer, OnionPeer) if not peer.status() == PEER_STATUS_CONNECTED: # we were not waiting for it: - log.warn("Unexpected handshake from peer: {}, " - "ignoring. Peer's current status is: {}".format( - peerid, peer.status())) + log.warning( + "Unexpected handshake from peer: {}, ignoring. Peer's current" + " status is: {}".format(peerid, peer.status())) return if dn: # it means, we are a non-dn and we are expecting @@ -1219,8 +1224,8 @@ class OnionMessageChannel(MessageChannel): assert not self.self_as_peer.directory if not peer.directory: # got dn-handshake from non-dn: - log.warn("Unexpected dn-handshake from non-dn " - "node: {}, ignoring.".format(peerid)) + log.warning("Unexpected dn-handshake from non-dn " + "node: {}, ignoring.".format(peerid)) return # we got the right message from the right peer; # check it is formatted correctly and represents @@ -1241,28 +1246,29 @@ class OnionMessageChannel(MessageChannel): assert isinstance(nick, str) assert isinstance(net, str) except Exception as e: - log.warn("Invalid handshake message from: {}," - " exception: {}, message: {},ignoring".format( - peerid, repr(e), message)) + log.warning( + "Invalid handshake message from: {}, exception: {}," + " message: {},ignoring".format(peerid, repr(e), message)) return # currently we are not using any features, but the intention # is forwards compatibility, so we don't check its contents # at all. if not accepted: - log.warn("Directory: {} rejected our handshake.".format(peerid)) + log.warning("Directory: {} rejected our " + "handshake.".format(peerid)) # explicitly choose to disconnect (if other side already did, # this is no-op). peer.disconnect() return if not (app_name == JM_APP_NAME and is_directory and JM_VERSION \ <= proto_max and JM_VERSION >= proto_min and accepted): - log.warn("Handshake from directory is incompatible or " - "rejected: {}".format(handshake_json)) + log.warning("Handshake from directory is incompatible or " + "rejected: {}".format(handshake_json)) peer.disconnect() return if not net == self.btc_network: - log.warn("Handshake from directory is on an incompatible " - "network: {}".format(net)) + log.warning("Handshake from directory is on an incompatible " + "network: {}".format(net)) return # We received a valid, accepting dn-handshake. Update the peer. peer.update_status(PEER_STATUS_HANDSHAKED) @@ -1287,19 +1293,21 @@ class OnionMessageChannel(MessageChannel): assert isinstance(nick, str) assert isinstance(net, str) except Exception as e: - log.warn("(not dn) Invalid handshake message from: {}, " - "exception: {}, message: {}, ignoring".format( - peerid, repr(e), message)) + log.warning( + "(not dn) Invalid handshake message from:" + " {}, exception: {}, message: {}," + " ignoring".format(peerid, repr(e), message)) # just ignore, since a syntax failure could lead to a crash return if not (app_name == JM_APP_NAME and proto_ver == JM_VERSION \ and not is_directory): - log.warn("Invalid handshake name/version data: {}, from peer: " - "{}, rejecting.".format(message, peerid)) + log.warning( + "Invalid handshake name/version data: {}," + " from peer: {}, rejecting.".format(message, peerid)) accepted = False if not net == self.btc_network: - log.warn("Handshake from peer is on an incompatible " - "network: {}".format(net)) + log.warning("Handshake from peer is on an incompatible " + "network: {}".format(net)) accepted = False # If accepted, we should update the peer to have the full # location which in general will not yet be present, so as to @@ -1398,7 +1406,8 @@ class OnionMessageChannel(MessageChannel): # There are currently a few ways the location # parsing and Peer object construction can fail; # TODO specify exception types. - log.warn("Failed to add peer: {}, exception: {}".format(peer, repr(e))) + log.warning("Failed to add peer: {}, exception:" + " {}".format(peer, repr(e))) return if not self.get_peer_by_id(temp_p.peer_location()): self.peers.add(temp_p)