Created
January 3, 2012 01:15
-
-
Save heynemann/1552950 to your computer and use it in GitHub Desktop.
NAMED PIPE READING IMAGE
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import os | |
NAMED_PIPE = '/tmp/PIPE' | |
def main(): | |
if not os.path.exists(NAMED_PIPE): | |
os.mkfifo(NAMED_PIPE) | |
try: | |
while True: | |
print "READING DATA..." | |
pipe = open(NAMED_PIPE, 'r') | |
data = pipe.read() | |
print data | |
finally: | |
pipe.close() | |
os.remove(NAMED_PIPE) | |
if __name__ == '__main__': | |
main() |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
NAMED_PIPE = '/tmp/PIPE' | |
def main(): | |
with open('rafael_amalia.jpg', 'r') as image: | |
pipe = open(NAMED_PIPE, 'w') | |
pipe.write(image.read()) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment