-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathio_strangler.py
executable file
·41 lines (29 loc) · 997 Bytes
/
io_strangler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
import os
import sys
from ioproxy.logger import Logger
from ioproxy.input import FileDescriptorInput
from ioproxy.output import FileDescriptorOutput
from ioproxy.smtp.strangler import SMTPFileDescriptorStrangler
def die_usage(logger):
this_program = os.path.basename(sys.argv[0]).encode('ASCII')
logger.log(b'usage: ' + this_program +
b' program-to-strangle [ arg ... ]\r\n')
sys.exit(99)
def die_interrupt(logger):
logger.log(b'[interrupted]\r\n')
sys.exit(0)
def main(command_line_arguments):
logger = Logger(sys.stderr.fileno())
if not command_line_arguments:
die_usage(logger)
try:
SMTPFileDescriptorStrangler(
logger,
FileDescriptorInput(sys.stdin.fileno()),
FileDescriptorOutput(sys.stdout.fileno()),
).strangle(77, command_line_arguments)
except KeyboardInterrupt:
die_interrupt(logger)
if '__main__' == __name__:
main(sys.argv[1:])