Last active
September 25, 2015 19:24
-
-
Save rstruber/615cda0a9617819ed701 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@task | |
def stats(): | |
with tempfile.NamedTemporaryFile() as f: | |
f.write('first line') | |
execute(collect, f.name) | |
import pdb; pdb.set_trace() | |
# from pdb, get f.name, and cat the file shows N lines in the file without "first line" | |
f.seek(0) | |
# cat the temp file, only has "first line" | |
for l in f: | |
print(green(l)) # prints "first line" | |
@task | |
@parallel | |
@roles('vm') | |
def collect(f_name): | |
with open(f_name, 'a+b') as f: | |
f.write('%s\n'.format(env.host)) | |
with open(f_name, 'r+b') as f: | |
f.seek(0) | |
print f.read() # prints this host plus whatever else got there first |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment