Hi Gaëtan,
As
you have probably read from the documentation Classad.quote() converts a python string into a classad string. A classad string is wrapped in double quotes. That is why the passed json '{"Hello":"World"}' converts to "{\"Hello\":\"World\"}" which cause your
failure after setting arguments to ' '.join(command[1:]). I believe arguments gets wrapped in double quotes making an invalid arguments string of "arg1 arg2 "{\"Hello\":\"World\"}"". I think if you did command[6] = Classad.quote(command[6]) and then convert
the first and last characters (the wrapping double quotes) to single quotes you should have a valid argument string.
Hope
this helps,
Cole
Bollig
From: HTCondor-users <htcondor-users-bounces@xxxxxxxxxxx> on behalf of Gaetan Geffroy <gage@xxxxxxxxx>
Sent: Friday, December 9, 2022 12:15 PM To: htcondor-users@xxxxxxxxxxx <htcondor-users@xxxxxxxxxxx> Subject: [HTCondor-users] Problems using classad.quote in the Python bindings I am trying to submit jobs using Python, and there is some JSON in the arguments. I am trying to use classad.quote to make these json strings understandable by Condor, but it does not look like it has the desired effect. Here is what I am doing:
job = { "executable": executable, # Executable "transfer_executable": False, # The executable is expected to be present in the docker image "arguments": arguments, # Arguments for the executable "universe": "docker", # Run job in Docker container "docker_image": docker_image, # Docker image to be used "environment": self.convert_envvars(), # Set the environment variables in container "should_transfer_files": "YES", # Enable file transfer "transfer_input_files": inputs, # Transfer files "output": self.stdout_filename, # File where the stdout of the container will be written "error": self.stderr_filename, # File where the stderr of the container will be written }
But then I get: ERROR:root:Condor Job Submission failed: Found illegal unescaped double-quote
After playing around a bit, it looks like the classad.quote function does not do what it is supposed to do: Isn’t it supposed to escape all “ characters and surround everything with ‘ ’ ?
Thanks,
Gaëtan Geffroy
Attention: |