%u is deprecated alias for %d since PEP 237 (2001)
diff --git a/blocky-client.py b/blocky-client.py index a189bca..7413ffe 100644 --- a/blocky-client.py +++ b/blocky-client.py
@@ -95,7 +95,7 @@ whiteblocks = [] if not (whitelist or banlist): return - print("Processing Blocky change-set (%u entries)" % (len(whitelist) + len(banlist))) + print("Processing Blocky change-set (%d entries)" % (len(whitelist) + len(banlist))) processed = 0 for ip in whitelist: if ip: @@ -129,14 +129,14 @@ if ip: processed += 1 if (processed % 500) == 0: - print("Processed %u entries..." % processed) + print("Processed %d entries..." % processed) banit = True block = None if '/' in ip: block = netaddr.IPNetwork(ip) # We never ban larger than a /8 on ipv4 and /56 on ipv6 if (block.version == 4 and block.size > (2 ** 24)) or (block.version == 6 and block.size > (2 ^ 72)): - print("%s was requested banned but the net block is too large (%u IPs)" % (block, block.size)) + print("%s was requested banned but the net block is too large (%d IPs)" % (block, block.size)) continue else: if ':' in ip: @@ -374,10 +374,10 @@ elif cmd == 'GOOD': if target == CONFIG['client']['hostname'] or target == '*': whitelist.append(ip) - print("[%u] Server disconnected, reconnecting in 30 seconds" % time.time()) + print("[%d] Server disconnected, reconnecting in 30 seconds" % time.time()) time.sleep(30) except Exception as e: - print("[%u] Connection failed (%s), reconnecting in 30 seconds" % (time.time(), e)) + print("[%d] Connection failed (%s), reconnecting in 30 seconds" % (time.time(), e)) time.sleep(30) @@ -400,7 +400,7 @@ pass # Set new epoch with open("epoch.dat", "w") as f: - f.write("%u" % time.time()) + f.write("%d" % time.time()) f.close() # Load YAML
diff --git a/blocky4-client.py b/blocky4-client.py index 5940735..ad4d7ef 100644 --- a/blocky4-client.py +++ b/blocky4-client.py
@@ -41,7 +41,7 @@ await chain.refresh() for rule in chain.items: rules_as_dict.append(rule.to_dict()) - # print("Uploading iptables list (%u entries) to Blocky server" % len(rules_as_dict)) + # print("Uploading iptables list (%d entries) to Blocky server" % len(rules_as_dict)) try: js = {"hostname": config["whoami"], "iptables": rules_as_dict} timeout = aiohttp.ClientTimeout(total=15) @@ -71,7 +71,7 @@ """Process allows and blocks""" allow_blocks = [] if allow or block: - print("Processing upstream change-set (%u entries)" % (len(allow) + len(block))) + print("Processing upstream change-set (%d entries)" % (len(allow) + len(block))) processed = 0 # First process any new allows if allow and chains: # If we have an INPUT default chain, refresh before unblock. @@ -103,7 +103,7 @@ if ip: processed += 1 if (processed % 500) == 0: - print("Processed %u entries..." % processed) + print("Processed %d entries..." % processed) # Only apply blocks if host is * or our specific name if entry.get('host', '*') not in [config['whoami'], '*']: continue @@ -114,7 +114,7 @@ if (as_block.version == 4 and as_block.size > MAX_BLOCK_SIZE_IPV4) or ( as_block.version == 6 and as_block.size > MAX_BLOCK_SIZE_IPV6 ): - print("%s was requested banned but the net block is too large (%u IPs)" % (as_block, as_block.size)) + print("%s was requested banned but the net block is too large (%d IPs)" % (as_block, as_block.size)) continue else: if ":" in ip: @@ -157,7 +157,7 @@ await process_changes(config, chains, allow=js["allow"], block=js["block"]) break except Exception as e: - print("[%u] Connection failed (%s: %s), reconnecting in 30 seconds" % (time.time(), type(e), e)) + print("[%d] Connection failed (%s: %s), reconnecting in 30 seconds" % (time.time(), type(e), e)) await asyncio.sleep(30) # Attach to pubsub and listen for new blocks/allows