|
From: | Eric Brunson |
Subject: | [Fab-user] Can't find in the docs, return codes |
Date: | Wed, 12 Jun 2013 15:45:15 -0600 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 |
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: Or possibly: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') I end up having to do something like this:def remove_backups(path): try: run('[ -d %s ]' % path) except NonZeroExitCode: print("no backup dir") return with cd(path): run('rm *.bak') 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. |
[Prev in Thread] | Current Thread | [Next in Thread] |