Closed HubLot closed 9 years ago
This is great! I tested it and it works. The use of a custom argparse action is a bit scary but very clever.
The pull request causes the demo2 to stop prematurely in the absence of weblogo, though. I submitted a pull request to @HubLot branch to fix the issue; see https://github.com/HubLot/PBxplore/pull/1. (Yes, I submitted a pull request to a pull request. It's too bad it does not appear in the initial pull request.)
Thanks. Indeed, I forgot to adapt demo2. I just merged your pull request.
This PR aims to solve the issue #60.
The availability of the weblogo program is now tested during the parsing step when the
--logo
option is set.Since it's not possible to add a callback with a
store_true
action, I created a custom action class (CommandAction
). The docstring of this class is pretty straightforward to understand how it works. Basically, it behaves the same way as thestore_true
but add 2 new keywords:weblogo --help
)The test of the availability is done through the subprocess library with the
cmd_exists
function which is called byCommandAction
. This class can be used for any external program, then it can be useful for R for example.From #60, I choose to prevent
PBstat.py
to run if the--logo
option is set and weblogo is not found by raising a exception which will be handle automatically by argparse. I think it's better to stop the script than silent the error.