Ensure it doesn't wait forever if invoked without data
This commit is contained in:
parent
cf8ac9465c
commit
4cf1e39d0b
1 changed files with 10 additions and 0 deletions
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import fileinput
|
import fileinput
|
||||||
|
import sys
|
||||||
|
import select
|
||||||
|
|
||||||
import drymail # Vendored
|
import drymail # Vendored
|
||||||
|
|
||||||
|
@ -30,7 +32,13 @@ def main():
|
||||||
state = State.unknown
|
state = State.unknown
|
||||||
text = list()
|
text = list()
|
||||||
|
|
||||||
|
# https://stackoverflow.com/questions/33871836/find-out-if-there-is-input-from-a-pipe-or-not-in-python
|
||||||
|
if not select.select([sys.stdin], [], [], 0.0)[0]:
|
||||||
|
print("No input processed.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
for line in fileinput.input():
|
for line in fileinput.input():
|
||||||
|
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
text.append(line)
|
text.append(line)
|
||||||
|
|
||||||
|
@ -51,6 +59,8 @@ def main():
|
||||||
text=text
|
text=text
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
client = drymail.SMTPMailer(
|
client = drymail.SMTPMailer(
|
||||||
host='localhost')
|
host='localhost')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue