Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update for hsds app arg processing #384

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions hsds/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,34 +262,40 @@ def main():
except OSError:
pass # ignore

# set username based on command line, .hscfg, or login user
if args.hs_username:
username = args.hs_username
elif "HS_USERNAME" in userConfig:
username = userConfig["HS_USERNAME"]
elif not args.password_file:
# no password file, add the login name as user
username = login_username
else:
username = None

# get password based on command line or .hscfg
if args.hs_password:
password = args.hs_password
elif "HS_PASSWORD" in userConfig:
password = userConfig["HS_PASSWORD"]
else:
password = login_username

if username:
kwargs["username"] = username
kwargs["password"] = password
username = None
password = None

# validate password_file arg if used
if args.password_file:
if not os.path.isfile(args.password_file):
sys.exit(f"password file: {args.password_file} not found")
kwargs["password_file"] = args.password_file

if args.hs_username:
sys.exit("username arg cannot be used if password_file is set")
if args.hs_password:
sys.exit("password arg cannot be used if password_file is set")
else:
if args.hs_username:
username = args.hs_username
elif "HS_USERNAME" in userConfig:
# can set username based on HS_USERNAME environment variable
username = userConfig["HS_USERNAME"]
else:
username = login_username

if args.hs_password:
password = args.hs_password
elif "HS_PASSWORD" in userConfig:
# can set password based on HS_PASSWORD environment variable
password = userConfig["HS_PASSWORD"]
else:
password = login_username

if username and password:
kwargs["username"] = username
kwargs["password"] = password

# use unix domain socket if a socket dir is set
if args.socket_dir:
socket_dir = os.path.abspath(args.socket_dir)
Expand Down
Loading