Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Commit

Permalink
BF: Handle non-existent configuration path
Browse files Browse the repository at this point in the history
When checking for available pump configurations pyqmix assumes that their default location is:
'C:/Users/Public/Documents/QmixElements/Projects/default_project/Configurations/'.

If this directory does not exist pyqmix will now raise an error.
  • Loading branch information
ArndalAndersen committed Apr 23, 2019
1 parent 839b638 commit acfd711
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 2019.1
------------------
* Handle non-existent configuration directory

Version 2018.12.13
------------------
* Update installation instructions
Expand Down
9 changes: 9 additions & 0 deletions pyqmix/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ def get_available_qmix_configs(configs_dir=None):
list of strings
Names of available Qmix configurations.
Raises
------
ValueError
If the configuration directory does not exist.
"""
if configs_dir is None:
configs_dir = DEFAULT_CONFIGS_DIR
Expand All @@ -100,6 +105,10 @@ def get_immediate_subdirectories(a_dir):
return [name for name in os.listdir(a_dir)
if os.path.isdir(os.path.join(a_dir, name))]

if not os.path.exists(configs_dir):
msg = 'The configuration directory does not exist: %s' % configs_dir
raise ValueError(msg)

return get_immediate_subdirectories(configs_dir)


Expand Down

0 comments on commit acfd711

Please sign in to comment.