fix: Lint to follow ruff standards
Some checks failed
Build Docker / Build Images (map[dockerfile:Dockerfile tag_suffix: target:default]) (push) Successful in 45s
Build Docker / Build Images (map[dockerfile:Dockerfile.hsd tag_suffix:-hsd target:hsd]) (push) Successful in 44s
Test Python Compatibility / Python-Compatibility (3.11) (push) Failing after 22s
Test Python Compatibility / Python-Compatibility (3.13) (push) Failing after 22s
Test Python Compatibility / Python-Compatibility (3.10) (push) Failing after 1m37s

This commit is contained in:
2025-09-02 15:55:45 +10:00
parent 997828795a
commit e7b787c30b
3 changed files with 46 additions and 44 deletions

72
main.py
View File

@@ -112,7 +112,7 @@ def transactions():
page = request.args.get('page', 1) page = request.args.get('page', 1)
try: try:
page = int(page) page = int(page)
except: except ValueError:
page = 1 page = 1
if page < 1: if page < 1:
@@ -209,7 +209,7 @@ def sendConfirmed():
address = request.args.get("address") address = request.args.get("address")
amount = float(request.args.get("amount","0")) amount = float(request.args.get("amount","0"))
response = account_module.send(request.cookies.get("account"),address,amount) response = account_module.send(request.cookies.get("account"),address,amount)
if 'error' in response and response['error'] != None: if 'error' in response and response['error'] is not None:
# If error is a dict get the message # If error is a dict get the message
if isinstance(response['error'], dict): if isinstance(response['error'], dict):
if 'message' in response['error']: if 'message' in response['error']:
@@ -280,7 +280,7 @@ def auctions():
# Sort # Sort
sort = request.args.get("sort") sort = request.args.get("sort")
if sort == None: if sort is None:
sort = "time" sort = "time"
sort = sort.lower() sort = sort.lower()
sort_price = "" sort_price = ""
@@ -294,7 +294,7 @@ def auctions():
reverse = False reverse = False
direction = request.args.get("direction") direction = request.args.get("direction")
if direction == None: if direction is None:
if sort == "time": if sort == "time":
direction = "" direction = ""
else: else:
@@ -363,7 +363,7 @@ def revealAllBids():
return redirect("/auctions?message=Failed to reveal bids") return redirect("/auctions?message=Failed to reveal bids")
if 'error' in response: if 'error' in response:
if response['error'] != None: if response['error'] is not None:
if response['error']['message'] == "Nothing to do.": if response['error']['message'] == "Nothing to do.":
return redirect("/auctions?message=No reveals pending") return redirect("/auctions?message=No reveals pending")
return redirect("/auctions?message=" + response['error']['message']) return redirect("/auctions?message=" + response['error']['message'])
@@ -386,7 +386,7 @@ def redeemAllBids():
return redirect("/auctions?message=Failed to redeem bids") return redirect("/auctions?message=Failed to redeem bids")
if 'error' in response: if 'error' in response:
if response['error'] != None: if response['error'] is not None:
if response['error']['message'] == "Nothing to do.": if response['error']['message'] == "Nothing to do.":
return redirect("/auctions?message=No redeems pending") return redirect("/auctions?message=No redeems pending")
return redirect("/auctions?message=" + response['error']['message']) return redirect("/auctions?message=" + response['error']['message'])
@@ -408,7 +408,7 @@ def registerAllDomains():
return redirect("/auctions?message=Failed to register domains") return redirect("/auctions?message=Failed to register domains")
if 'error' in response: if 'error' in response:
if response['error'] != None: if response['error'] is not None:
if response['error']['message'] == "Nothing to do.": if response['error']['message'] == "Nothing to do.":
return redirect("/auctions?message=No domains to register") return redirect("/auctions?message=No domains to register")
return redirect("/auctions?message=" + response['error']['message']) return redirect("/auctions?message=" + response['error']['message'])
@@ -427,7 +427,7 @@ def finalizeAllBids():
response = account_module.finalizeAll(request.cookies.get("account")) response = account_module.finalizeAll(request.cookies.get("account"))
if 'error' in response: if 'error' in response:
if response['error'] != None: if response['error'] is not None:
if response['error']['message'] == "Nothing to do.": if response['error']['message'] == "Nothing to do.":
return redirect("/dashboard?message=No domains to finalize") return redirect("/dashboard?message=No domains to finalize")
return redirect("/dashboard?message=" + response['error']['message']) return redirect("/dashboard?message=" + response['error']['message'])
@@ -505,7 +505,6 @@ def search():
domain_info = account_module.getDomain(search_term) domain_info = account_module.getDomain(search_term)
owner = 'Unknown' owner = 'Unknown'
dns = [] dns = []
txs = []
if domain_info: if domain_info:
# Check if info and info.owner # Check if info and info.owner
@@ -558,10 +557,10 @@ def manage(domain: str):
dns = render.dns(dns) dns = render.dns(dns)
errorMessage = request.args.get("error") errorMessage = request.args.get("error")
if errorMessage == None: if errorMessage is None:
errorMessage = "" errorMessage = ""
address = request.args.get("address") address = request.args.get("address")
if address == None: if address is None:
address = "" address = ""
finalize_time = "" finalize_time = ""
@@ -605,7 +604,7 @@ def finalize(domain: str):
domain = domain.lower() domain = domain.lower()
response = account_module.finalize(request.cookies.get("account"),domain) response = account_module.finalize(request.cookies.get("account"),domain)
if response['error'] != None: if response['error'] is not None:
print(response) print(response)
return redirect("/manage/" + domain + "?error=" + response['error']['message']) return redirect("/manage/" + domain + "?error=" + response['error']['message'])
@@ -624,7 +623,7 @@ def cancelTransfer(domain: str):
domain = domain.lower() domain = domain.lower()
response = account_module.cancelTransfer(request.cookies.get("account"),domain) response = account_module.cancelTransfer(request.cookies.get("account"),domain)
if 'error' in response: if 'error' in response:
if response['error'] != None: if response['error'] is not None:
print(response) print(response)
return redirect("/manage/" + domain + "?error=" + response['error']['message']) return redirect("/manage/" + domain + "?error=" + response['error']['message'])
@@ -674,13 +673,13 @@ def revokeConfirm(domain: str):
return redirect("/manage/" + domain + "?error=An error occurred. Please try again.") return redirect("/manage/" + domain + "?error=An error occurred. Please try again.")
response = account_module.check_password(request.cookies.get("account"),password) response = account_module.check_password(request.cookies.get("account"),password)
if response == False: if not response:
return redirect("/manage/" + domain + "?error=Invalid password") return redirect("/manage/" + domain + "?error=Invalid password")
response = account_module.revoke(request.cookies.get("account"),domain) response = account_module.revoke(request.cookies.get("account"),domain)
if 'error' in response: if 'error' in response:
if response['error'] != None: if response['error'] is not None:
print(response) print(response)
return redirect("/manage/" + domain + "?error=" + response['error']['message']) return redirect("/manage/" + domain + "?error=" + response['error']['message'])
@@ -720,7 +719,7 @@ def editPage(domain: str):
user_edits = request.args.get("dns") user_edits = request.args.get("dns")
if user_edits != None: if user_edits is not None:
dns = urllib.parse.unquote(user_edits) dns = urllib.parse.unquote(user_edits)
else: else:
dns = account_module.getDNS(domain) dns = account_module.getDNS(domain)
@@ -733,7 +732,7 @@ def editPage(domain: str):
# Check if new records have been added # Check if new records have been added
dnsType = request.args.get("type") dnsType = request.args.get("type")
dnsValue = request.args.get("value") dnsValue = request.args.get("value")
if dnsType != None and dnsValue != None: if dnsType is not None and dnsValue is not None:
if dnsType != "DS": if dnsType != "DS":
dns.append({"type": dnsType, "value": dnsValue}) dns.append({"type": dnsType, "value": dnsValue})
else: else:
@@ -747,7 +746,7 @@ def editPage(domain: str):
key_tag = int(ds[0]) key_tag = int(ds[0])
algorithm = int(ds[1]) algorithm = int(ds[1])
digest_type = int(ds[2]) digest_type = int(ds[2])
except: except ValueError:
raw_dns = str(dns).replace("'",'"') raw_dns = str(dns).replace("'",'"')
return redirect("/manage/" + domain + "/edit?dns=" + urllib.parse.quote(str(raw_dns)) + "&error=Invalid DS record") return redirect("/manage/" + domain + "/edit?dns=" + urllib.parse.quote(str(raw_dns)) + "&error=Invalid DS record")
@@ -759,7 +758,7 @@ def editPage(domain: str):
raw_dns = str(dns).replace("'",'"') raw_dns = str(dns).replace("'",'"')
dns = render.dns(dns,True) dns = render.dns(dns,True)
errorMessage = request.args.get("error") errorMessage = request.args.get("error")
if errorMessage == None: if errorMessage is None:
errorMessage = "" errorMessage = ""
@@ -845,7 +844,7 @@ def signMessage(domain):
content = "Message to sign:<br><code>" + message + "</code><br><br>" content = "Message to sign:<br><code>" + message + "</code><br><br>"
signedMessage = account_module.signMessage(request.cookies.get("account"),domain,message) signedMessage = account_module.signMessage(request.cookies.get("account"),domain,message)
if signedMessage["error"] != None: if signedMessage["error"] is not None:
return redirect("/manage/" + domain + "?error=" + signedMessage["error"]) return redirect("/manage/" + domain + "?error=" + signedMessage["error"])
content += f"Signature:<br><code>{signedMessage['result']}</code><br><br>" content += f"Signature:<br><code>{signedMessage['result']}</code><br><br>"
@@ -904,7 +903,7 @@ def auction(domain):
domainInfo = account_module.getDomain(search_term) domainInfo = account_module.getDomain(search_term)
error = request.args.get("error") error = request.args.get("error")
if error == None: if error is None:
error = "" error = ""
if 'error' in domainInfo: if 'error' in domainInfo:
@@ -914,7 +913,7 @@ def auction(domain):
error=error) error=error)
if domainInfo['info'] is None: if domainInfo['info'] is None:
if 'registered' in domainInfo and domainInfo['registered'] == False and 'expired' in domainInfo and domainInfo['expired'] == False: if 'registered' in domainInfo and not domainInfo['registered'] and 'expired' in domainInfo and not domainInfo['expired']:
# Needs to be registered # Needs to be registered
next_action = 'ERROR GETTING NEXT STATE' next_action = 'ERROR GETTING NEXT STATE'
else: else:
@@ -995,7 +994,7 @@ def rescan_auction(domain):
domain = domain.lower() domain = domain.lower()
response = account_module.rescan_auction(account,domain) account_module.rescan_auction(account,domain)
return redirect("/auction/" + domain) return redirect("/auction/" + domain)
@app.route('/auction/<domain>/bid') @app.route('/auction/<domain>/bid')
@@ -1091,7 +1090,7 @@ def open_auction(domain):
response = account_module.openAuction(request.cookies.get("account"),domain) response = account_module.openAuction(request.cookies.get("account"),domain)
if 'error' in response: if 'error' in response:
if response['error'] != None: if response['error'] is not None:
return redirect("/auction/" + domain + "?error=" + response['error']['message']) return redirect("/auction/" + domain + "?error=" + response['error']['message'])
return redirect(f"/success?tx={response['hash']}") return redirect(f"/success?tx={response['hash']}")
@@ -1140,10 +1139,10 @@ def settings():
return redirect("/logout") return redirect("/logout")
error = request.args.get("error") error = request.args.get("error")
if error == None: if error is None:
error = "" error = ""
success = request.args.get("success") success = request.args.get("success")
if success == None: if success is None:
success = "" success = ""
@@ -1202,7 +1201,7 @@ def settings_action(action):
if action == "zap": if action == "zap":
resp = account_module.zapTXs(request.cookies.get("account")) resp = account_module.zapTXs(request.cookies.get("account"))
if type(resp) == dict and 'error' in resp: if type(resp) is dict and 'error' in resp:
return redirect("/settings?error=" + str(resp['error'])) return redirect("/settings?error=" + str(resp['error']))
return redirect("/settings?success=Zapped transactions") return redirect("/settings?success=Zapped transactions")
@@ -1288,7 +1287,7 @@ def login_post():
account = request.form.get("account") account = request.form.get("account")
password = request.form.get("password") password = request.form.get("password")
if account == None or password == None: if account is None or password is None:
wallets = account_module.listWallets() wallets = account_module.listWallets()
wallets = render.wallets(wallets) wallets = render.wallets(wallets)
return render_template("login.html", return render_template("login.html",
@@ -1327,7 +1326,7 @@ def register():
password = request.form.get("password") password = request.form.get("password")
repeatPassword = request.form.get("password_repeat") repeatPassword = request.form.get("password_repeat")
if account == None or password == None or repeatPassword == None: if account is None or password is None or repeatPassword is None:
return render_template("register.html", return render_template("register.html",
error="Invalid account or password", error="Invalid account or password",
name=account,password=password,password_repeat=repeatPassword) name=account,password=password,password_repeat=repeatPassword)
@@ -1374,7 +1373,7 @@ def import_wallet():
repeatPassword = request.form.get("password_repeat") repeatPassword = request.form.get("password_repeat")
seed = request.form.get("seed") seed = request.form.get("seed")
if account == None or password == None or repeatPassword == None or seed == None: if account is None or password is None or repeatPassword is None or seed is None:
return render_template("import-wallet.html", return render_template("import-wallet.html",
error="Invalid account, password or seed", error="Invalid account, password or seed",
name=account,password=password,password_repeat=repeatPassword, name=account,password=password,password_repeat=repeatPassword,
@@ -1473,12 +1472,12 @@ def plugin(ptype,plugin):
functions = plugins_module.getPluginFunctions(plugin) functions = plugins_module.getPluginFunctions(plugin)
functions = render.plugin_functions(functions,plugin) functions = render.plugin_functions(functions,plugin)
if data['verified'] == False: if not data['verified']:
functions = "<div class='container-fluid'><div class='alert alert-warning' role='alert'>This plugin is not verified and is disabled for your protection. Please check the code before marking the plugin as verified <a href='/plugin/" + plugin + "/verify' class='btn btn-danger'>Verify</a></div></div>" + functions functions = "<div class='container-fluid'><div class='alert alert-warning' role='alert'>This plugin is not verified and is disabled for your protection. Please check the code before marking the plugin as verified <a href='/plugin/" + plugin + "/verify' class='btn btn-danger'>Verify</a></div></div>" + functions
error = request.args.get("error") error = request.args.get("error")
if error == None: if error is None:
error = "" error = ""
return render_template("plugin.html", account=account, return render_template("plugin.html", account=account,
@@ -1504,7 +1503,7 @@ def plugin_verify(ptype,plugin):
data = plugins_module.getPluginData(plugin) data = plugins_module.getPluginData(plugin)
if data['verified'] == False: if not data['verified']:
plugins_module.verifyPlugin(plugin) plugins_module.verifyPlugin(plugin)
return redirect("/plugin/" + plugin) return redirect("/plugin/" + plugin)
@@ -1591,7 +1590,7 @@ def api_hsd(function):
if not domain: if not domain:
return jsonify({"error": "No domain specified"}), 400 return jsonify({"error": "No domain specified"}), 400
domainInfo = account_module.getDomain(domain) domainInfo = account_module.getDomain(domain)
if 'error' in domainInfo and domainInfo['error'] != None: if 'error' in domainInfo and domainInfo['error'] is not None:
return jsonify({"error": domainInfo['error']}), 400 return jsonify({"error": domainInfo['error']}), 400
stats = domainInfo['info']['stats'] if 'stats' in domainInfo['info'] else {} stats = domainInfo['info']['stats'] if 'stats' in domainInfo['info'] else {}
state = domainInfo['info']['state'] state = domainInfo['info']['state']
@@ -1712,7 +1711,7 @@ def api_wallet(function):
if function == "domains": if function == "domains":
domains = account_module.getDomains(account) domains = account_module.getDomains(account)
if type(domains) == dict and 'error' in domains: if type(domains) is dict and 'error' in domains:
return jsonify({"result": [], "error": domains['error']}) return jsonify({"result": [], "error": domains['error']})
# Add nameRender to each domain # Add nameRender to each domain
@@ -1726,7 +1725,7 @@ def api_wallet(function):
page = request.args.get('page', 1) page = request.args.get('page', 1)
try: try:
page = int(page) page = int(page)
except: except ValueError:
page = 1 page = 1
if page < 1: if page < 1:
@@ -1799,7 +1798,6 @@ def api_wallet_mobile(function):
return jsonify({"error": "Not logged in"}) return jsonify({"error": "Not logged in"})
account = account_module.check_account(request.cookies.get("account")) account = account_module.check_account(request.cookies.get("account"))
password = request.cookies.get("account","").split(":")[1]
if not account: if not account:
return jsonify({"error": "Invalid account"}) return jsonify({"error": "Invalid account"})

View File

@@ -62,7 +62,8 @@ def listPlugins(update=False):
try: try:
with open("user_data/plugin_signatures.json", "r") as f: with open("user_data/plugin_signatures.json", "r") as f:
signatures = json.load(f) signatures = json.load(f)
except: except Exception as e:
print(f"Error loading plugin signatures: {e}")
# Write a new signatures file # Write a new signatures file
with open("user_data/plugin_signatures.json", "w") as f: with open("user_data/plugin_signatures.json", "w") as f:
json.dump(signatures, f) json.dump(signatures, f)
@@ -87,7 +88,8 @@ def verifyPlugin(plugin: str):
try: try:
with open("user_data/plugin_signatures.json", "r") as f: with open("user_data/plugin_signatures.json", "r") as f:
signatures = json.load(f) signatures = json.load(f)
except: except Exception as e:
print(f"Error loading plugin signatures: {e}")
# Write a new signatures file # Write a new signatures file
with open("user_data/plugin_signatures.json", "w") as f: with open("user_data/plugin_signatures.json", "w") as f:
json.dump(signatures, f) json.dump(signatures, f)
@@ -120,7 +122,8 @@ def getPluginData(pluginStr: str):
try: try:
with open("user_data/plugin_signatures.json", "r") as f: with open("user_data/plugin_signatures.json", "r") as f:
signatures = json.load(f) signatures = json.load(f)
except: except Exception as e:
print(f"Error loading plugin signatures: {e}")
# Write a new signatures file # Write a new signatures file
with open("user_data/plugin_signatures.json", "w") as f: with open("user_data/plugin_signatures.json", "w") as f:
json.dump(signatures, f) json.dump(signatures, f)
@@ -171,7 +174,8 @@ def runPluginFunction(plugin: str, function: str, params: dict, authentication:
try: try:
with open("user_data/plugin_signatures.json", "r") as f: with open("user_data/plugin_signatures.json", "r") as f:
signatures = json.load(f) signatures = json.load(f)
except: except Exception as e:
print(f"Error loading plugin signatures: {e}")
# Write a new signatures file # Write a new signatures file
with open("user_data/plugin_signatures.json", "w") as f: with open("user_data/plugin_signatures.json", "w") as f:
json.dump(signatures, f) json.dump(signatures, f)

View File

@@ -53,7 +53,7 @@ def domains(domains, mobile=False):
link = f'/manage/{domain["name"]}' link = f'/manage/{domain["name"]}'
link_action = "Manage" link_action = "Manage"
if domain['registered'] == False: if not domain['registered']:
link_action = "Register" link_action = "Register"
link = f'/auction/{domain["name"]}/register' link = f'/auction/{domain["name"]}/register'
@@ -251,7 +251,7 @@ def txs(data):
amount = entry['amount'] amount = entry['amount']
amount = amount / 1000000 amount = amount / 1000000
if entry['blind'] == None: if entry['blind'] is None:
html_output += f"<td>{amount:,.2f} HNS</td>\n" html_output += f"<td>{amount:,.2f} HNS</td>\n"
else: else:
blind = entry['blind'] blind = entry['blind']
@@ -496,7 +496,7 @@ def plugin_output_dash(outputs, returns):
for returnOutput in returns: for returnOutput in returns:
if returnOutput not in outputs: if returnOutput not in outputs:
continue continue
if outputs[returnOutput] == None: if outputs[returnOutput] is None:
continue continue
html += render_template('components/dashboard-plugin.html', name=returns[returnOutput]["name"], output=outputs[returnOutput]) html += render_template('components/dashboard-plugin.html', name=returns[returnOutput]["name"], output=outputs[returnOutput])
return html return html