Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for quoted environment variables
Environment variables with spaces in them must be quoted, otherwise `make run` will report `command not found`: ``` $ grep DEYE_HA_PLUGIN_INVERTER_MODEL config.env DEYE_HA_PLUGIN_INVERTER_MODEL=SUN300G3 EU 230 $ make run config.env: line 49: EU: command not found 2024-06-10 21:13:44,180 - DeyeDaemon - INFO - Please help me build the list of compatible inverters. kbialek#41 2024-06-10 21:13:44,190 - DeyePluginLoader - INFO - Loading plugin: 'deye_plugin_ha_discovery' 2024-06-10 21:13:44,191 - DeyeConnectorFactory - INFO - Creating Modbus/TCP Logger connector [...] ``` With the quotation marks, the environment variables in Docker are slightly different: **Setup:** ``` $ grep DEYE_HA_PLUGIN_INVERTER_MODEL config.env DEYE_HA_PLUGIN_INVERTER_MODEL="SUN300G3 EU 230" ``` **Unix Shell and local Python** ``` $ strings /proc/<pid>/environ | grep DEYE_HA_PLUGIN_INVERTER_MODEL DEYE_HA_PLUGIN_INVERTER_MODEL=SUN300G3 EU 230 ``` **Docker** ``` $ strings /proc/<pid>/environ | grep DEYE_HA_PLUGIN_INVERTER_MODEL DEYE_HA_PLUGIN_INVERTER_MODEL="SUN300G3 EU 230" ``` This change addresses the different behavior of Docker compared to a Unix shell and removes single and double quotes only if they are the first and last character of the string. The functionality was added to `DeyeEnv.integer()` and `DeyeEnv.boolean()` for the sake of convenience to avoid problems with quotes that may occur later.
- Loading branch information