labscript-suite / labscript-utils

Shared modules used by the 𝘭𝘒𝘣𝘴𝘀𝘳π˜ͺ𝘱𝘡 𝘴𝘢π˜ͺ𝘡𝘦. Includes a graphical exception handler, debug tools, configuration management, cross platform filepath conversions, unit conversions and custom GUI widgets.
http://labscriptsuite.org
Other
2 stars 45 forks source link

Remove labscript_suite from default config file #45

Closed chrisjbillington closed 4 years ago

chrisjbillington commented 4 years ago

But add it as a default option so that config files may continue to use it as an interpolation value.

Saving config files whenever a value is set breaks this, as it actually saves the default value to disk. Without adding a guard against it, it actually writes any provided default values to disk before loading the existing config file, actually wiping out the user's config completely.

So this commit removes the overridden methods that save back to disk.

No labscript code actually sets config values except for some code in the BLACS plugins __init__.py, which adds the list of available plugins. Not writing this back to disk is fine. If we ever make GUI interfaces for manipulating the config file, it is poor form to just overwrite the user's config file anyway, which may re-order sections and remove comments. For that we would want to use something like https://pypi.org/project/ConfigUpdater/.

Also simplify the code that gets the config path. There is only one place on disk for config paths now, and if it doesn't exist the user will get a FileNotFoundError with the full path, so I don't think there is a strong need to wrap that error in one written by us that basically says the same thing!

This change removes the hostname and config_prefix variables. These variables are imported (unused) by lyse and runviewer, so I will remove them from those projects. They are also imported and used by BLACS to construct its config filepath. I will modify BLACS to instead put its config file in the standard config file locations for apps.

Fixes #22

Edit: Above is a typo, actually fixes #35.