error handling for missing hdf user/pass when uploading

This commit is contained in:
2025-10-15 13:20:51 -05:00
parent dc654d9613
commit ce98ec7f4e
2 changed files with 15 additions and 6 deletions

View File

@@ -112,7 +112,7 @@ OPTIONS=runmode:teleport
OPTIONS=quick_farsight
{% if commenst %}
{% if comments %}
# whatis_coord: coordinates to display when looking around the map with the whatis or farlook commands
# c: compass ('east' or '3s' or '2n,4w')
# f: full compass ('east' or '3south' or '2north,4west')
@@ -127,7 +127,8 @@ OPTIONS=whatis_coord:c
{% endif %}
OPTIONS=!implicit_uncursed
{% if base37 %}
{%- if base37 %}
{% if comments %}
# tutorial: play a tutorial level at the start of the game
{% endif %}
@@ -153,7 +154,8 @@ OPTIONS=cond_held,cond_ice,cond_lava,cond_woundedlegs,cond_slip
{% if comments %}
# paranoid_confirmation: space-separated list of specific situations where alternate prompting is desired
# Confirm: for any prompts which are set to require 'yes' rather than 'y', also require 'no' to reject instead of accepting any non-yes response as no
# Confirm: for any prompts which are set to require 'yes' rather than 'y',
# also require 'no' to reject instead of accepting any non-yes response as no
# quit: require 'yes' rather than 'y' to confirm quitting or switching into explore mode
# die: require 'yes' rather than 'y' to confirm dying in explore mode
# bones: require 'yes' rather than 'y' to confirm saving bones data on death in debug mode
@@ -172,6 +174,7 @@ OPTIONS=cond_held,cond_ice,cond_lava,cond_woundedlegs,cond_slip
{% endif %}
OPTIONS=paranoid_confirmation:pray Remove{{ " AutoAll trap swim" if base37 }}
{# block for additional options to keep main set of options together #}
{% block options %}
{% endblock options %}

View File

@@ -16,9 +16,15 @@ def upload(rcfile, variant):
s = requests.Session()
base_url = f"https://www.hardfought.org/nh/{variant}"
hdf_username = os.getenv("HDF_USERNAME")
hdf_password = os.getenv("HDF_PASSWORD")
if hdf_username is None or hdf_password is None or len(hdf_username) == 0 or len(hdf_password) == 0:
print("To upload config to hardfought you must specify HDF_USERNAME and HDF_PASSWORD in .env")
return False
login = s.post(f"{base_url}/login.php", {
"username": os.getenv("HDF_USERNAME"),
"password": os.getenv("HDF_PASSWORD"),
"username": hdf_username,
"password": hdf_password,
"submit": "Login",
})
@@ -64,7 +70,7 @@ if __name__ == "__main__":
render_params = vars(args).copy()
jnh = os.getenv("JNH_USERNAME")
if jnh != None and len(jnh) > 0:
if jnh is not None and len(jnh) > 0:
render_params['jnh_username'] = jnh
rcfile = render(args.template, render_params)