[1]
import classad
import os
fd = os.popen("condor_history -l -file /root/history")
ads = classad.parseOldAds(fd)
for ad in ads: print ad['ClusterId']
Hi Jose,
Couple notes re the above:
Note that "parseOldAds()" method has been deprecated in favor of
"parseAds()".
Also note there is no need popen the condor_history command-line
tool, since the HTCondor history file is just a sequence
of classads (in 'old' serial format) separated by a line starting
with asterisks. So using a Python generator function to delimit
these on the fly, you could achieve the same thing as your example
above with the following code:
import classad
# Handy one-line generator function to read in an HTCondor
history file
history_file = lambda file: ("\n" if line.startswith("***")
else line for line in open(file,'r'))
# Convert history file to an iterator of ClassAds
ads =
classad.parseAds(history_file("/root/history"),parser=classad.Parser.Old)
# Print something out per ad...
for ad in ads: print(ad['ClusterId'])
Finally note the above was done in Python 3 (I am purging Python 2
from my brain cells) using HTCondor v8.9.8...