On Wed, Feb 23, 2011 at 4:18 PM, Scott Henson <shenson(a)redhat.com> wrote:
On Wed, 23 Feb 2011 14:57:28 -0500, Andrew Rankin
<andrew(a)eiknet.com> wrote:
>
> Additional patch for setup.py and cobbler.spec to create the paths attached.
>
Merged. Thanks!
--
Scott Henson
Red Hat CIS Operator
WVU Alum BSAE/BSME
So noticed this morning that the addition of self to self.on_done()
actually makes running any other background tasks show as failed
through the web interface now (from a sync):
Thu Feb 24 10:26:44 2011 - INFO | ### TASK COMPLETE ###
Thu Feb 24 10:26:44 2011 - INFO | Exception occured: exceptions.TypeError
Thu Feb 24 10:26:44 2011 - INFO | Exception value: on_done() takes
exactly 1 argument (2 given)
Thu Feb 24 10:26:44 2011 - INFO | Exception Info:
File "/usr/lib/python2.4/site-packages/cobbler/remote.py", line 97, in run
self.on_done(self)
Thu Feb 24 10:26:44 2011 - ERROR | ### TASK FAILED ###
Looks like background_buildiso is the only thing including it's own
on_done and overriding the dummy on_done in CobblerThread. Perhaps
someone with greater knowledge of python can help me understand this
better:
on_done is defined with CobblerThread as:
def on_done(self):
pass
It's being overridden by background_buildiso with an on_done defined as:
def on_done(self):
if self.options.get("iso","") ==
"/var/www/cobbler/pub/generated.iso":
msg = "ISO now available for <A
HREF=\"/cobbler/pub/generated.iso\">download</A>"
self.remote._new_event(msg)
Since background_sync is not overriding on_done, it's using the dummy
defined in CobblerThread, which expects one argument. The call to it
after my patch is:
self.on_done(self)
We're only sending one argument, but the 'self.' adds CobblerThread's
address as the first argument so we end up with two. Fine, that's
expected - but why when we call background_isobuild and it overrides
the on_done does python view self.on_done(self) as only 1 argument?
My workaround was just to not define a dummy or call on_done in
CobblerThread unless one is passed to it when object instance is
created in __start_task (see diff). But this really is only a
workaround to deal with the functions expecting a different number
arguments. You still have to pass self to on_done when you call it,
which confuses me - you're calling it as self.on_done(self) so
shouldn't it end up with two arguments?
Andrew