[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fab-user] road to 0.1.0
From: |
Christian Vest Hansen |
Subject: |
Re: [Fab-user] road to 0.1.0 |
Date: |
Sun, 13 Jul 2008 23:29:16 +0200 |
Sorry about this, but I never got the time to review your changes
today. And I'll be going to London tomorrow on vacation, so I won't be
near any computer next week either. Therefor I'm going to release
0.0.8 as it currently is in my master branch. Hope you're OK with that
:)
On 7/13/08, Jeff Forcier <address@hidden> wrote:
> On Sat, Jul 12, 2008 at 6:11 PM, Jeff Forcier <address@hidden> wrote:
>
> > From here, I'll probably poke at this a bit more and try to clean it
> > up a bit, or forge ahead and see about getting capturing implemented.
>
>
> Apologies for replying to myself a second time :) but as of this email
> the HEAD of my 'execution' branch contains an implementation of
> capturing via return value for run() and sudo().
>
> Specifically, _try_run_operation() has been updated to accept either
> the original 'signature' of a single Boolean value, *or* a two-tuple
> of captured stdout + the boolean. run() and sudo() then return that
> two-tuple, and _try_run_operation() uses the boolean for normal
> failure testing, then returns the output if there was any.
>
> Thus, operations that return these two-tuples will effectively return
> their stdout when used in a fab command, but will also respect the
> failure settings vis-a-vis warning/aborting.
>
> With this and the 'deep' mode working, I've successfully implemented
> the command that's been my immediate use-case/goal throughout my
> journeys with Capistrano and then Fabric (see below) and it works fine
> :D This also means that if this functionality ends up in mainline
> Fabric in some form, it will have a big leg up over Capistrano for
> anyone else who wants to use "deployment" tools in this fashion.
>
> Finally, in writing the command below, I notice that mixing set/get
> with normal Python variables gets kind of icky when you need to use
> both in the same string, so that's something I might ponder for later.
> That, and giving users better control over the output of the
> operations -- my command ends up being very verbose, where one would
> rather see mostly/only their own print statements.
>
> Regards,
> Jeff
>
>
> set(
> fab_hosts=['address@hidden', 'localhost'],
>
> fab_mode="deep",
> fab_fail='warn'
> )
>
> def deluser():
> "Archive and delete a user."
> prompt('username', 'User to delete')
> # Only run if exact username found + has homedir
> user_line = run('grep "^$(username):" /etc/passwd')
> if user_line:
> homedir = user_line.split(':')[5]
> if not homedir or not run('ls -d %s' % homedir):
> print("%s has no home directory on %s! Aborting for this host."
> % (get('username'), get('fab_host')))
> return
> # Check size of homedir
> size = sudo('du -sm %s | cut -f1' % homedir).strip()
> if size and int(size) < 200:
> # Archive home dir
> set(archive='$(username).tgz')
> sudo('tar czf /tmp/$(archive) %s' % homedir)
> # Copy it locally
> download('/tmp/$(archive)', '/tmp/$(archive)')
> # Remove user
> # sudo('deluser --remove-home $(username)')
> else:
> print("%s's home directory on %s is %s MB; aborting
> deletion for this host." % (get('username'), get('fab_host'), size))
>
--
Venlig hilsen / Kind regards,
Christian Vest Hansen.
- [Fab-user] road to 0.1.0, Christian Vest Hansen, 2008/07/05
- Re: [Fab-user] road to 0.1.0, Loic d'Anterroches, 2008/07/05
- Message not available
- Re: [Fab-user] road to 0.1.0, Christian Vest Hansen, 2008/07/12
- Re: [Fab-user] road to 0.1.0, Jeff Forcier, 2008/07/12
- Re: [Fab-user] road to 0.1.0, Christian Vest Hansen, 2008/07/12
- Re: [Fab-user] road to 0.1.0, Jeff Forcier, 2008/07/12
- Re: [Fab-user] road to 0.1.0, Jeff Forcier, 2008/07/12
- Re: [Fab-user] road to 0.1.0, Jeff Forcier, 2008/07/13
- Re: [Fab-user] road to 0.1.0,
Christian Vest Hansen <=
- Re: [Fab-user] road to 0.1.0, Jeff Forcier, 2008/07/13
- Re: [Fab-user] road to 0.1.0, Jeff Forcier, 2008/07/18