fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] Can't find in the docs, return codes


From: Eric Brunson
Subject: Re: [Fab-user] Can't find in the docs, return codes
Date: Thu, 13 Jun 2013 12:55:01 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5


No worries.  The functionality is there and now I know how to find it.  :-)

Looking forward to v2.

On 06/12/2013 05:57 PM, Jeff Forcier wrote:
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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]