Created
September 22, 2012 00:36
-
-
Save slackorama/3764666 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
import zlib | |
import sys | |
import subprocess | |
import tempfile | |
d = zlib.decompressobj(16+zlib.MAX_WBITS) | |
def bob(data): | |
for value in data: | |
print(value) | |
def load_stream(input_stream): | |
while True: | |
data = input_stream.read(1024*8) | |
if not data: | |
break | |
yield d.decompress(data) | |
if __name__ == '__main__': | |
f = tempfile.NamedTemporaryFile(delete=False) | |
name = f.name | |
p1 = subprocess.Popen(['cat', '/home/seth/.emacs.d/init.el'], | |
stdout=subprocess.PIPE) | |
p2 = subprocess.Popen(['/bin/gzip', '-c'], stdin=p1.stdout, | |
stdout=f) | |
p1.stdout.close() | |
p2.communicate()[0] | |
f.close() | |
print(name) | |
# print(p2.communicate()[0]) | |
# # becomes | |
# p1 = Popen(["dmesg"], stdout=PIPE) | |
# p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE) | |
# p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. | |
# output = p2.communicate()[0] | |
# print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment