waikato-ufdl / ufdl-python-client

Core Python library for accessing the UFDL backend, managing the communication.
Apache License 2.0
0 stars 0 forks source link

mkdir of $HOME/.config/ufdl fails if $HOME/.config doesn't exist #7

Closed fracpete closed 4 years ago

fracpete commented 4 years ago

The python client fails to create the $HOME/.config/ufdl directory if $HOME/.config is not already present (eg when run on a server without graphical user interface), generating the following stacktrace:

Traceback (most recent call last):
  File "src/ufdl/joblauncher/blah.py", line 9, in <module>
    context = UFDLServerContext("127.0.0.1", 8000, config['backend']['user'], config['backend']['password'])
  File "/home/fracpete/projects/ufdl-job-launcher/venv/lib/python3.7/site-packages/ufdl/pythonclient/_UFDLServerContext.py", line 28, in __init__
    self._token_cache = token_cache if token_cache is not None else JSONTokenCache()
  File "/home/fracpete/projects/ufdl-job-launcher/venv/lib/python3.7/site-packages/ufdl/pythonclient/token_cache/json/_JSONTokenCache.py", line 19, in __init__
    filename = os.path.join(get_ufdl_config_dir(), "tokens.json")
  File "/home/fracpete/projects/ufdl-job-launcher/venv/lib/python3.7/site-packages/ufdl/pythonclient/util/_get_ufdl_config_dir.py", line 20, in get_ufdl_config_dir
    os.mkdir(ufdl_config_dir)
FileNotFoundError: [Errno 2] No such file or directory: '/home/fracpete/.config/ufdl'

Fix: create $HOME/.config if not present.

csterling commented 4 years ago

Implemented in commit 549026ca361ace82538ce87ace3fd3784ce08981

@fracpete can you please test?

fracpete commented 4 years ago

Works as expected now.