Re: [Fab-user] Generic prefix context manager?

2009-07-07 Thread Steve Steiner (listsin)
First of all let me tell you I love the idea. In fact I think fabric should be totally aware of venvs and it should be even simpler something like with virtualenv('/path/to/venv/'): cmd('pip install package') I haven't had time to code it. That said in the case of the venv there is one little

Re: [Fab-user] Generic prefix context manager?

2009-07-07 Thread Jorge Vargas
On Tue, Jul 7, 2009 at 5:37 PM, Matthew Wilson wrote: > Since I use a virtualenv on my servers, before I run "python zzz.py", > I need to activate the virtualenv.  So I'm doing this right now: > >    run("source /home/matt/virtualenvs/foo/bin/activate && python zzz.py") > > I read through how fabri

Re: [Fab-user] Generic prefix context manager?

2009-07-07 Thread Jeff Forcier
> I might take a shot at this.  Do you have a design in mind, or do you > want to see what I can come up with? Offhand I was probably going to approach it in a similar manner to your example: env.prefixes as a list, with each invocation of the context manager appending as it enters, then popping a

Re: [Fab-user] Generic prefix context manager?

2009-07-07 Thread Matthew Wilson
On Tue, Jul 7, 2009 at 6:33 PM, Jeff Forcier wrote: > Hi Matt, > > This is definitely on the TODO: make a generic prefix context manager > (and then rework 'cd' to use that) which is capable of prefixing any > arbitrary string. It'll be in for 1.0 for sure, and probably enter > master pretty soon a

Re: [Fab-user] default "global" domain but not host?

2009-07-07 Thread Jeff Forcier
Hi Jorge, I personally have no need for it since my workstation (all my internal systems, actually) make use of the DNS 'domain' and 'search' options, so that if I refer to a non-FQDN hostname, the domain is automatically appended for me. This is the best idea if your 'example.com' is relatively s

Re: [Fab-user] Generic prefix context manager?

2009-07-07 Thread Jeff Forcier
Hi Matt, This is definitely on the TODO: make a generic prefix context manager (and then rework 'cd' to use that) which is capable of prefixing any arbitrary string. It'll be in for 1.0 for sure, and probably enter master pretty soon after I finish the 0.9 beta work. Also, re: virtualenv, I've fo

[Fab-user] Generic prefix context manager?

2009-07-07 Thread Matthew Wilson
Since I use a virtualenv on my servers, before I run "python zzz.py", I need to activate the virtualenv. So I'm doing this right now: run("source /home/matt/virtualenvs/foo/bin/activate && python zzz.py") I read through how fabric.context_managers.cd works. It seems to set a key in the env

[Fab-user] default "global" domain but not host?

2009-07-07 Thread Jorge Vargas
Hi guys, I have been thinking of this and I'll like your opinion. most (if not all) of the time you will be handling several environments for the same project which normally contain the same domain. The classical example will be test.example.com prod1.example.com prod2.example.com db1.example.co

Re: [Fab-user] Maybe my fabfile callables should get called with a parameter

2009-07-07 Thread Jeff Forcier
Check out the value of env.host. It's updated dynamically to be the current host every time. No need to pass anything in, you just need to make sure you import the 'env' object from fabric.api (it's included if you do 'from fabric.api import *', PEP8 compliance notwithstanding.) Better yet, do som

[Fab-user] Maybe my fabfile callables should get called with a parameter

2009-07-07 Thread Matthew Wilson
I'm daydreaming here, but I can see a scenario where I want to do one thing on one box, and something slightly different on another box, e.g.: @hosts('a.example.com') def foo(): run('touch a.example.com') @hosts('b.example.com') def bar(): run('touch b.example.com') It would be neat if I

Re: [Fab-user] @hosts decorator fails in python interactive session?

2009-07-07 Thread Jeff Forcier
Yea, sorry, I did see Mike has a fork with a change along these lines, I haven't had time to go over it yet which is why it wasn't on my mind :) With regards to the execution internals, I expect they'll change a lot over time as we need to make stuff more flexible like in this case, and when we tr

Re: [Fab-user] @hosts decorator fails in python interactive session?

2009-07-07 Thread Mike Ivanov
Jeff Forcier wrote: I anticipate solving this particular problem by further breaking down the fabric/main.py internals so you can just import a function or class that lets you use the host-list logic on your own terms. That was what I tried to say :-) Mike __

Re: [Fab-user] @hosts decorator fails in python interactive session?

2009-07-07 Thread Mike Ivanov
Matthew Wilson wrote: I'm likely doing something wrong, but I can't get the hosts decorator to behave when I use it from within an interactive session: This is because the actual host/role expanding does not happen in decorators. Instead it happens in function main() in main.py, which mean

Re: [Fab-user] @hosts decorator fails in python interactive session?

2009-07-07 Thread Jeff Forcier
Anything relating to host lists will not work correctly interactively, due to how Fabric currently has to execute things. Basically, it imports your fabfile and inspects env and the functions themselves, then figures out how many times to run each function and on which hosts. @hosts simply sets an

[Fab-user] @hosts decorator fails in python interactive session?

2009-07-07 Thread Matthew Wilson
I'm likely doing something wrong, but I can't get the hosts decorator to behave when I use it from within an interactive session: >>> @hosts('jaffa.tplus1.com', 'daffodil.tplus1.com') ... def hostname(): ... run('hostname') ... >>> hostname.hosts ['jaffa.tplus1.com', 'd

Fwd: [Fab-user] How do I handle when something goes wrong

2009-07-07 Thread Jeff Forcier
Check out the docs for sudo and run:    http://docs.fabfile.org/0.9/api/operations.html You'll see mention of a "failed" attribute, so you can do stuff like:    def foo():        result = run('whatever')        if result.failed:            abort("ohnoes!") Best, Jeff On Tue, Jul 7, 2009 at 2:2

[Fab-user] How do I handle when something goes wrong

2009-07-07 Thread Matthew Wilson
I'm going to use fabric to tell my remote webservers to pull down some updated code and then restart. If the code pull fails, I don't want to restart. Instead I want to know about it so I can figure out what went wrong. Is there anything in fabric to let me catch status codes from scripts, or ev