fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] simple test loop.


From: Morgan Goose
Subject: Re: [Fab-user] simple test loop.
Date: Tue, 19 Oct 2010 11:05:41 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

The get() is going to raise an error, and you're best off surrounding it with a
try/except and returning True outside the catch, and return False if the get
raises the AttributeError.

goose

On Tue, Oct 19, 2010 at 10:54:57AM -0400, Jeff Honey wrote:
> In an effort to do a rudimentary test before moving onto the next host, I've 
> nested one function inside another. I put a file on the host, reboot it, and 
> then test if I can pull it back down. When I can, move to the next host in 
> the loop.
> 
> ...in fabfile.py:
> <snip>
> def is_ready():
>  with settings(warn_only=True):
>   get('/tmp/ready.txt','~/')
> 
> def reboot():
>  for host in env.roledefs['test']:
>   with settings(host_string=host):
>    put('ready.txt','/tmp/')
>    run('shutdown -r now')
>    while not is_ready():
>     time.sleep(60)
>    return True
> </snip>
> 
> ...the resultant error:
> <snip>
> Traceback (most recent call last):
>   File "c:\python26\lib\site-packages\fabric\main.py", line 537, in main 
> commands[name](*args, **kwargs)
>   File "C:\Users\foo\Desktop\fabfile.py", line 41, in reboot while not 
> is_ready():
>   File "C:\Users\foo\Desktop\fabfile.py", line 30, in is_ready 
> get('/tmp/ready.txt','~/')
>   File "C:\Python26\lib\contextlib.py", line 34, in __exit__ 
> self.gen.throw(type, value, traceback)
>   File "C:\Python26\lib\contextlib.py", line 113, in nested yield vars
>   File "C:\Users\foo\Desktop\fabfile.py", line 30, in is_ready 
> get('/tmp/ready.txt','~/')
>   File "c:\python26\lib\site-packages\fabric\network.py", line 391, in 
> host_prompting_wrapper return func(*args, **kwargs)
>   File "c:\python26\lib\site-packages\fabric\operations.py", line 372, in get 
> _handle_failure(message=msg % remote_path, exception=e)
>   File "C:\Python26\lib\contextlib.py", line 153, in __exit__ 
> self.thing.close()
> AttributeError: 'NoneType' object has no attribute 'close'
> Disconnecting from host... done.
> </snip>
> 
> Am I even on the right track?
> --
>  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
> ¤ kyoboku kazeoshi ¤
>  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
---end quoted text---



reply via email to

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