Hi Todd,many thanks - that looks much more nifty than my impromptu serialization with a lambda for ensuring strings ;)
Cheers, Thomas On 14/09/2022 19.46, Todd L Miller via HTCondor-users wrote:
afais a classad object can not be easily flatten/serialized into a htchirp compatible string. For python dicts flatten()/printJson/printOld/... return strings in different formattings or fail.ÂÂÂÂI would only expect the str() method to work, but it doesn't because we included newlines in the output. Thus:#!/usr/bin/python3 import classad import htcondor.htchirp ad = classad.ClassAd({"key1": "value1", 'key2':'value2'}) with htcondor.htchirp.HTChirp() as chirp:  chirp.connect()  chirp_str = str(ad).replace('\n', '')  chirp.set_job_attr("TestAttr", chirp_str)  chirp.disconnect()btw: can python list be cast into classads? I tried something like [2] but failed. Max suggested to use enumerate for Lua-like lists with keys as consecutive numbers, but one would need to explicitly cast the int indices into strings in a second step.ÂÂÂÂThe following is awful but does seem to work: pylist = ["foo", "bar", "baz"] listdic = {"entry": pylist} listad = classad.ClassAd(listdic) classadlist = listad["entry"] I suspect there isn't a good reason why clasadlist = classad.ClassAd(pylist) and classadlist = classad.Literal(pylist) don't work. -- ToddM _______________________________________________ HTCondor-users mailing list To unsubscribe, send a message to htcondor-users-request@xxxxxxxxxxx with a subject: Unsubscribe You can also unsubscribe by visiting https://lists.cs.wisc.edu/mailman/listinfo/htcondor-users The archives can be found at: https://lists.cs.wisc.edu/archive/htcondor-users/
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature