[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Pulp-list] Feedback on sync_repo() result reporting for v2 plugins



I'm not ignoring this, I'm just so deep into the unit association stuff that I'm afraid I'd do physical damage to my brain if I were to try to shift gears and think about this. I'll take a look in the next few days.


On 12/12/2011 05:44 PM, Nick Coghlan wrote:
Based on the current status of the v2 APIs, I now have some working
rsync-based importer plugins up and running:

http://git.fedorahosted.org/git/?p=pulpdist.git;a=blob;f=src/pulpdist/pulp_plugins/importers/pulpdist_importers/importer.py


(If you want to look at the code for the sync operations themselves,
they're in pulpdist.core:
http://git.fedorahosted.org/git/?p=pulpdist.git;a=blob;f=src/pulpdist/core/sync_trees.py)


However, I think the error reporting API leaves a bit to be desired as
it currently stands. I'd like to be able to raise an exception to
indicate a problem, but provide additional details in the result as
structured data.

Currently, I jam everything I want to report into an exception message:

except:
et, ev, tb = sys.exc_info()
msg_format = (
"exception: {0}\n"
"error_message: {1}\n"
"traceback:\n{2}\n"
"log_details:\n{3}\n"
)
raise RuntimeError(msg.format(et, ev,
traceback.format_tb(tb),
sync_log.getvalue()))

I'd prefer it if I could do something more like what I'm able to do in
the success case via sync_conduit.build_report():

except:
et, ev, tb = sys.exc_info()
err_summary = {
"result": command.SYNC_FAILED
"exception": str(et)
"message": str(ev)
}
err_details = {
"sync_log": sync_log.getvalue()
"traceback": traceback.format_tb(tb)
}
raise sync_conduit.sync_error(err_summary, err_details)

If I had that richer API, I could also correctly report SYNC_PARTIAL as
an error without losing data by replacing the current build_report()
call with the following:

if result == command.SYNC_PARTIAL:
raise sync_conduit.sync_error(summary, details)
else:
report = sync_conduit.build_report(summary, details)

Regards,
Nick.



--
Jay Dobies
Freenode: jdob @ #pulp
http://pulpproject.org | http://blog.pulpproject.org


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]