Open jmartens opened 1 year ago
The problem occurs because of the fact that when no default is set there is some special construction done to generate the default path as can be observed at https://github.com/deductiv/kvstore_tools/blob/master/bin/kvstore_backup.py#L119-L125
On Windows this results in the following due to not evaluating the value of $SPLUNK_BASE
:
>>> import os
>>> default_path = "$SPLUNK_HOME/etc/apps/kvstore_tools/backups".split("/")
>>> default_path
['$SPLUNK_HOME', 'etc', 'apps', 'kvstore_tools', 'backups']
>>> os.path.abspath(os.path.join(os.sep, *default_path))
'C:\\$SPLUNK_HOME\\etc\\apps\\kvstore_tools\\backups'
Suggested change is to wrap the default_path with os.path.expandvars
before splitting it :
>>> default_path = os.path.expandvars("$SPLUNK_HOME/etc/apps/kvstore_tools/backups").split("/")
>>> default_path
['C:\\Program Files\\Splunk', 'etc', 'apps', 'kvstore_tools', 'backups']
>>> os.path.abspath(os.path.join(os.sep, *default_path))
'C:\\Program Files\\Splunk\\etc\\apps\\kvstore_tools\\backups'
>>>
Perhaps it is even better not to do any massaging and just take the path verbatim from the configuration file.
I fail to see why the splitting and merging is done and I noticed the os.path.expandvars is done later on a more general code path at https://github.com/deductiv/kvstore_tools/blob/master/bin/kvstore_backup.py#L128
While using the default values from defaults/kvstore_config.conf
a default backup w/o parameters fails with the following error:
But it does work when manually specifying it as path parameter:
Contents of defaults/kvstore_config.
It seems some internal setting on windows fails to evaluate properly IMHO