On Fri, 2010-04-23 at 11:30 +0200, Josef Skladanka wrote:
Hello gang,
take a look at the patch attached - both autotest_server and job.tag are
stored in the autoqa_conf variable.
To get the job.tag there, I had to do a little 'hack' - the autoqa_conf
is stored in the control file as a string, so when creating this string,
I add a parameter
jobtag = %s
to the [general] section of the config, and append
% (job.tag, )
behind the string, so it gets evaluated, when the control file is
imported (i.e. when the job.tag value is known).
It took me a little while to understand the patch, but now that I get
how it works.. that's really clever!
But there's two things:
1) I'd suggest creating a separate section for job-specific data, i.e.:
if not cfg_parser.has_section('job'):
cfg_parser.add_section('job')
cfg_parser.set('job','tag','@JOBTAG@') # see below about @JOBTAG@
2) In my testing, cfg_parser.set('job','tag','%s') will raise:
ValueError: invalid interpolation syntax in '%s' at position 0
(at least, it does on my F13 system). That's why I used '@JOBTAG@'
above. But then we'd need to change the ' % (job.tag, )' part to:
... '''.replace('@JOBTAG(a)',job.tag)
which is starting to get kind of messy.
We could do this a slightly simpler way. In autoqa:
os.write(fd, "autoqa_conf = '''\n%s\n[job]\ntag=%s''' %%
(job.tag, )\n
\n" % cfgdata.read())
This adds the job section and puts the magic bits into the control file
so we get the job tag set. It's inelegant but I think it would work?
only the tests will need minor adjustments in the initialize
method:
def initialize(self, envr, name, kojitag, config):
self.config = config_loader(config, self.tmpdir)
autotest_server = self.config.get('general', 'autotest_server')
jobtag = self.config.get('general', 'jobtag')
self.autotest_url = "http://%s/results/%s/" % (autotest_server,
jobtag)
Probably we'd want to put this into the autoqa library, so it'd look
more like:
def initialize(self, envr, name, kojitag, config):
self.config = config_loader(config, self.tmpdir)
self.autotest_url = autoqa.util.make_autotest_url(config)
What do you think about this approach - I belive it's quite clean
(apart
from the minor job.tag 'hack') and hope you'll like it.
I like it a lot.
I'm still a little confused about why you can get away with doing
cfg_parser.set('job','tag','%s') - maybe you're using F12 and
SafeConfigParser behavior has changed?
Anyway, once we sort out how exactly to set things up so the magic
interpolation happens in the control file as desired - and once we agree
on what section/name to use for the job tag - I think we're really close
to deploying this.
-w