Hi all,
i am struggling a bit, where my agent’s libexec script is receiving parameters in single quotes.
This breaks argparse’s evaluation of the parameters provided to the script.
I am offering the script a parameter --exclude=something,otherthing
When i do that everything works fine ( both direct and from agent-call).
However, when i try --exclude=something, otherthing
( observe space after comma!)
which i compensated for in my script with:
def parse_exclude_list(value):
# Split by comma, strip whitespace, remove empty items
return [item.strip() for item in value.split(',') if item.strip()]
And then using that in argparse:
parser.add_argument('--exclude', type=parse_exclude_list, help='Excluded section(s) comma separated (optional)')
With above, when calling the script from command-line works like a charm.
But when its called from CMK, it wraps single quotes around that part, not stripping the whitespaces.
Seen when running cmk -vvn Host:
'--exclude=something, otherthing'
So i’m looking for a way around/compensating for this in my code.
(apart from “dont use spaces in the argument ”
- Glowsome