Yea, the docs for it aren't great. v2 will have actual, publicly
documented classes for all of this kind of thing, instead of multiple
printed-pages' worth of paragraphs in the run() docstring :) sorry!
Best,
Jeff
On Wed, Jun 12, 2013 at 3:32 PM, Eric Brunson <address@hidden> wrote:
That's definitely it, I wasn't reading closely enough.
What threw me off that I checked the type of the object returned by run()
and the looked at pydoc for fabric.operations._AttributeString. I thought
it would have included the class attributes and methods defined in the
module, but only saw the methods inherited from string.
Looking at operations.py I now see that they're added dynamically so
wouldn't show up in the pydoc. If I do a dir(result) I can see them.
Thanks for pointing that out.
On 06/12/2013 03:58 PM, Jeff Forcier wrote:
I must not be following, why doesn't result.succeeded / result.failed
work for this use case? Or doing e.g. "if result.return_code not in
[0, 1]"?
See ~third paragraph off
http://docs.fabfile.org/en/1.6/api/core/operations.html#fabric.operations.run
On Wed, Jun 12, 2013 at 2:45 PM, Eric Brunson <address@hidden> wrote:
I'm hoping to start a discussion of behavior that would aid in
implementing
flow control. I've only been using fabric for a couple of months, so
maybe
I just need some education on better coding patterns.
What I'd like to be able to do is something like this:
def remove_backups(path):
with settings(warn_only=True), hide('warnings'):
result = run('[ -d %s ]' % path)
if ! result.error_code:
with cd(path):
run('rm *.bak')
Or possibly:
def remove_backups(path):
try:
run('[ -d %s ]' % path)
except NonZeroExitCode:
print("no backup dir")
return
with cd(path):
run('rm *.bak')
I end up having to do something like this:
def remove_backups(path):
with settings(warn_only=True), hide('stderr','warnings'):
result = run('[ -d %s ] && echo true' % path)
if result == 'true':
run('rm *.bak')
Which is less than pythonic.
Has there ever been discussion of throwing exceptions or handling exit
codes
rather than the default "Abort unless otherwise instructed?" tactic as it
currently exists? Constructing intelligent flow control gets really
messy
in the current implementation.
Other than that, I've been using the crap out of the application and
think
it's great. Thanks for all the hard work.
Sincerely,
e.
_______________________________________________
Fab-user mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fab-user
_______________________________________________
Fab-user mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/fab-user