Created
November 12, 2017 11:25
-
-
Save ddrscott/9a78e90ebf14c2c8b399dc51a3939a7d to your computer and use it in GitHub Desktop.
Example checking for std in data.
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 logging | |
| import sys | |
| from tempfile import SpooledTemporaryFile | |
| try: | |
| with SpooledTemporaryFile() as temp: | |
| temp.write(sys.stdin.read()) | |
| logging.debug("tell: %i" % temp.tell()) | |
| if temp.tell() > 0: | |
| temp.seek(0) | |
| # do something with the data | |
| except Exception as msg: | |
| logging.error("could not read stdin:") | |
| logging.error(msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment