fab-user
[Top][All Lists]
Advanced

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

[Fab-user] try: run except run ?


From: Jorge Vargas
Subject: [Fab-user] try: run except run ?
Date: Wed, 20 May 2009 16:40:18 -0400

Hi,


I'm not using this for deployment but to query several servers for
their old non-fabric configs. Long story short I got several servers
and all have sightly different configurations mainly due to human
interaction over time, updates, etc. So I need to make commands that
are good enough for all servers taking into account all the little
inconsistencies (as most can't be fix because they are production
environments)

I'm trying to handle the following.

1- try to find the configuration in pathA
2- if that doesn't exists try pathB
3- if that doesn't exists abort.

For an unrelated reason I'm using grep to figure this out. So
basically I need to figure out if a string is present in fileA or
fileB. The flow of the script is actually.

ok=False
if run('grep string fileA'):
    ok = True
elif run('grep string fileB'):
    fabric.contrib.files.append('something','fileB')
    run('something')
    ok = True

if not ok:
   abort('couldn't locate config")

run('the real command we want to execute')
ssh to another machine
run('another command')

but this bit of code in run() is preventing it from happening

    # Error handling
    output.failed = False
    if status != 0:
        output.failed = True
        msg = "run() encountered an error (return code %s) while
executing '%s'" % (status, command)
        _handle_failure(message=msg)

how can I do this?




reply via email to

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